TransitionSeekController


interface TransitionSeekController


Returned from controlDelayedTransition to allow manually controlling the animations within a Transition using setCurrentPlayTimeMillis. The transition will be ready to seek when isReady is true.

Summary

Public functions

Unit

Add a listener for whenever the progress of the transition is changed.

Unit

Adds a listener to know when isReady is true.

Unit

Runs the animation forwards toward the end.

Unit
animateToStart(resetToStartState: Runnable)

Runs the animation backwards toward the start.

@FloatRange(from = 0.0, to = 1.0) Float
@IntRange(from = 0) Long
@IntRange(from = 0) Long
Boolean

Returns true when the Transition is ready to seek or false when the Transition's animations have yet to be built.

Unit

Remove a listener previously added in addOnProgressChangedListener

Unit

Removes onReadyListener that was previously added in addOnReadyListener so that it won't be called.

Unit
setCurrentFraction(fraction: @FloatRange(from = 0.0, to = 1.0) Float)

Sets the position of the Transition's animation.

Unit
setCurrentPlayTimeMillis(playTimeMillis: @IntRange(from = 0) Long)

Sets the position of the Transition's animation.

Public functions

addOnProgressChangedListener

Added in 1.5.1
fun addOnProgressChangedListener(
    consumer: Consumer<TransitionSeekController!>
): Unit

Add a listener for whenever the progress of the transition is changed. This will be called when setCurrentPlayTimeMillis or setCurrentFraction are called as well as when the animation from animateToEnd or animateToStart changes the progress.

Parameters
consumer: Consumer<TransitionSeekController!>

A method that accepts this TransitionSeekController.

addOnReadyListener

Added in 1.5.1
fun addOnReadyListener(onReadyListener: Consumer<TransitionSeekController!>): Unit

Adds a listener to know when isReady is true. The listener will be removed once notified as isReady can only be made true once. If isReady is already true, then it will be notified immediately.

Parameters
onReadyListener: Consumer<TransitionSeekController!>

The listener to be notified when the Transition is ready.

animateToEnd

Added in 1.5.1
fun animateToEnd(): Unit

Runs the animation forwards toward the end. setCurrentPlayTimeMillis will not be allowed after executing this. When the animation completes, onTransitionEnd will be called with the isReverse parameter false. After the Transition ends, the state will reach the final state set after controlDelayedTransition. After calling this, setCurrentPlayTimeMillis may not be called.

animateToStart

Added in 1.5.1
fun animateToStart(resetToStartState: Runnable): Unit

Runs the animation backwards toward the start. setCurrentPlayTimeMillis will not be allowed after executing this. When the animation completes, resetToStart will be executed to set the state back to the starting state and onTransitionEnd will be called with the isReverse parameter true. If resetToStartState does not properly set the state back to starting state, onTransitionEnd will still be called, but the UI will jump to the end state instead of the start state.

getCurrentFraction

Added in 1.5.1
fun getCurrentFraction(): @FloatRange(from = 0.0, to = 1.0) Float
Returns
@FloatRange(from = 0.0, to = 1.0) Float

The fraction, between 0 and 1, inclusive, of the progress of the transition.

getCurrentPlayTimeMillis

Added in 1.5.1
fun getCurrentPlayTimeMillis(): @IntRange(from = 0) Long
Returns
@IntRange(from = 0) Long

The time, in milliseconds, of the animation. This will be between 0 and getDurationMillis.

getDurationMillis

Added in 1.5.1
fun getDurationMillis(): @IntRange(from = 0) Long
Returns
@IntRange(from = 0) Long

The total duration, in milliseconds, of the Transition's animations.

isReady

Added in 1.5.1
fun isReady(): Boolean

Returns true when the Transition is ready to seek or false when the Transition's animations have yet to be built.

removeOnProgressChangedListener

Added in 1.5.1
fun removeOnProgressChangedListener(
    consumer: Consumer<TransitionSeekController!>
): Unit

Remove a listener previously added in addOnProgressChangedListener

Parameters
consumer: Consumer<TransitionSeekController!>

The listener to be removed.

removeOnReadyListener

Added in 1.5.1
fun removeOnReadyListener(
    onReadyListener: Consumer<TransitionSeekController!>
): Unit

Removes onReadyListener that was previously added in addOnReadyListener so that it won't be called.

Parameters
onReadyListener: Consumer<TransitionSeekController!>

The listener to be removed so that it won't be notified when ready.

setCurrentFraction

Added in 1.5.1
fun setCurrentFraction(fraction: @FloatRange(from = 0.0, to = 1.0) Float): Unit

Sets the position of the Transition's animation. fraction should be between 0 and 1, inclusive, where 0 indicates that the transition hasn't progressed and 1 indicates that the transition is completed. Calling this before isReady is true will do nothing.

Parameters
fraction: @FloatRange(from = 0.0, to = 1.0) Float

The fraction, between 0 and 1, inclusive, of the progress of the transition.

setCurrentPlayTimeMillis

Added in 1.5.1
fun setCurrentPlayTimeMillis(playTimeMillis: @IntRange(from = 0) Long): Unit

Sets the position of the Transition's animation. playTimeMillis should be between 0 and getDurationMillis. Calling this before isReady is true will do nothing.

Parameters
playTimeMillis: @IntRange(from = 0) Long

The time, between 0 and getDurationMillis that the animation should play.