fetch preferences
This commit is contained in:
parent
3ce2889b00
commit
682d1dd013
@ -90,17 +90,22 @@ public class WaldemarWidget extends AppWidgetProvider {
|
|||||||
calNow.set(Calendar.SECOND, 0);
|
calNow.set(Calendar.SECOND, 0);
|
||||||
long timeNow = calNow.getTimeInMillis();
|
long timeNow = calNow.getTimeInMillis();
|
||||||
|
|
||||||
|
Calendar calStart = DatePreference.getDateFor(PreferenceManager.getDefaultSharedPreferences(context), "pref_dateStart");
|
||||||
|
long timeStart = calStart.getTimeInMillis();
|
||||||
|
|
||||||
|
Integer duration = Integer.parseInt(prefs.getString("pref_duration", context.getString(R.string.duration_default)));
|
||||||
|
|
||||||
Calendar calThen = DatePreference.getDateFor(PreferenceManager.getDefaultSharedPreferences(context), "pref_dateThen");
|
Calendar calThen = DatePreference.getDateFor(PreferenceManager.getDefaultSharedPreferences(context), "pref_dateThen");
|
||||||
long timeThen = calThen.getTimeInMillis();
|
long timeThen = calThen.getTimeInMillis();
|
||||||
|
|
||||||
long days = Math.round((double) (timeThen - timeNow) / 86400000.);
|
Integer days = (int)Math.round((double) (timeThen - timeNow) / 86400000.);
|
||||||
remoteViews.setTextViewText(R.id.daycount, String.valueOf(days));
|
remoteViews.setTextViewText(R.id.daycount, String.valueOf(days));
|
||||||
|
|
||||||
DateFormat format = SimpleDateFormat.getTimeInstance(
|
DateFormat format = SimpleDateFormat.getTimeInstance(
|
||||||
SimpleDateFormat.MEDIUM, Locale.getDefault());
|
SimpleDateFormat.MEDIUM, Locale.getDefault());
|
||||||
remoteViews.setTextViewText(R.id.debug, format.format(new Date()));
|
remoteViews.setTextViewText(R.id.debug, format.format(new Date()));
|
||||||
|
|
||||||
remoteViews.setProgressBar(R.id.progress, 267, 166, false);
|
remoteViews.setProgressBar(R.id.progress, duration, duration - days, false);
|
||||||
|
|
||||||
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
|
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user