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

VectorizedDecayAnimationSpec

public interface VectorizedDecayAnimationSpec<V extends AnimationVector>


VectorizedDecayAnimationSpecs are stateless vector based decay animation specifications. They do not assume any starting/ending conditions. Nor do they manage a lifecycle. All it stores is the configuration that is particular to the type of the decay animation: friction multiplier for exponentialDecay. Its stateless nature allows the same VectorizedDecayAnimationSpec to be reused by a few different running animations with different starting and ending values.

Since VectorizedDecayAnimationSpecs are stateless, it requires starting value/velocity and ending value to be passed in, along with playtime, to calculate the value or velocity at that time. Play time here is the progress of the animation in terms of milliseconds, where 0 means the start of the animation and getDurationNanos returns the play time for the end of the animation.

Note: For use cases where the starting values/velocity and ending values aren't expected to change, it is recommended to use DecayAnimation that caches these static values and hence does not require them to be supplied in the value/velocity calculation.

See also
DecayAnimation

Summary

Public methods

abstract float

This is the absolute value of a velocity threshold, below which the animation is considered finished.

abstract long
getDurationNanos(@NonNull V initialValue, @NonNull V initialVelocity)

Returns the duration of the decay animation, in nanoseconds.

abstract @NonNull V
getTargetValue(@NonNull V initialValue, @NonNull V initialVelocity)

Returns the target value of the animation based on the initial condition of the animation ( i.e. initial value and initial velocity).

abstract @NonNull V
getValueFromNanos(
    long playTimeNanos,
    @NonNull V initialValue,
    @NonNull V initialVelocity
)

Returns the value of the animation at the given time.

abstract @NonNull V
getVelocityFromNanos(
    long playTimeNanos,
    @NonNull V initialValue,
    @NonNull V initialVelocity
)

Returns the velocity of the animation at the given time.

Public methods

getAbsVelocityThreshold

abstract float getAbsVelocityThreshold()

This is the absolute value of a velocity threshold, below which the animation is considered finished.

getDurationNanos

abstract long getDurationNanos(@NonNull V initialValue, @NonNull V initialVelocity)

Returns the duration of the decay animation, in nanoseconds.

Parameters
@NonNull V initialValue

initialValue value of the animation

@NonNull V initialVelocity

initialValue velocity of the animation

getTargetValue

abstract @NonNullgetTargetValue(@NonNull V initialValue, @NonNull V initialVelocity)

Returns the target value of the animation based on the initial condition of the animation ( i.e. initial value and initial velocity).

Parameters
@NonNull V initialValue

The initial value of the animation

@NonNull V initialVelocity

The initial velocity of the animation

getValueFromNanos

abstract @NonNullgetValueFromNanos(
    long playTimeNanos,
    @NonNull V initialValue,
    @NonNull V initialVelocity
)

Returns the value of the animation at the given time.

Parameters
long playTimeNanos

The time elapsed in milliseconds since the initialValue of the animation

@NonNull V initialValue

The initialValue value of the animation

@NonNull V initialVelocity

The initialValue velocity of the animation

getVelocityFromNanos

abstract @NonNullgetVelocityFromNanos(
    long playTimeNanos,
    @NonNull V initialValue,
    @NonNull V initialVelocity
)

Returns the velocity of the animation at the given time.

Parameters
long playTimeNanos

The time elapsed in milliseconds since the initialValue of the animation

@NonNull V initialValue

The initialValue value of the animation

@NonNull V initialVelocity

The initialValue velocity of the animation