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

AnimationStateKt

public final class AnimationStateKt


Summary

Public methods

static final @NonNull AnimationState<@NonNull Float, @NonNull AnimationVector1D>
AnimationState(
    float initialValue,
    float initialVelocity,
    long lastFrameTimeNanos,
    long finishedTimeNanos,
    boolean isRunning
)

Factory method for creating an AnimationState for Float initialValue.

static final @NonNull AnimationState<@NonNull T, @NonNull V>
<T extends Object, V extends AnimationVector> AnimationState(
    @NonNull TwoWayConverter<@NonNull T, @NonNull V> typeConverter,
    @NonNull T initialValue,
    @NonNull T initialVelocity,
    long lastFrameTimeNanos,
    long finishedTimeNanos,
    boolean isRunning
)

Factory method for creating an AnimationState with an initialValue and an initialVelocity.

static final @NonNull AnimationState<@NonNull Float, @NonNull AnimationVector1D>
copy(
    @NonNull AnimationState<@NonNull Float, @NonNull AnimationVector1D> receiver,
    float value,
    float velocity,
    long lastFrameTimeNanos,
    long finishedTimeNanos,
    boolean isRunning
)

Creates a new AnimationState of Float value type from a given AnimationState of the same type.

static final @NonNull AnimationState<@NonNull T, @NonNull V>
<T extends Object, V extends AnimationVector> copy(
    @NonNull AnimationState<@NonNull T, @NonNull V> receiver,
    @NonNull T value,
    V velocityVector,
    long lastFrameTimeNanos,
    long finishedTimeNanos,
    boolean isRunning
)

Creates a new AnimationState from a given AnimationState.

static final @NonNull V
<T extends Object, V extends AnimationVector> createZeroVectorFrom(
    @NonNull TwoWayConverter<@NonNull T, @NonNull V> receiver,
    @NonNull T value
)

Creates an AnimationVector with all the values set to 0 using the provided TwoWayConverter and the value.

static final boolean

Indicates whether the given AnimationState is for an animation that has finished, indicated by AnimationState.finishedTimeNanos having a specified value.

Public methods

AnimationState

public static final @NonNull AnimationState<@NonNull Float, @NonNull AnimationVector1DAnimationState(
    float initialValue,
    float initialVelocity,
    long lastFrameTimeNanos,
    long finishedTimeNanos,
    boolean isRunning
)

Factory method for creating an AnimationState for Float initialValue.

Parameters
float initialValue

initial value of the AnimationState

float initialVelocity

initial velocity of the AnimationState, 0 (i.e. no velocity) by default

long lastFrameTimeNanos

last frame time of the animation, AnimationConstants.UnspecifiedTime by default

long finishedTimeNanos

the time that the animation finished successfully, AnimationConstants.UnspecifiedTime by default.

boolean isRunning

whether the AnimationState is currently being updated by an animation. False by default

AnimationState

public static final @NonNull AnimationState<@NonNull T, @NonNull V> <T extends Object, V extends AnimationVector> AnimationState(
    @NonNull TwoWayConverter<@NonNull T, @NonNull V> typeConverter,
    @NonNull T initialValue,
    @NonNull T initialVelocity,
    long lastFrameTimeNanos,
    long finishedTimeNanos,
    boolean isRunning
)

Factory method for creating an AnimationState with an initialValue and an initialVelocity.

Parameters
@NonNull TwoWayConverter<@NonNull T, @NonNull V> typeConverter

TwoWayConverter to convert type T from and to AnimationVector

@NonNull T initialValue

initial value of the AnimationState

@NonNull T initialVelocity

initial velocity of the AnimationState

long lastFrameTimeNanos

last frame time of the animation, AnimationConstants.UnspecifiedTime by default

long finishedTimeNanos

the time that the animation finished successfully, AnimationConstants.UnspecifiedTime by default.

boolean isRunning

whether the AnimationState is currently being updated by an animation. False by default

Returns
@NonNull AnimationState<@NonNull T, @NonNull V>

A new AnimationState instance

copy

public static final @NonNull AnimationState<@NonNull Float, @NonNull AnimationVector1Dcopy(
    @NonNull AnimationState<@NonNull Float, @NonNull AnimationVector1D> receiver,
    float value,
    float velocity,
    long lastFrameTimeNanos,
    long finishedTimeNanos,
    boolean isRunning
)

Creates a new AnimationState of Float value type from a given AnimationState of the same type. This function allows some of the fields to be different in the new AnimationState.

Parameters
float value

value of the AnimationState, using the value of the given AnimationState by default

float velocity

velocity of the AnimationState, using the velocity of the given AnimationState by default.

long lastFrameTimeNanos

last frame time of the animation, same as the given AnimationState by default

long finishedTimeNanos

the time that the animation finished successfully, same as the given AnimationState by default.

boolean isRunning

whether the AnimationState is currently being updated by an animation. Same as the given AnimationState by default

Returns
@NonNull AnimationState<@NonNull Float, @NonNull AnimationVector1D>

A new AnimationState instance copied from the given instance, with some fields optionally altered

copy

public static final @NonNull AnimationState<@NonNull T, @NonNull V> <T extends Object, V extends AnimationVector> copy(
    @NonNull AnimationState<@NonNull T, @NonNull V> receiver,
    @NonNull T value,
    V velocityVector,
    long lastFrameTimeNanos,
    long finishedTimeNanos,
    boolean isRunning
)

Creates a new AnimationState from a given AnimationState. This function allows some of the fields to be different in the new AnimationState.

Parameters
@NonNull T value

value of the AnimationState, using the value of the given AnimationState by default

V velocityVector

velocity of the AnimationState, using the velocity of the given AnimationState by default.

long lastFrameTimeNanos

last frame time of the animation, same as the given AnimationState by default

long finishedTimeNanos

the time that the animation finished successfully, AnimationConstants.UnspecifiedTime until then. Default value is the same as the given AnimationState.

boolean isRunning

whether the AnimationState is currently being updated by an animation. Same as the given AnimationState by default

Returns
@NonNull AnimationState<@NonNull T, @NonNull V>

A new AnimationState instance copied from the given instance, with some fields optionally altered

createZeroVectorFrom

public static final @NonNull V <T extends Object, V extends AnimationVector> createZeroVectorFrom(
    @NonNull TwoWayConverter<@NonNull T, @NonNull V> receiver,
    @NonNull T value
)

Creates an AnimationVector with all the values set to 0 using the provided TwoWayConverter and the value.

Returns
@NonNull V

a new AnimationVector instance of type V.

isFinished

public static final boolean isFinished(@NonNull AnimationState<@NonNull ?, @NonNull ?> receiver)

Indicates whether the given AnimationState is for an animation that has finished, indicated by AnimationState.finishedTimeNanos having a specified value.