Create AnimatedVectorValue class for animating vectors
Also separated type converter out from ValueHolder, to minimize the
cognitive load around ValueHolder interface, and to allow converters
to be customized separately.
Test: included in the CL
Change-Id: I4bf258c832f33c94ca0179b7b00f786eead48f70
diff --git a/ui/ui-animation-core/api/0.1.0-dev04.txt b/ui/ui-animation-core/api/0.1.0-dev04.txt
index 32f2886..e1b1920 100644
--- a/ui/ui-animation-core/api/0.1.0-dev04.txt
+++ b/ui/ui-animation-core/api/0.1.0-dev04.txt
@@ -2,7 +2,8 @@
package androidx.animation {
public final class AnimatedFloat extends androidx.animation.BaseAnimatedValue<java.lang.Float,androidx.animation.AnimationVector1D> {
- ctor public AnimatedFloat(androidx.animation.FloatValueHolder valueHolder);
+ ctor public AnimatedFloat(androidx.animation.ValueHolder<java.lang.Float> valueHolder);
+ ctor public AnimatedFloat(float initVal);
method public void doAnimationFrame$lintWithKotlin(long time);
method public float getVelocity();
method public void setBounds(float min = Float.NEGATIVE_INFINITY, float max = Float.POSITIVE_INFINITY);
@@ -11,7 +12,7 @@
}
public final class AnimatedValue<T, V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<T,V> {
- ctor public AnimatedValue(androidx.animation.ValueHolder<T,V> valueHolder);
+ ctor public AnimatedValue(androidx.animation.ValueHolder<T> valueHolder, androidx.animation.TwoWayConverter<T,V> typeConverter);
method public V getVelocity();
property public final V velocity;
}
@@ -21,6 +22,11 @@
method public static void fling(androidx.animation.AnimatedFloat, float startVelocity, androidx.animation.DecayAnimation decay = androidx.animation.ExponentialDecay(), kotlin.jvm.functions.Function1<? super java.lang.Float,androidx.animation.TargetAnimation> adjustTarget, kotlin.jvm.functions.Function3<? super androidx.animation.AnimationEndReason,? super java.lang.Float,? super java.lang.Float,kotlin.Unit>? >
}
+ public final class AnimatedVectorValue<V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<V,V> {
+ ctor public AnimatedVectorValue(androidx.animation.ValueHolder<V> valueHolder);
+ ctor public AnimatedVectorValue(V initVal);
+ }
+
public abstract class AnimationBuilder<T> {
ctor public AnimationBuilder();
}
@@ -88,6 +94,9 @@
property public final float v4;
}
+ public final class AnimationVectorsKt {
+ }
+
public abstract sealed class BaseAnimatedValue<T, V extends androidx.animation.AnimationVector> {
method public final void animateTo(T? targetValue);
method public final void animateTo(T? targetValue, kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit> onEnd);
@@ -165,11 +174,6 @@
property public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
}
- public interface FloatValueHolder extends androidx.animation.ValueHolder<java.lang.Float,androidx.animation.AnimationVector1D> {
- method public default androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getTypeConverter();
- property public default androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
- }
-
public final class IntPropKey implements androidx.animation.PropKey<java.lang.Integer,androidx.animation.AnimationVector1D> {
ctor public IntPropKey();
method public androidx.animation.TwoWayConverter<java.lang.Integer,androidx.animation.AnimationVector1D> getTypeConverter();
@@ -363,22 +367,14 @@
property public androidx.animation.Arithmetic<androidx.animation.AnimationVector4D> arithmetic;
}
- public interface ValueHolder<T, V extends androidx.animation.AnimationVector> {
- method public androidx.animation.TwoWayConverter<T,V> getTypeConverter();
+ public interface ValueHolder<T> {
method public T! getValue();
method public void setValue(T! p);
- property public abstract androidx.animation.TwoWayConverter<T,V> typeConverter;
property public abstract T! value;
}
- public final class ValueHolderImpl<T, V extends androidx.animation.AnimationVector> implements androidx.animation.ValueHolder<T,V> {
- ctor public ValueHolderImpl(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter);
- method public T! component1();
- method public androidx.animation.TwoWayConverter<T,V> component2();
- method public androidx.animation.ValueHolderImpl<T,V> copy(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter);
- method public androidx.animation.TwoWayConverter<T,V> getTypeConverter();
- method public T! getValue();
- method public void setValue(T? p);
+ public final class ValueHolderKt {
+ method public static <T> androidx.animation.ValueHolder<T> ValueHolder(T? initValue);
}
public final class VectorAnimationKt {
diff --git a/ui/ui-animation-core/api/current.txt b/ui/ui-animation-core/api/current.txt
index 32f2886..e1b1920 100644
--- a/ui/ui-animation-core/api/current.txt
+++ b/ui/ui-animation-core/api/current.txt
@@ -2,7 +2,8 @@
package androidx.animation {
public final class AnimatedFloat extends androidx.animation.BaseAnimatedValue<java.lang.Float,androidx.animation.AnimationVector1D> {
- ctor public AnimatedFloat(androidx.animation.FloatValueHolder valueHolder);
+ ctor public AnimatedFloat(androidx.animation.ValueHolder<java.lang.Float> valueHolder);
+ ctor public AnimatedFloat(float initVal);
method public void doAnimationFrame$lintWithKotlin(long time);
method public float getVelocity();
method public void setBounds(float min = Float.NEGATIVE_INFINITY, float max = Float.POSITIVE_INFINITY);
@@ -11,7 +12,7 @@
}
public final class AnimatedValue<T, V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<T,V> {
- ctor public AnimatedValue(androidx.animation.ValueHolder<T,V> valueHolder);
+ ctor public AnimatedValue(androidx.animation.ValueHolder<T> valueHolder, androidx.animation.TwoWayConverter<T,V> typeConverter);
method public V getVelocity();
property public final V velocity;
}
@@ -21,6 +22,11 @@
method public static void fling(androidx.animation.AnimatedFloat, float startVelocity, androidx.animation.DecayAnimation decay = androidx.animation.ExponentialDecay(), kotlin.jvm.functions.Function1<? super java.lang.Float,androidx.animation.TargetAnimation> adjustTarget, kotlin.jvm.functions.Function3<? super androidx.animation.AnimationEndReason,? super java.lang.Float,? super java.lang.Float,kotlin.Unit>? >
}
+ public final class AnimatedVectorValue<V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<V,V> {
+ ctor public AnimatedVectorValue(androidx.animation.ValueHolder<V> valueHolder);
+ ctor public AnimatedVectorValue(V initVal);
+ }
+
public abstract class AnimationBuilder<T> {
ctor public AnimationBuilder();
}
@@ -88,6 +94,9 @@
property public final float v4;
}
+ public final class AnimationVectorsKt {
+ }
+
public abstract sealed class BaseAnimatedValue<T, V extends androidx.animation.AnimationVector> {
method public final void animateTo(T? targetValue);
method public final void animateTo(T? targetValue, kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit> onEnd);
@@ -165,11 +174,6 @@
property public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
}
- public interface FloatValueHolder extends androidx.animation.ValueHolder<java.lang.Float,androidx.animation.AnimationVector1D> {
- method public default androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getTypeConverter();
- property public default androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
- }
-
public final class IntPropKey implements androidx.animation.PropKey<java.lang.Integer,androidx.animation.AnimationVector1D> {
ctor public IntPropKey();
method public androidx.animation.TwoWayConverter<java.lang.Integer,androidx.animation.AnimationVector1D> getTypeConverter();
@@ -363,22 +367,14 @@
property public androidx.animation.Arithmetic<androidx.animation.AnimationVector4D> arithmetic;
}
- public interface ValueHolder<T, V extends androidx.animation.AnimationVector> {
- method public androidx.animation.TwoWayConverter<T,V> getTypeConverter();
+ public interface ValueHolder<T> {
method public T! getValue();
method public void setValue(T! p);
- property public abstract androidx.animation.TwoWayConverter<T,V> typeConverter;
property public abstract T! value;
}
- public final class ValueHolderImpl<T, V extends androidx.animation.AnimationVector> implements androidx.animation.ValueHolder<T,V> {
- ctor public ValueHolderImpl(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter);
- method public T! component1();
- method public androidx.animation.TwoWayConverter<T,V> component2();
- method public androidx.animation.ValueHolderImpl<T,V> copy(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter);
- method public androidx.animation.TwoWayConverter<T,V> getTypeConverter();
- method public T! getValue();
- method public void setValue(T? p);
+ public final class ValueHolderKt {
+ method public static <T> androidx.animation.ValueHolder<T> ValueHolder(T? initValue);
}
public final class VectorAnimationKt {
diff --git a/ui/ui-animation-core/api/public_plus_experimental_0.1.0-dev04.txt b/ui/ui-animation-core/api/public_plus_experimental_0.1.0-dev04.txt
index 32f2886..e1b1920 100644
--- a/ui/ui-animation-core/api/public_plus_experimental_0.1.0-dev04.txt
+++ b/ui/ui-animation-core/api/public_plus_experimental_0.1.0-dev04.txt
@@ -2,7 +2,8 @@
package androidx.animation {
public final class AnimatedFloat extends androidx.animation.BaseAnimatedValue<java.lang.Float,androidx.animation.AnimationVector1D> {
- ctor public AnimatedFloat(androidx.animation.FloatValueHolder valueHolder);
+ ctor public AnimatedFloat(androidx.animation.ValueHolder<java.lang.Float> valueHolder);
+ ctor public AnimatedFloat(float initVal);
method public void doAnimationFrame$lintWithKotlin(long time);
method public float getVelocity();
method public void setBounds(float min = Float.NEGATIVE_INFINITY, float max = Float.POSITIVE_INFINITY);
@@ -11,7 +12,7 @@
}
public final class AnimatedValue<T, V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<T,V> {
- ctor public AnimatedValue(androidx.animation.ValueHolder<T,V> valueHolder);
+ ctor public AnimatedValue(androidx.animation.ValueHolder<T> valueHolder, androidx.animation.TwoWayConverter<T,V> typeConverter);
method public V getVelocity();
property public final V velocity;
}
@@ -21,6 +22,11 @@
method public static void fling(androidx.animation.AnimatedFloat, float startVelocity, androidx.animation.DecayAnimation decay = androidx.animation.ExponentialDecay(), kotlin.jvm.functions.Function1<? super java.lang.Float,androidx.animation.TargetAnimation> adjustTarget, kotlin.jvm.functions.Function3<? super androidx.animation.AnimationEndReason,? super java.lang.Float,? super java.lang.Float,kotlin.Unit>? >
}
+ public final class AnimatedVectorValue<V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<V,V> {
+ ctor public AnimatedVectorValue(androidx.animation.ValueHolder<V> valueHolder);
+ ctor public AnimatedVectorValue(V initVal);
+ }
+
public abstract class AnimationBuilder<T> {
ctor public AnimationBuilder();
}
@@ -88,6 +94,9 @@
property public final float v4;
}
+ public final class AnimationVectorsKt {
+ }
+
public abstract sealed class BaseAnimatedValue<T, V extends androidx.animation.AnimationVector> {
method public final void animateTo(T? targetValue);
method public final void animateTo(T? targetValue, kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit> onEnd);
@@ -165,11 +174,6 @@
property public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
}
- public interface FloatValueHolder extends androidx.animation.ValueHolder<java.lang.Float,androidx.animation.AnimationVector1D> {
- method public default androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getTypeConverter();
- property public default androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
- }
-
public final class IntPropKey implements androidx.animation.PropKey<java.lang.Integer,androidx.animation.AnimationVector1D> {
ctor public IntPropKey();
method public androidx.animation.TwoWayConverter<java.lang.Integer,androidx.animation.AnimationVector1D> getTypeConverter();
@@ -363,22 +367,14 @@
property public androidx.animation.Arithmetic<androidx.animation.AnimationVector4D> arithmetic;
}
- public interface ValueHolder<T, V extends androidx.animation.AnimationVector> {
- method public androidx.animation.TwoWayConverter<T,V> getTypeConverter();
+ public interface ValueHolder<T> {
method public T! getValue();
method public void setValue(T! p);
- property public abstract androidx.animation.TwoWayConverter<T,V> typeConverter;
property public abstract T! value;
}
- public final class ValueHolderImpl<T, V extends androidx.animation.AnimationVector> implements androidx.animation.ValueHolder<T,V> {
- ctor public ValueHolderImpl(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter);
- method public T! component1();
- method public androidx.animation.TwoWayConverter<T,V> component2();
- method public androidx.animation.ValueHolderImpl<T,V> copy(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter);
- method public androidx.animation.TwoWayConverter<T,V> getTypeConverter();
- method public T! getValue();
- method public void setValue(T? p);
+ public final class ValueHolderKt {
+ method public static <T> androidx.animation.ValueHolder<T> ValueHolder(T? initValue);
}
public final class VectorAnimationKt {
diff --git a/ui/ui-animation-core/api/public_plus_experimental_current.txt b/ui/ui-animation-core/api/public_plus_experimental_current.txt
index 32f2886..e1b1920 100644
--- a/ui/ui-animation-core/api/public_plus_experimental_current.txt
+++ b/ui/ui-animation-core/api/public_plus_experimental_current.txt
@@ -2,7 +2,8 @@
package androidx.animation {
public final class AnimatedFloat extends androidx.animation.BaseAnimatedValue<java.lang.Float,androidx.animation.AnimationVector1D> {
- ctor public AnimatedFloat(androidx.animation.FloatValueHolder valueHolder);
+ ctor public AnimatedFloat(androidx.animation.ValueHolder<java.lang.Float> valueHolder);
+ ctor public AnimatedFloat(float initVal);
method public void doAnimationFrame$lintWithKotlin(long time);
method public float getVelocity();
method public void setBounds(float min = Float.NEGATIVE_INFINITY, float max = Float.POSITIVE_INFINITY);
@@ -11,7 +12,7 @@
}
public final class AnimatedValue<T, V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<T,V> {
- ctor public AnimatedValue(androidx.animation.ValueHolder<T,V> valueHolder);
+ ctor public AnimatedValue(androidx.animation.ValueHolder<T> valueHolder, androidx.animation.TwoWayConverter<T,V> typeConverter);
method public V getVelocity();
property public final V velocity;
}
@@ -21,6 +22,11 @@
method public static void fling(androidx.animation.AnimatedFloat, float startVelocity, androidx.animation.DecayAnimation decay = androidx.animation.ExponentialDecay(), kotlin.jvm.functions.Function1<? super java.lang.Float,androidx.animation.TargetAnimation> adjustTarget, kotlin.jvm.functions.Function3<? super androidx.animation.AnimationEndReason,? super java.lang.Float,? super java.lang.Float,kotlin.Unit>? >
}
+ public final class AnimatedVectorValue<V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<V,V> {
+ ctor public AnimatedVectorValue(androidx.animation.ValueHolder<V> valueHolder);
+ ctor public AnimatedVectorValue(V initVal);
+ }
+
public abstract class AnimationBuilder<T> {
ctor public AnimationBuilder();
}
@@ -88,6 +94,9 @@
property public final float v4;
}
+ public final class AnimationVectorsKt {
+ }
+
public abstract sealed class BaseAnimatedValue<T, V extends androidx.animation.AnimationVector> {
method public final void animateTo(T? targetValue);
method public final void animateTo(T? targetValue, kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit> onEnd);
@@ -165,11 +174,6 @@
property public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
}
- public interface FloatValueHolder extends androidx.animation.ValueHolder<java.lang.Float,androidx.animation.AnimationVector1D> {
- method public default androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getTypeConverter();
- property public default androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
- }
-
public final class IntPropKey implements androidx.animation.PropKey<java.lang.Integer,androidx.animation.AnimationVector1D> {
ctor public IntPropKey();
method public androidx.animation.TwoWayConverter<java.lang.Integer,androidx.animation.AnimationVector1D> getTypeConverter();
@@ -363,22 +367,14 @@
property public androidx.animation.Arithmetic<androidx.animation.AnimationVector4D> arithmetic;
}
- public interface ValueHolder<T, V extends androidx.animation.AnimationVector> {
- method public androidx.animation.TwoWayConverter<T,V> getTypeConverter();
+ public interface ValueHolder<T> {
method public T! getValue();
method public void setValue(T! p);
- property public abstract androidx.animation.TwoWayConverter<T,V> typeConverter;
property public abstract T! value;
}
- public final class ValueHolderImpl<T, V extends androidx.animation.AnimationVector> implements androidx.animation.ValueHolder<T,V> {
- ctor public ValueHolderImpl(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter);
- method public T! component1();
- method public androidx.animation.TwoWayConverter<T,V> component2();
- method public androidx.animation.ValueHolderImpl<T,V> copy(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter);
- method public androidx.animation.TwoWayConverter<T,V> getTypeConverter();
- method public T! getValue();
- method public void setValue(T? p);
+ public final class ValueHolderKt {
+ method public static <T> androidx.animation.ValueHolder<T> ValueHolder(T? initValue);
}
public final class VectorAnimationKt {
diff --git a/ui/ui-animation-core/api/restricted_0.1.0-dev04.txt b/ui/ui-animation-core/api/restricted_0.1.0-dev04.txt
index 32f2886..e1b1920 100644
--- a/ui/ui-animation-core/api/restricted_0.1.0-dev04.txt
+++ b/ui/ui-animation-core/api/restricted_0.1.0-dev04.txt
@@ -2,7 +2,8 @@
package androidx.animation {
public final class AnimatedFloat extends androidx.animation.BaseAnimatedValue<java.lang.Float,androidx.animation.AnimationVector1D> {
- ctor public AnimatedFloat(androidx.animation.FloatValueHolder valueHolder);
+ ctor public AnimatedFloat(androidx.animation.ValueHolder<java.lang.Float> valueHolder);
+ ctor public AnimatedFloat(float initVal);
method public void doAnimationFrame$lintWithKotlin(long time);
method public float getVelocity();
method public void setBounds(float min = Float.NEGATIVE_INFINITY, float max = Float.POSITIVE_INFINITY);
@@ -11,7 +12,7 @@
}
public final class AnimatedValue<T, V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<T,V> {
- ctor public AnimatedValue(androidx.animation.ValueHolder<T,V> valueHolder);
+ ctor public AnimatedValue(androidx.animation.ValueHolder<T> valueHolder, androidx.animation.TwoWayConverter<T,V> typeConverter);
method public V getVelocity();
property public final V velocity;
}
@@ -21,6 +22,11 @@
method public static void fling(androidx.animation.AnimatedFloat, float startVelocity, androidx.animation.DecayAnimation decay = androidx.animation.ExponentialDecay(), kotlin.jvm.functions.Function1<? super java.lang.Float,androidx.animation.TargetAnimation> adjustTarget, kotlin.jvm.functions.Function3<? super androidx.animation.AnimationEndReason,? super java.lang.Float,? super java.lang.Float,kotlin.Unit>? >
}
+ public final class AnimatedVectorValue<V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<V,V> {
+ ctor public AnimatedVectorValue(androidx.animation.ValueHolder<V> valueHolder);
+ ctor public AnimatedVectorValue(V initVal);
+ }
+
public abstract class AnimationBuilder<T> {
ctor public AnimationBuilder();
}
@@ -88,6 +94,9 @@
property public final float v4;
}
+ public final class AnimationVectorsKt {
+ }
+
public abstract sealed class BaseAnimatedValue<T, V extends androidx.animation.AnimationVector> {
method public final void animateTo(T? targetValue);
method public final void animateTo(T? targetValue, kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit> onEnd);
@@ -165,11 +174,6 @@
property public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
}
- public interface FloatValueHolder extends androidx.animation.ValueHolder<java.lang.Float,androidx.animation.AnimationVector1D> {
- method public default androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getTypeConverter();
- property public default androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
- }
-
public final class IntPropKey implements androidx.animation.PropKey<java.lang.Integer,androidx.animation.AnimationVector1D> {
ctor public IntPropKey();
method public androidx.animation.TwoWayConverter<java.lang.Integer,androidx.animation.AnimationVector1D> getTypeConverter();
@@ -363,22 +367,14 @@
property public androidx.animation.Arithmetic<androidx.animation.AnimationVector4D> arithmetic;
}
- public interface ValueHolder<T, V extends androidx.animation.AnimationVector> {
- method public androidx.animation.TwoWayConverter<T,V> getTypeConverter();
+ public interface ValueHolder<T> {
method public T! getValue();
method public void setValue(T! p);
- property public abstract androidx.animation.TwoWayConverter<T,V> typeConverter;
property public abstract T! value;
}
- public final class ValueHolderImpl<T, V extends androidx.animation.AnimationVector> implements androidx.animation.ValueHolder<T,V> {
- ctor public ValueHolderImpl(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter);
- method public T! component1();
- method public androidx.animation.TwoWayConverter<T,V> component2();
- method public androidx.animation.ValueHolderImpl<T,V> copy(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter);
- method public androidx.animation.TwoWayConverter<T,V> getTypeConverter();
- method public T! getValue();
- method public void setValue(T? p);
+ public final class ValueHolderKt {
+ method public static <T> androidx.animation.ValueHolder<T> ValueHolder(T? initValue);
}
public final class VectorAnimationKt {
diff --git a/ui/ui-animation-core/api/restricted_current.txt b/ui/ui-animation-core/api/restricted_current.txt
index 32f2886..e1b1920 100644
--- a/ui/ui-animation-core/api/restricted_current.txt
+++ b/ui/ui-animation-core/api/restricted_current.txt
@@ -2,7 +2,8 @@
package androidx.animation {
public final class AnimatedFloat extends androidx.animation.BaseAnimatedValue<java.lang.Float,androidx.animation.AnimationVector1D> {
- ctor public AnimatedFloat(androidx.animation.FloatValueHolder valueHolder);
+ ctor public AnimatedFloat(androidx.animation.ValueHolder<java.lang.Float> valueHolder);
+ ctor public AnimatedFloat(float initVal);
method public void doAnimationFrame$lintWithKotlin(long time);
method public float getVelocity();
method public void setBounds(float min = Float.NEGATIVE_INFINITY, float max = Float.POSITIVE_INFINITY);
@@ -11,7 +12,7 @@
}
public final class AnimatedValue<T, V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<T,V> {
- ctor public AnimatedValue(androidx.animation.ValueHolder<T,V> valueHolder);
+ ctor public AnimatedValue(androidx.animation.ValueHolder<T> valueHolder, androidx.animation.TwoWayConverter<T,V> typeConverter);
method public V getVelocity();
property public final V velocity;
}
@@ -21,6 +22,11 @@
method public static void fling(androidx.animation.AnimatedFloat, float startVelocity, androidx.animation.DecayAnimation decay = androidx.animation.ExponentialDecay(), kotlin.jvm.functions.Function1<? super java.lang.Float,androidx.animation.TargetAnimation> adjustTarget, kotlin.jvm.functions.Function3<? super androidx.animation.AnimationEndReason,? super java.lang.Float,? super java.lang.Float,kotlin.Unit>? >
}
+ public final class AnimatedVectorValue<V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<V,V> {
+ ctor public AnimatedVectorValue(androidx.animation.ValueHolder<V> valueHolder);
+ ctor public AnimatedVectorValue(V initVal);
+ }
+
public abstract class AnimationBuilder<T> {
ctor public AnimationBuilder();
}
@@ -88,6 +94,9 @@
property public final float v4;
}
+ public final class AnimationVectorsKt {
+ }
+
public abstract sealed class BaseAnimatedValue<T, V extends androidx.animation.AnimationVector> {
method public final void animateTo(T? targetValue);
method public final void animateTo(T? targetValue, kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit> onEnd);
@@ -165,11 +174,6 @@
property public androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
}
- public interface FloatValueHolder extends androidx.animation.ValueHolder<java.lang.Float,androidx.animation.AnimationVector1D> {
- method public default androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> getTypeConverter();
- property public default androidx.animation.TwoWayConverter<java.lang.Float,androidx.animation.AnimationVector1D> typeConverter;
- }
-
public final class IntPropKey implements androidx.animation.PropKey<java.lang.Integer,androidx.animation.AnimationVector1D> {
ctor public IntPropKey();
method public androidx.animation.TwoWayConverter<java.lang.Integer,androidx.animation.AnimationVector1D> getTypeConverter();
@@ -363,22 +367,14 @@
property public androidx.animation.Arithmetic<androidx.animation.AnimationVector4D> arithmetic;
}
- public interface ValueHolder<T, V extends androidx.animation.AnimationVector> {
- method public androidx.animation.TwoWayConverter<T,V> getTypeConverter();
+ public interface ValueHolder<T> {
method public T! getValue();
method public void setValue(T! p);
- property public abstract androidx.animation.TwoWayConverter<T,V> typeConverter;
property public abstract T! value;
}
- public final class ValueHolderImpl<T, V extends androidx.animation.AnimationVector> implements androidx.animation.ValueHolder<T,V> {
- ctor public ValueHolderImpl(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter);
- method public T! component1();
- method public androidx.animation.TwoWayConverter<T,V> component2();
- method public androidx.animation.ValueHolderImpl<T,V> copy(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter);
- method public androidx.animation.TwoWayConverter<T,V> getTypeConverter();
- method public T! getValue();
- method public void setValue(T? p);
+ public final class ValueHolderKt {
+ method public static <T> androidx.animation.ValueHolder<T> ValueHolder(T? initValue);
}
public final class VectorAnimationKt {
diff --git a/ui/ui-animation-core/src/main/java/androidx/animation/AnimatedValue.kt b/ui/ui-animation-core/src/main/java/androidx/animation/AnimatedValue.kt
index bdcd71e..d5a1f17 100644
--- a/ui/ui-animation-core/src/main/java/androidx/animation/AnimatedValue.kt
+++ b/ui/ui-animation-core/src/main/java/androidx/animation/AnimatedValue.kt
@@ -22,11 +22,6 @@
import androidx.animation.AnimationEndReason.Interrupted
import androidx.animation.AnimationEndReason.TargetReached
-typealias AnimatedValue1D<T> = AnimatedValue<T, AnimationVector1D>
-typealias AnimatedValue2D<T> = AnimatedValue<T, AnimationVector2D>
-typealias AnimatedValue3D<T> = AnimatedValue<T, AnimationVector3D>
-typealias AnimatedValue4D<T> = AnimatedValue<T, AnimationVector4D>
-
/**
* This is the base class for [AnimatedValue]. It contains all the functionality of AnimatedValue.
* It is intended to be used as a base class for the other classes (such as [AnimatedFloat] to build
@@ -38,8 +33,14 @@
*
* @param valueHolder A value holder whose value gets updated by [BaseAnimatedValue] on every
* animation frame.
+ * @param typeConverter A two way type converter that converts from value to [AnimationVector1D],
+ * [AnimationVector2D], [AnimationVector3D], or [AnimationVector4D], and vice
+ * versa.
*/
-sealed class BaseAnimatedValue<T, V : AnimationVector>(private val valueHolder: ValueHolder<T, V>) {
+sealed class BaseAnimatedValue<T, V : AnimationVector>(
+ private val valueHolder: ValueHolder<T>,
+ typeConverter: TwoWayConverter<T, V>
+) {
/**
* Creates a [BaseAnimatedValue] instance that starts at the given value, and uses the given
@@ -50,7 +51,7 @@
constructor(
initVal: T,
typeConverter: TwoWayConverter<T, V>
- ) : this(ValueHolderImpl(initVal, typeConverter))
+ ) : this(ValueHolder(initVal), typeConverter)
/**
* Current value of the animation.
@@ -78,9 +79,9 @@
* Velocity of the animation. The velocity will be of [AnimationVector1D], [AnimationVector2D],
* [AnimationVector3D], or [AnimationVector4D] type.
*/
- internal var velocityVector: V = valueHolder.typeConverter.createNewVector()
+ internal var velocityVector: V = typeConverter.createNewVector()
- internal val typeConverter: TwoWayConverter<T, V> = valueHolder.typeConverter
+ internal val typeConverter: TwoWayConverter<T, V> = typeConverter
internal var onEnd: ((AnimationEndReason, T) -> Unit)? = null
private lateinit var anim: AnimationWrapper<T, V>
private var startTime: Long = Unset
@@ -286,12 +287,20 @@
* @param valueHolder A value holder whose value field will be updated during animations
*/
class AnimatedValue<T, V : AnimationVector>(
- valueHolder: ValueHolder<T, V>
-) : BaseAnimatedValue<T, V>(valueHolder) {
+ valueHolder: ValueHolder<T>,
+ typeConverter: TwoWayConverter<T, V>
+) : BaseAnimatedValue<T, V>(valueHolder, typeConverter) {
val velocity: V
get() = velocityVector
}
+// TODO class description
+class AnimatedVectorValue<V : AnimationVector>(
+ valueHolder: ValueHolder<V>
+) : BaseAnimatedValue<V, V>(valueHolder, valueHolder.value.createPassThroughConverter()) {
+ constructor(initVal: V) : this(ValueHolder(initVal))
+}
+
/**
* This class inherits most of the functionality from BaseAnimatedValue. In addition, it tracks
* velocity and supports the definition of bounds. Once bounds are defined using [setBounds], the
@@ -302,8 +311,9 @@
* animations
*/
class AnimatedFloat(
- valueHolder: FloatValueHolder
-) : BaseAnimatedValue<Float, AnimationVector1D>(valueHolder) {
+ valueHolder: ValueHolder<Float>
+) : BaseAnimatedValue<Float, AnimationVector1D>(valueHolder, FloatToVectorConverter) {
+ constructor(initVal: Float) : this(ValueHolder(initVal))
private var min: Float = Float.NEGATIVE_INFINITY
private var max: Float = Float.POSITIVE_INFINITY
diff --git a/ui/ui-animation-core/src/main/java/androidx/animation/AnimationVectors.kt b/ui/ui-animation-core/src/main/java/androidx/animation/AnimationVectors.kt
index cde934f..923512a 100644
--- a/ui/ui-animation-core/src/main/java/androidx/animation/AnimationVectors.kt
+++ b/ui/ui-animation-core/src/main/java/androidx/animation/AnimationVectors.kt
@@ -18,7 +18,7 @@
/**
* [AnimationVector] class that is the base class of [AnimationVector1D], [AnimationVector2D],
- * [AnimationVector3D] and [AnimationVector3D]. In order to animate any arbitrary type, it is
+ * [AnimationVector3D] and [AnimationVector4D]. In order to animate any arbitrary type, it is
* required to provide a [TwoWayConverter] that defines how to convert that arbitrary type T to an
* [AnimationVector], and vice versa. Depending on how many dimensions this type T has, it may need
* to be converted to any of the subclasses of [AnimationVector]. For example, a position based
@@ -29,6 +29,23 @@
internal abstract fun reset()
}
+internal fun <T : AnimationVector> T.createPassThroughConverter(): TwoWayConverter<T, T> {
+ val converter = when (this) {
+ is AnimationVector1D -> passThroughConverter1D
+ is AnimationVector2D -> passThroughConverter2D
+ is AnimationVector3D -> passThroughConverter3D
+ is AnimationVector4D -> passThroughConverter4D
+ else -> throw UnsupportedOperationException()
+ }
+ @Suppress("UNCHECKED_CAST")
+ return converter as TwoWayConverter<T, T>
+}
+
+private val passThroughConverter1D = TypeConverter1D({ it }, { it })
+private val passThroughConverter2D = TypeConverter2D({ it }, { it })
+private val passThroughConverter3D = TypeConverter3D({ it }, { it })
+private val passThroughConverter4D = TypeConverter4D({ it }, { it })
+
/**
* This class defines a 1D vector. It contains only one Float value that is initialized in the
* constructor.
diff --git a/ui/ui-animation-core/src/main/java/androidx/animation/PropKey.kt b/ui/ui-animation-core/src/main/java/androidx/animation/PropKey.kt
index 40f6546..94ca2ca 100644
--- a/ui/ui-animation-core/src/main/java/androidx/animation/PropKey.kt
+++ b/ui/ui-animation-core/src/main/java/androidx/animation/PropKey.kt
@@ -134,4 +134,4 @@
* A [TwoWayConverter] that converts [Int] from and to [AnimationVector1D]
*/
val IntToVectorConverter: TwoWayConverter<Int, AnimationVector1D> =
- TypeConverter1D({ AnimationVector1D(it.toFloat()) }, { it.value.toInt() })
\ No newline at end of file
+ TypeConverter1D({ AnimationVector1D(it.toFloat()) }, { it.value.toInt() })
diff --git a/ui/ui-animation-core/src/main/java/androidx/animation/ValueHolder.kt b/ui/ui-animation-core/src/main/java/androidx/animation/ValueHolder.kt
index ea2b576..0645d99 100644
--- a/ui/ui-animation-core/src/main/java/androidx/animation/ValueHolder.kt
+++ b/ui/ui-animation-core/src/main/java/androidx/animation/ValueHolder.kt
@@ -20,36 +20,19 @@
* A value holder contains two fields: A mutable value that is expected to change throughout an
* animation, and an immutable value converter
*/
-interface ValueHolder<T, V : AnimationVector> {
+interface ValueHolder<T> {
/**
* Value of the [ValueHolder]. This value will be updated by subclasses of [BaseAnimatedValue].
*/
var value: T
-
- /**
- * A two way type converter that converts from value to [AnimationVector1D],
- * [AnimationVector2D], [AnimationVector3D], or [AnimationVector4D], and vice versa.
- */
- val typeConverter: TwoWayConverter<T, V>
}
/**
- * FloatValueHolder defines a value holder that holds a Float value.
- */
-interface FloatValueHolder : ValueHolder<Float, AnimationVector1D> {
- override val typeConverter: TwoWayConverter<Float, AnimationVector1D>
- get() = FloatToVectorConverter
-}
-
-/**
- * [ValueHolderImpl] is a data class that defines two fields: value (of type [T]) and a type
- * converter.
+ * Creates a [ValueHolder] (of type [T]) with the initial value being [initValue].
*
- * @param value This value field gets updated during animation
- * @param typeConverter A two way type converter that converts from value to [AnimationVector1D],
- * [AnimationVector2D], [Vector3D], or [Vector4D], and vice versa.
+ * @param initValue The initial value of the value holder to be created.
*/
-data class ValueHolderImpl<T, V : AnimationVector>(
- override var value: T,
- override val typeConverter: TwoWayConverter<T, V>
-) : ValueHolder<T, V>
+fun <T> ValueHolder(initValue: T): ValueHolder<T> =
+ object : ValueHolder<T> {
+ override var value: T = initValue
+ }
\ No newline at end of file
diff --git a/ui/ui-animation-core/src/test/java/androidx/animation/TypeConverterTest.kt b/ui/ui-animation-core/src/test/java/androidx/animation/TypeConverterTest.kt
index 68d99ac..6a557f1 100644
--- a/ui/ui-animation-core/src/test/java/androidx/animation/TypeConverterTest.kt
+++ b/ui/ui-animation-core/src/test/java/androidx/animation/TypeConverterTest.kt
@@ -27,10 +27,7 @@
fun testFloatToVectorConverter() {
verifyFloatConverter(FloatToVectorConverter)
verifyFloatConverter(FloatPropKey().typeConverter)
- val holder = object : FloatValueHolder {
- override var value: Float = 0.0f
- }
- verifyFloatConverter(holder.typeConverter)
+ verifyFloatConverter(AnimatedFloat(5f).typeConverter)
}
@Test
@@ -42,6 +39,19 @@
assertEquals(22, IntPropKey().typeConverter.convertFromVector(AnimationVector1D(22f)))
}
+ @Test
+ fun testAnimatedVectorConverter() {
+ verifyV2VConverter(AnimationVector1D(100f))
+ verifyV2VConverter(AnimationVector2D(40f, 50f))
+ verifyV2VConverter(AnimationVector3D(300f, -20f, 1f))
+ verifyV2VConverter(AnimationVector4D(100f, -20f, 3000f, 4f))
+ }
+
+ private fun <V : AnimationVector> verifyV2VConverter(value: V) {
+ val converter = AnimatedVectorValue(value).typeConverter
+ assertEquals(converter.convertFromVector(value), converter.convertToVector(value))
+ }
+
private fun verifyFloatConverter(converter: TwoWayConverter<Float, AnimationVector1D>) {
assertEquals(15f, converter.convertToVector(15f).value)
assertEquals(5f, converter.convertFromVector(AnimationVector1D(5f)))
diff --git a/ui/ui-animation/src/main/java/androidx/ui/animation/AnimatedValueEffects.kt b/ui/ui-animation/src/main/java/androidx/ui/animation/AnimatedValueEffects.kt
index 3ae5575..2185bcd 100644
--- a/ui/ui-animation/src/main/java/androidx/ui/animation/AnimatedValueEffects.kt
+++ b/ui/ui-animation/src/main/java/androidx/ui/animation/AnimatedValueEffects.kt
@@ -18,7 +18,6 @@
import androidx.animation.AnimatedFloat
import androidx.animation.AnimatedValue
-import androidx.animation.FloatValueHolder
import androidx.animation.TwoWayConverter
import androidx.compose.Model
import androidx.animation.ValueHolder
@@ -41,7 +40,7 @@
fun <T, V : AnimationVector> animatedValue(
initVal: T,
converter: TwoWayConverter<T, V>
-): AnimatedValue<T, V> = remember { AnimatedValue(AnimValueHolder(initVal, converter)) }
+): AnimatedValue<T, V> = remember { AnimatedValue(AnimValueHolder(initVal), converter) }
/**
* The animatedValue effect creates an [AnimatedFloat] and positionally memoizes it. When the
@@ -52,7 +51,7 @@
*/
@Composable
fun animatedFloat(initVal: Float): AnimatedFloat =
- remember { AnimatedFloat(FloatAnimValueHolder(initVal)) }
+ remember { AnimatedFloat(AnimValueHolder(initVal)) }
/**
* The animatedValue effect creates an [AnimatedValue] of [Color] and positionally memoizes it. When
@@ -63,22 +62,9 @@
*/
@Composable
fun animatedColor(initVal: Color): AnimatedValue<Color, AnimationVector4D> =
- remember { AnimatedValue(ColorAnimValueHolder(initVal)) }
+ remember { AnimatedValue(AnimValueHolder(initVal), ColorToVectorConverter(initVal.colorSpace)) }
@Model
-private class FloatAnimValueHolder(
- override var value: Float
-) : FloatValueHolder
-
-@Model
-private class ColorAnimValueHolder(
- override var value: Color
-) : ValueHolder<Color, AnimationVector4D> {
- override val typeConverter = ColorToVectorConverter(value.colorSpace)
-}
-
-@Model
-private class AnimValueHolder<T, V : AnimationVector>(
- override var value: T,
- override val typeConverter: TwoWayConverter<T, V>
-) : ValueHolder<T, V>
+private class AnimValueHolder<T> (
+ override var value: T
+) : ValueHolder<T>
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/animation/AnimatedValueHolder.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/animation/AnimatedValueHolder.kt
index cf7993a..fd519f0 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/animation/AnimatedValueHolder.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/animation/AnimatedValueHolder.kt
@@ -18,7 +18,6 @@
import androidx.animation.AnimatedFloat
import androidx.compose.Composable
-import androidx.animation.FloatValueHolder
import androidx.compose.Model
import androidx.compose.remember
import androidx.ui.foundation.ValueHolder
@@ -83,7 +82,7 @@
private class ListeneableValueHolder(
var current: Float,
var onValueChanged: (Float) -> Unit
-) : FloatValueHolder {
+) : androidx.animation.ValueHolder<Float> {
override var value: Float
get() = current
set(value) {