{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

AndroidUiFrameClock

public final class AndroidUiFrameClock implements MonotonicFrameClock


Summary

Public constructors

Public methods

final @NonNull Choreographer
@NonNull R
<R extends Object> withFrameNanos(
    @NonNull Function1<@NonNull Long, @NonNull R> onFrame
)

Suspends until a new frame is requested, immediately invokes onFrame with the frame time in nanoseconds in the calling context of frame dispatch, then resumes with the result from onFrame.

Inherited methods

From kotlin.coroutines.CoroutineContext
From kotlin.coroutines.CoroutineContext.Element
@NonNull R
<R extends Object> fold(
    @NonNull R initial,
    @NonNull Function2<@NonNull R, @NonNull CoroutineContext.Element, @NonNull R> operation
)
E
@NonNull CoroutineContext
From androidx.compose.runtime.MonotonicFrameClock

Public constructors

AndroidUiFrameClock

public AndroidUiFrameClock(@NonNull Choreographer choreographer)

Public methods

getChoreographer

public final @NonNull Choreographer getChoreographer()

withFrameNanos

public @NonNull R <R extends Object> withFrameNanos(
    @NonNull Function1<@NonNull Long, @NonNull R> onFrame
)

Suspends until a new frame is requested, immediately invokes onFrame with the frame time in nanoseconds in the calling context of frame dispatch, then resumes with the result from onFrame.

frameTimeNanos should be used when calculating animation time deltas from frame to frame as it may be normalized to the target time for the frame, not necessarily a direct, "now" value.

The time base of the value provided by withFrameNanos is implementation defined. Time values provided are strictly monotonically increasing; after a call to withFrameNanos completes it must not provide the same value again for a subsequent call.