public abstract class POBCountdownTimer
extends java.lang.Object
Example of showing a 30 second countdown in a text field:
new POBCountdownTimer(30, 1) {
public void onTick(long secondsUntilFinished) {
mTextField.setText("seconds remaining: " + secondsUntilFinished);
}
public void onFinish() {
mTextField.setText("done!");
}
}.start();
The calls to onTick(long) are synchronized to this object so that
one call to onTick(long) won't ever occur before the previous
callback is complete. This is only relevant when the implementation of
onTick(long) takes an amount of time to execute that is significant
compared to the countdown interval.| Constructor and Description |
|---|
POBCountdownTimer(long secondsInFuture,
long countDownIntervalInSeconds,
android.os.Looper looper) |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancel the countdown.
|
abstract void |
onFinish()
Callback fired when the time is up.
|
abstract void |
onTick(long secondsUntilFinished)
Callback fired on regular interval.
|
long |
pause()
Pause the countdown.
|
long |
resume()
Resume the countdown.
|
POBCountdownTimer |
start()
Start the countdown.
|
public POBCountdownTimer(long secondsInFuture,
long countDownIntervalInSeconds,
@NonNull
android.os.Looper looper)
secondsInFuture - The number of seconds in the future from the call
to start() until the countdown is done and onFinish()
is called.countDownIntervalInSeconds - The interval in seconds along the way to receive
onTick(long) callbacks.looper - the instance of looper, to provide callbacks on provided looperpublic final void cancel()
Do not call it from inside CountDownTimer threads
public final POBCountdownTimer start()
public long pause()
public long resume()
public abstract void onTick(long secondsUntilFinished)
secondsUntilFinished - The amount of time until finished.public abstract void onFinish()