예제 #1
0
 public static void resetTimersInSharedPrefs(SharedPreferences prefs) {
   ArrayList<TimerObj> timers = new ArrayList<TimerObj>();
   getTimersFromSharedPrefs(prefs, timers);
   Iterator<TimerObj> i = timers.iterator();
   while (i.hasNext()) {
     TimerObj t = i.next();
     t.mState = TimerObj.STATE_RESTART;
     t.mTimeLeft = t.mOriginalLength = t.mSetupLength;
     t.writeToSharedPref(prefs);
   }
 }
예제 #2
0
 public static void getTimersFromSharedPrefs(
     SharedPreferences prefs, ArrayList<TimerObj> timers, int match) {
   Object[] timerStrings = prefs.getStringSet(PREF_TIMERS_LIST, new HashSet<String>()).toArray();
   if (timerStrings.length > 0) {
     for (int i = 0; i < timerStrings.length; i++) {
       TimerObj t = new TimerObj();
       t.mTimerId = Integer.parseInt((String) timerStrings[i]);
       t.readFromSharedPref(prefs);
       if (t.mState == match) {
         timers.add(t);
       }
     }
   }
 }
예제 #3
0
 public static void getTimersFromSharedPrefs(SharedPreferences prefs, ArrayList<TimerObj> timers) {
   Object[] timerStrings = prefs.getStringSet(PREF_TIMERS_LIST, new HashSet<String>()).toArray();
   if (timerStrings.length > 0) {
     for (int i = 0; i < timerStrings.length; i++) {
       TimerObj t = new TimerObj();
       t.mTimerId = Integer.parseInt((String) timerStrings[i]);
       t.readFromSharedPref(prefs);
       timers.add(t);
     }
     Collections.sort(
         timers,
         new Comparator<TimerObj>() {
           @Override
           public int compare(TimerObj timerObj1, TimerObj timerObj2) {
             return timerObj2.mTimerId - timerObj1.mTimerId;
           }
         });
   }
 }