TransitionSeekController


public 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 methods

abstract void

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

abstract void

Adds a listener to know when isReady is true.

abstract void

Runs the animation forwards toward the end.

abstract void
animateToStart(@NonNull Runnable resetToStartState)

Runs the animation backwards toward the start.

abstract @FloatRange(from = 0.0, to = 1.0) float
abstract @IntRange(from = 0) long
abstract @IntRange(from = 0) long
abstract boolean

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

abstract void

Remove a listener previously added in addOnProgressChangedListener

abstract void

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

abstract void
setCurrentFraction(@FloatRange(from = 0.0, to = 1.0) float fraction)

Sets the position of the Transition's animation.

abstract void
setCurrentPlayTimeMillis(@IntRange(from = 0) long playTimeMillis)

Sets the position of the Transition's animation.

Public methods

addOnProgressChangedListener

Added in 1.5.0
abstract void addOnProgressChangedListener(
    @NonNull Consumer<TransitionSeekController> consumer
)

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
@NonNull Consumer<TransitionSeekController> consumer

A method that accepts this TransitionSeekController.

addOnReadyListener

Added in 1.5.0
abstract void addOnReadyListener(
    @NonNull Consumer<TransitionSeekController> onReadyListener
)

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
@NonNull Consumer<TransitionSeekController> onReadyListener

The listener to be notified when the Transition is ready.

animateToEnd

Added in 1.5.0
abstract void animateToEnd()

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.0
abstract void animateToStart(@NonNull Runnable resetToStartState)

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.0
abstract @FloatRange(from = 0.0, to = 1.0) float getCurrentFraction()
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.0
abstract @IntRange(from = 0) long getCurrentPlayTimeMillis()
Returns
@IntRange(from = 0) long

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

getDurationMillis

Added in 1.5.0
abstract @IntRange(from = 0) long getDurationMillis()
Returns
@IntRange(from = 0) long

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

isReady

Added in 1.5.0
abstract boolean isReady()

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.0
abstract void removeOnProgressChangedListener(
    @NonNull Consumer<TransitionSeekController> consumer
)

Remove a listener previously added in addOnProgressChangedListener

Parameters
@NonNull Consumer<TransitionSeekController> consumer

The listener to be removed.

removeOnReadyListener

Added in 1.5.0
abstract void removeOnReadyListener(
    @NonNull Consumer<TransitionSeekController> onReadyListener
)

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

Parameters
@NonNull Consumer<TransitionSeekController> onReadyListener

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

setCurrentFraction

Added in 1.5.0
abstract void setCurrentFraction(@FloatRange(from = 0.0, to = 1.0) float fraction)

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
@FloatRange(from = 0.0, to = 1.0) float fraction

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

setCurrentPlayTimeMillis

Added in 1.5.0
abstract void setCurrentPlayTimeMillis(@IntRange(from = 0) long playTimeMillis)

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
@IntRange(from = 0) long playTimeMillis

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