Changeset 299


Ignore:
Timestamp:
08/06/06 16:45:05 (18 years ago)
Author:
Nicholas Riley
Message:

Midnight check - changes "Tomorrow" to "Today" etc. at midnight.

Location:
trunk/hiptop/pester/net/sabi/pester
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/hiptop/pester/net/sabi/pester/Alarms.java

    r297 r299  
    189189            if (e.type == Event.EVENT_TIME_CHANGED) {
    190190                Alarms.getList().forEach(this);
     191                ((Pester)Application.getCurrentApp()).resetMidnightCheck();
    191192                return true;
    192193            } else if (e.type == Event.EVENT_DATASTORE_RESTORED) {
  • trunk/hiptop/pester/net/sabi/pester/Pester.java

    r296 r299  
    33import danger.app.Application;
    44import danger.app.Event;
     5import danger.internal.Date;
     6import danger.system.Hardware;
    57import danger.ui.AlertWindow;
    68import danger.ui.Container;
     
    1719public class Pester extends Application implements Resources, Commands {
    1820    private static ScreenWindow sAlarmListWindow;
     21    private static danger.app.Alarm sMidnightAlarm;
    1922
    2023    public Pester() {
    2124        sAlarmListWindow = (ScreenWindow)getResources().getScreen(ID_ALARM_LIST_SCREEN);
    2225        sAlarmListWindow.show();
     26        sMidnightAlarm = new danger.app.Alarm(0, this, null);
     27        resetMidnightCheck();
     28    }
     29
     30    void resetMidnightCheck() {
     31        int now = Hardware.getDate();
     32        Date midnight = new Date();
     33        midnight.addDays(1);
     34        midnight.setTime(0);
     35        sMidnightAlarm.resetWake(midnight.getDangerTimeGMT() - now);
     36        DEBUG.p("Pester.resetMidnightCheck");
    2337    }
    2438
     
    6680        switch (e.type) {
    6781        case Event.EVENT_ALARM:
     82            if (e.argument == null) { // midnight
     83                updatePreviewScreen();
     84                // update alarm list
     85                sAlarmListWindow.receiveEvent(event(Event.EVENT_TIME_CHANGED, 0));
     86                resetMidnightCheck();
     87                return true;
     88            }
    6889            showAlertForAlarm((Alarm)e.argument);
    6990            return true;
Note: See TracChangeset for help on using the changeset viewer.