danger.app
Class Timer

java.lang.Object
  extended by danger.app.Timer


public class Timer
extends Object

Application interface to timers. You can use Timer to get notified based on time. Timer uses the event system to send notifications. One can setup a new Timer, activate it, and handle the timer event callback by handling EventType.EVENT_TIMER in the receiveEvent() method. The requirement is that one has to be a listener to be able to receive timer events. Timer's granularity is in milliseconds. Timer does not run when the system is in the sleep mode. For example, when you set up an timer to fire in 1 minute, but the system goes into sleep for a minute right after the timer is activated, the timer won't fire for another minute after the system wakes up from sleep mode. This is because Timer is based on the system clock, which stops running in sleep mode. Another note worth mentioning is that the system time on Danger OS wraps every 49.23 hours. The Timer class is designed to operate correctly when the system time wraps.


Constructor Summary
Timer(int delay)
          Class constructor specifying delay time.
Timer(int delay, boolean repeats, Listener target)
          Class constructor specifying delay time, repeat option, and listener.
Timer(int delay, boolean repeats, Listener target, int data)
          Class constructor specifying delay time, repeat option, listener, and data Constructs an timer with the specified delay time.
Timer(int delay, boolean repeats, Listener target, int data, Object context)
          Class constructor specifying delay time, repeat option, listener, event data, and context Constructs an timer with the specified delay time.
Timer(int delay, boolean repeats, Listener target, Object context)
          Class constructor specifying delay time, repeat option, listener, and context Constructs an timer with the specified delay time.
 
Method Summary
 void resetDelay(int inDelay)
          Reset the timer's time.
 void start()
          Starts the timer.
 void stop()
          Stops the timer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Timer

public Timer(int delay)
Class constructor specifying delay time. Constructs an timer with the specified delay time. The timer events are sent to the application that creates the timer.

Parameters:
delay - time to timer firing specified in milliseconds from when the timer is activated. the minimum delay time allowed is 30 milliseconds.

Timer

public Timer(int delay,
             boolean repeats,
             Listener target)
Class constructor specifying delay time, repeat option, and listener. Constructs an timer with the specified delay time. The timer events are sent to the application that creates the timer.

Parameters:
delay - time to timer firing specified in milliseconds from when the timer is activated. the minimum delay time allowed is 30 milliseconds.
repeats - whether the timer is to be repeated.
target - Listener.
See Also:
Listener

Timer

public Timer(int delay,
             boolean repeats,
             Listener target,
             int data)
Class constructor specifying delay time, repeat option, listener, and data Constructs an timer with the specified delay time. The timer events are sent to the application that creates the timer.

Parameters:
delay - time to timer firing specified in milliseconds from when the timer is activated. the minimum delay time allowed is 30 milliseconds.
repeats - whether the timer is to be repeated.
target - Listener.
data - data argument to be passed back in the Timer event.
See Also:
Listener

Timer

public Timer(int delay,
             boolean repeats,
             Listener target,
             Object context)
Class constructor specifying delay time, repeat option, listener, and context Constructs an timer with the specified delay time. The timer events are sent to the application that creates the timer.

Parameters:
delay - time to timer firing specified in milliseconds from when the timer is activated. the minimum delay time allowed is 30 milliseconds.
repeats - whether the timer is to be repeated.
target - Listener.
context - argument to be passed back in the Timer event.
See Also:
Listener

Timer

public Timer(int delay,
             boolean repeats,
             Listener target,
             int data,
             Object context)
Class constructor specifying delay time, repeat option, listener, event data, and context Constructs an timer with the specified delay time. The timer events are sent to the application that creates the timer.

Parameters:
delay - time to timer firing specified in milliseconds from when the timer is activated. the minimum delay time allowed is 30 milliseconds.
repeats - whether the timer is to be repeated.
target - Listener.
data - data argument to be passed back in the Timer event.
context - argument to be passed back in the Timer event.
See Also:
Listener
Method Detail

start

public void start()
Starts the timer. Starts the timer. Timer events will be sent to the listener when the timer fires.


stop

public void stop()
Stops the timer. Stops the timer. This prevents the timer events from being sent to the listener.


resetDelay

public void resetDelay(int inDelay)
Reset the timer's time. Resets the timer's time. This stops the current timer, if one has been started; resets the time, and starts up a new timer.

Parameters:
inDelay - time to timer firing specified in milliseconds from now.