added debug variable

This commit is contained in:
Ronald Schaten 2011-06-13 14:04:37 +02:00
parent bc3383b42e
commit 2492c12804

View File

@ -27,7 +27,8 @@ public class WaldemarWidget extends AppWidgetProvider {
private static final double SECONDS_PER_DAY = 24 * 60 * 60; private static final double SECONDS_PER_DAY = 24 * 60 * 60;
private static final double MILLISECONDS_PER_DAY = SECONDS_PER_DAY * 1000; private static final double MILLISECONDS_PER_DAY = SECONDS_PER_DAY * 1000;
private static final int CURRENTLY_NOT_USED_REQUEST_CODE = 0; private static final int CURRENTLY_NOT_USED_REQUEST_CODE = 0;
private static final int SUSPICIOUS_FLAGS = 0; private static final int SUSPICIOUS_FLAGS = 0;
private static final boolean DEBUG = false;
static AlarmManager myAlarmManager; static AlarmManager myAlarmManager;
static PendingIntent myPendingIntent; static PendingIntent myPendingIntent;
@ -48,12 +49,13 @@ public class WaldemarWidget extends AppWidgetProvider {
AlarmManager alarmManager = (AlarmManager) context AlarmManager alarmManager = (AlarmManager) context
.getSystemService(Context.ALARM_SERVICE); .getSystemService(Context.ALARM_SERVICE);
long midnightInMillis = getMidnightInMillis(); long midnightInMillis = getMidnightInMillis();
//alarmManager.setRepeating(AlarmManager.RTC, midnightInMillis, long interval = AlarmManager.INTERVAL_DAY;
// AlarmManager.INTERVAL_DAY, pendingIntent); if (DEBUG) {
alarmManager.setRepeating(AlarmManager.RTC, midnightInMillis, interval = AlarmManager.INTERVAL_FIFTEEN_MINUTES;
AlarmManager.INTERVAL_FIFTEEN_MINUTES, pendingIntent); }
alarmManager.setRepeating(AlarmManager.RTC, midnightInMillis, interval,
WaldemarWidget.saveAlarmManager(alarmManager, pendingIntent); pendingIntent);
saveAlarmManager(alarmManager, pendingIntent);
} }
@Override @Override
@ -140,8 +142,10 @@ public class WaldemarWidget extends AppWidgetProvider {
status = ""; status = "";
} }
DateFormat format = SimpleDateFormat.getTimeInstance(SimpleDateFormat.MEDIUM, Locale.getDefault()); if (DEBUG) {
status = status + "\n" + format.format(new Date()); DateFormat format = SimpleDateFormat.getTimeInstance(SimpleDateFormat.MEDIUM, Locale.getDefault());
status = status + "\n" + format.format(new Date());
}
remoteViews.setProgressBar(R.id.progress, duration, duration - days, false); remoteViews.setProgressBar(R.id.progress, duration, duration - days, false);
remoteViews.setTextViewText(R.id.status, status); remoteViews.setTextViewText(R.id.status, status);
@ -149,7 +153,7 @@ public class WaldemarWidget extends AppWidgetProvider {
appWidgetManager.updateAppWidget(appWidgetId, remoteViews); appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
} }
static void saveAlarmManager(AlarmManager alarmManager, private void saveAlarmManager(AlarmManager alarmManager,
PendingIntent pendingIntent) { PendingIntent pendingIntent) {
myAlarmManager = alarmManager; myAlarmManager = alarmManager;
myPendingIntent = pendingIntent; myPendingIntent = pendingIntent;