use of com.bourke.glimmr.services.AppListener in project glimmr by brk3.
the class SettingsFragment method onSharedPreferenceChanged.
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (Constants.KEY_INTERVALS_LIST_PREFERENCE.equals(key)) {
updateIntervalSummary();
WakefulIntentService.scheduleAlarms(new AppListener(), getActivity(), false);
} else if (Constants.KEY_ENABLE_NOTIFICATIONS.equals(key)) {
boolean enableNotifications = sharedPreferences.getBoolean(Constants.KEY_ENABLE_NOTIFICATIONS, false);
if (!enableNotifications) {
if (BuildConfig.DEBUG)
Log.d(TAG, "Cancelling alarms");
AppService.cancelAlarms(getActivity());
} else {
WakefulIntentService.scheduleAlarms(new AppListener(), getActivity(), false);
}
} else if (Constants.KEY_INITIAL_TAB_LIST_PREFERENCE.equals(key)) {
updateInitialTabSummary();
} else if (Constants.KEY_SLIDESHOW_INTERVAL.equals(key)) {
updateSlideshowIntervalSummary();
} else if (Constants.KEY_HIGH_QUALITY_THUMBNAILS.equals(key)) {
/* Restart the main activity to clear the memory cache */
Context baseContext = getActivity().getBaseContext();
Intent i = baseContext.getPackageManager().getLaunchIntentForPackage(baseContext.getPackageName());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
}
use of com.bourke.glimmr.services.AppListener in project glimmr by brk3.
the class MainActivity method initNotificationAlarms.
private void initNotificationAlarms() {
SharedPreferences defaultSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean enableNotifications = defaultSharedPrefs.getBoolean(Constants.KEY_ENABLE_NOTIFICATIONS, false);
if (enableNotifications) {
if (BuildConfig.DEBUG)
Log.d(TAG, "Scheduling alarms");
WakefulIntentService.scheduleAlarms(new AppListener(), this, false);
} else {
if (BuildConfig.DEBUG)
Log.d(TAG, "Cancelling alarms");
AppService.cancelAlarms(this);
}
}
Aggregations