Google is committed to advancing racial equity for Black communities. See how.

ManualAnimationClock

class ManualAnimationClock : BaseAnimationClock
kotlin.Any
   ↳ androidx.animation.BaseAnimationClock
   ↳ androidx.animation.ManualAnimationClock

A custom clock whose frame time can be manually updated via mutating clockTimeMillis. Observers will be called immediately with the current time when they are subscribed. Use dispatchOnSubscribe = false to wait for the next tick instead, which can be useful if the current time might be outdated.

Summary

Public constructors
<init>(initTimeMillis: Long, dispatchOnSubscribe: Boolean = true)

A custom clock whose frame time can be manually updated via mutating clockTimeMillis.

Public methods
Unit

Subscribes observer to this clock.

Inherited functions
Inherited extension functions
From androidx.ui.animation
DisposableAnimationClock

Return a new AnimationClockObservable wrapping this one that will auto-unsubscribe all AnimationClockObservers when this call leaves the composition, preventing clock subscriptions from persisting beyond the composition lifecycle.

Properties
Long

Clock time in milliseconds.

Boolean

Whether or not there are AnimationClockObservers observing this clock.

Public constructors

<init>

ManualAnimationClock(
    initTimeMillis: Long,
    dispatchOnSubscribe: Boolean = true)

A custom clock whose frame time can be manually updated via mutating clockTimeMillis. Observers will be called immediately with the current time when they are subscribed. Use dispatchOnSubscribe = false to wait for the next tick instead, which can be useful if the current time might be outdated.

Public methods

subscribe

fun subscribe(observer: AnimationClockObserver): Unit

Subscribes observer to this clock. Duplicate subscriptions will be ignored.

Properties

clockTimeMillis

var clockTimeMillis: Long

Clock time in milliseconds. When clockTimeMillis is updated, the ManualAnimationClock notifies all its observers (i.e. animations) the new clock time. The animations will consequently snap to the new play time.

hasObservers

val hasObservers: Boolean

Whether or not there are AnimationClockObservers observing this clock.