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

RepeatableSpec

public final class RepeatableSpec<T extends Object> implements FiniteAnimationSpec


RepeatableSpec takes another DurationBasedAnimationSpec and plays it iterations times. For creating infinitely repeating animation spec, consider using InfiniteRepeatableSpec.

Note: When repeating in the RepeatMode.Reverse mode, it's highly recommended to have an odd number of iterations. Otherwise, the animation may jump to the end value when it finishes the last iteration.

initialStartOffset can be used to either delay the start of the animation or to fast forward the animation to a given play time. This start offset will not be repeated, whereas the delay in the animation (if any) will be repeated. By default, the amount of offset is 0.

See also
repeatable
InfiniteRepeatableSpec
infiniteRepeatable

Summary

Public constructors

<T extends Object> RepeatableSpec(
    int iterations,
    @NonNull DurationBasedAnimationSpec<@NonNull T> animation,
    @NonNull RepeatMode repeatMode,
    @NonNull StartOffset initialStartOffset
)

Public methods

boolean
equals(Object other)
final @NonNull DurationBasedAnimationSpec<@NonNull T>

the AnimationSpec to be repeated

final @NonNull StartOffset

offsets the start of the animation

final int

the count of iterations.

final @NonNull RepeatMode

whether animation should repeat by starting from the beginning (i.e. RepeatMode.Restart) or from the end (i.e. RepeatMode.Reverse)

int
@NonNull VectorizedFiniteAnimationSpec<@NonNull V>
<V extends AnimationVector> vectorize(
    @NonNull TwoWayConverter<@NonNull T, @NonNull V> converter
)

Creates a VectorizedAnimationSpec with the given TwoWayConverter.

Public constructors

RepeatableSpec

public <T extends Object> RepeatableSpec(
    int iterations,
    @NonNull DurationBasedAnimationSpec<@NonNull T> animation,
    @NonNull RepeatMode repeatMode,
    @NonNull StartOffset initialStartOffset
)
Parameters
int iterations

the count of iterations. Should be at least 1.

@NonNull DurationBasedAnimationSpec<@NonNull T> animation

the AnimationSpec to be repeated

@NonNull RepeatMode repeatMode

whether animation should repeat by starting from the beginning (i.e. RepeatMode.Restart) or from the end (i.e. RepeatMode.Reverse)

@NonNull StartOffset initialStartOffset

offsets the start of the animation

Public methods

equals

public boolean equals(Object other)

getAnimation

public final @NonNull DurationBasedAnimationSpec<@NonNull T> getAnimation()

the AnimationSpec to be repeated

getInitialStartOffset

public final @NonNull StartOffset getInitialStartOffset()

offsets the start of the animation

getIterations

public final int getIterations()

the count of iterations. Should be at least 1.

getRepeatMode

public final @NonNull RepeatMode getRepeatMode()

whether animation should repeat by starting from the beginning (i.e. RepeatMode.Restart) or from the end (i.e. RepeatMode.Reverse)

hashCode

public int hashCode()

vectorize

public @NonNull VectorizedFiniteAnimationSpec<@NonNull V> <V extends AnimationVector> vectorize(
    @NonNull TwoWayConverter<@NonNull T, @NonNull V> converter
)

Creates a VectorizedAnimationSpec with the given TwoWayConverter.

The underlying animation system operates on AnimationVectors. T will be converted to AnimationVector to animate. VectorizedAnimationSpec describes how the converted AnimationVector should be animated. E.g. The animation could simply interpolate between the start and end values (i.e.TweenSpec), or apply spring physics to produce the motion (i.e. SpringSpec), etc)

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

converts the type T from and to AnimationVector type