Class: $.BackgroundTimerView

Inherits:
WatchUi.View show all

Overview

The main view for the timer application. This displays the remaining time on the countdown timer

Constant Summary

Constant Variables

Type Name Value Since Description
Type TIMER_DURATION_DEFAULT (5*60)

TimerKeys

Name Value Since Description
TIMER_KEY_DURATION 0
TIMER_KEY_START_TIME 1
TIMER_KEY_PAUSE_TIME 2

Instance Member Summary collapse

Instance Method Summary collapse

Instance Attribute Details

var _timerDuration as Lang.Number

var _timerPauseTime as Lang.Number or Null

var _timerStartTime as Lang.Number or Null

var _updateTimer as Timer.Timer

Instance Method Details

backgroundEvent() as Void

If we do receive a background event while the application is open, go ahead and reset to the default timer.

deleteBackgroundEvent() as Void

Delete the background event. We can get rid of this event when the application opens because now we can see exactly when the timer is going to expire. We will set it again when the application closes.

initialize(backgroundRan as Application.PersistableType)

Initialize variables for this view

Parameters:

  • backgroundRan —

    Contains background data if background ran

onUpdate(dc as Graphics.Dc) as Void

Draw the time remaining on the timer to the display

Parameters:

  • dc —

    Device Context

requestUpdate() as Void

This is the callback method we use for our timer. It is only needed to request display updates as the timer counts down so we see the updated time on the display.

resetTimer() as Lang.Boolean

If the timer is paused, then go ahead and reset it back to the default time.

Returns:

  • true if timer is reset, false otherwise

saveProperties() as Void

Save all the persisted values into the object store. This gets called by the Application base before the application shuts down.

setBackgroundEvent() as Void

Set up a background event to occur when the timer expires. This will alert the user that the timer has expired even if the application does not remain open.

startStopTimer() as Void

If the timer is running, pause it. Otherwise, start it up.


Generated Jun 9, 2026, 8:45:34 AM