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

TwoWayConverter

public interface TwoWayConverter<T extends Object, V extends AnimationVector>


TwoWayConverter class contains the definition on how to convert from an arbitrary type T to a AnimationVector, and convert the AnimationVector back to the type T. This allows animations to run on any type of objects, e.g. position, rectangle, color, etc.

Summary

Public methods

abstract @NonNull Function1<@NonNull V, @NonNull T>

Defines how to convert a Vector type (i.e. AnimationVector1D, AnimationVector2D, AnimationVector3D or AnimationVector4D, depends on the dimensions of type T) back to type T.

abstract @NonNull Function1<@NonNull T, @NonNull V>

Defines how a type T should be converted to a Vector type (i.e. AnimationVector1D, AnimationVector2D, AnimationVector3D or AnimationVector4D, depends on the dimensions of type T).

Extension functions

default final @NonNull V
<T extends Object, V extends AnimationVector> AnimationStateKt.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.

Public methods

getConvertFromVector

abstract @NonNull Function1<@NonNull V, @NonNull T> getConvertFromVector()

Defines how to convert a Vector type (i.e. AnimationVector1D, AnimationVector2D, AnimationVector3D or AnimationVector4D, depends on the dimensions of type T) back to type T.

getConvertToVector

abstract @NonNull Function1<@NonNull T, @NonNull V> getConvertToVector()

Defines how a type T should be converted to a Vector type (i.e. AnimationVector1D, AnimationVector2D, AnimationVector3D or AnimationVector4D, depends on the dimensions of type T).

Extension functions

AnimationStateKt.createZeroVectorFrom

default final @NonNull V <T extends Object, V extends AnimationVector> AnimationStateKt.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.