Changeset 255 for trunk/hiptop
- Timestamp:
- 07/19/06 04:38:21 (18 years ago)
- Location:
- trunk/hiptop/pester/net/sabi/pester
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hiptop/pester/net/sabi/pester/Alarm.java
r253 r255 8 8 import danger.audio.RingToneObject; 9 9 import danger.internal.Date; 10 import danger.system.Hardware; 10 11 import danger.util.LocaleUtils; 11 12 import danger.util.StdActiveList; … … 27 28 // transient 28 29 private int mState; 30 private int mAbsoluteFireTime; // only valid if periodic 29 31 private danger.app.Alarm mAlarm; 30 32 … … 122 124 } 123 125 124 // XXX trigger on EVENT_TIME_CHANGED125 126 void resume() { 126 127 mState = STATE_SCHEDULED; … … 132 133 } 133 134 135 void timeChanged() { 136 if (mState != STATE_SCHEDULED) 137 return; 138 if (getUsesPeriod()) { 139 int realSecondsLeft = mAbsoluteFireTime - Hardware.getAbsoluteTime(); 140 mDate = new Date(); 141 mDate.addSeconds(realSecondsLeft < 0 ? 0 : realSecondsLeft); 142 // no need to call resume(): alarm uses absolute time 143 } else { 144 resume(); 145 } 146 } 147 134 148 void schedule() { 135 149 if (getUsesPeriod()) { 136 150 mDate = new Date(); 137 151 mDate.addSeconds(mPeriod); 152 mAbsoluteFireTime = Hardware.getAbsoluteTime() + mPeriod; 138 153 } 139 154 resume(); -
trunk/hiptop/pester/net/sabi/pester/AlarmSetDialog.java
r254 r255 127 127 } 128 128 validate(); 129 Application.registerForEvent(this, Event.EVENT_TIME_CHANGED) );129 Application.registerForEvent(this, Event.EVENT_TIME_CHANGED); 130 130 show(); 131 131 if (!mHaveShownWindow) { -
trunk/hiptop/pester/net/sabi/pester/Alarms.java
r250 r255 2 2 3 3 import java.util.Comparator; 4 import danger.app.Application; 4 5 import danger.app.DataStore; 6 import danger.app.Event; 5 7 import danger.util.StdActiveList; 6 8 … … 10 12 11 13 private static Alarms sAlarmList = null; 12 private static DataStore sDataStore; 14 private static Listener sListener; 15 16 private DataStore mDataStore; 13 17 14 18 private Alarms() { 15 sDataStore = DataStore.createDataStore("alarms", true /* auto sync */);19 mDataStore = DataStore.createDataStore("alarms", true /* auto sync */); 16 20 } 17 21 18 22 public static Alarms getList() { 19 if (sAlarmList == null) 23 if (sAlarmList == null) { 20 24 sAlarmList = new Alarms(); 25 sListener = new Listener(); 26 Application.registerForEvent(sListener, Event.EVENT_TIME_CHANGED); 27 } 21 28 return sAlarmList; 22 29 } … … 37 44 } 38 45 */ 46 47 static class Listener extends danger.app.Listener 48 implements danger.util.ActiveList.ForEach { 49 50 public void receive(Object item) { 51 ((Alarm)item).timeChanged(); 52 } 53 54 public boolean receiveEvent(Event e) { 55 if (e.type == Event.EVENT_TIME_CHANGED) { 56 // XXX do we get this when the time zone changes? 57 Alarms.getList().forEach(this); 58 return true; 59 } 60 return super.receiveEvent(e); 61 } 62 } 39 63 } 64
Note:
See TracChangeset
for help on using the changeset viewer.