Search in sources :

Example 1 with AppListener

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);
    }
}
Also used : Context(android.content.Context) Intent(android.content.Intent) AppListener(com.bourke.glimmr.services.AppListener)

Example 2 with AppListener

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);
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) AppListener(com.bourke.glimmr.services.AppListener)

Aggregations

AppListener (com.bourke.glimmr.services.AppListener)2 Context (android.content.Context)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1