Пример #1
0
 private static void clearSnoozeIfNeeded(Context context, long alarmTime) {
   // If this alarm fires before the next snooze, clear the snooze to
   // enable this alarm.
   SharedPreferences prefs = context.getSharedPreferences(PREFERENCES, 0);
   long snoozeTime = prefs.getLong(PREF_SNOOZE_TIME, 0);
   if (alarmTime < snoozeTime) {
     clearSnoozePreference(context, prefs);
   }
 }
Пример #2
0
 /** Disable the snooze alert if the given id matches the snooze id. */
 public static void disableSnoozeAlert(final Context context, final int id) {
   SharedPreferences prefs = context.getSharedPreferences(PREFERENCES, 0);
   int snoozeId = prefs.getInt(PREF_SNOOZE_ID, -1);
   if (snoozeId == -1) {
     // No snooze set, do nothing.
     return;
   } else if (snoozeId == id) {
     // This is the same id so clear the shared prefs.
     clearSnoozePreference(context, prefs);
   }
 }
Пример #3
0
 public static void saveSnoozeAlert(final Context context, final int id, final long time) {
   SharedPreferences prefs = context.getSharedPreferences(PREFERENCES, 0);
   if (id == -1) {
     clearSnoozePreference(context, prefs);
   } else {
     SharedPreferences.Editor ed = prefs.edit();
     ed.putInt(PREF_SNOOZE_ID, id);
     ed.putLong(PREF_SNOOZE_TIME, time);
     ed.commit();
   }
   // Set the next alert after updating the snooze.
   setNextAlert(context);
 }