Timer Info

Timer Info

The TimerInfo component handles live counting timers. It is used across various layouts—including Animated Info and the Dynamic Island (Big Island)—to display countdowns or stopwatches that update in real-time without needing constant push updates.

Usage

1
2
3
4
5
6
7
8
9
val now = System.currentTimeMillis()
val duration = 60_000L // 1 minute

val myTimer = TimerInfo(
    timerType = -1,             // -1 = Start Countdown
    timerWhen = now + duration, // Target End Time
    timerTotal = duration,      // Total Duration
    timerSystemCurrent = now    // Current System Time
)

Data Model (TimerInfo)

ParameterTypeDescription
timerTypeIntRequired. Controls the timer mode and state.
-2: Stop/Pause Countdown.
-1: Start Countdown (Counts down to timerWhen).
0: Default / Standard.
1: Start Chronometer (Counts up).
2: Stop/Pause Chronometer.
timerWhenLongRequired. The absolute target timestamp (milliseconds).
For countdowns, this is the time when the timer hits 0.
timerTotalLongRequired. The total duration of the timer in milliseconds. Used to calculate progress bars (if applicable).
timerSystemCurrentLongRequired. The System.currentTimeMillis() at the moment of creation. This is used to synchronize the timer and calculate accurate offsets.