Add AnimatedValue scaffolding for physics thresholding
This CL introduces additional methods for animated float/value to specify visibility thresholds.
Test: Unit tests added
Change-Id: I1d040488da2c80fa23556c1740f7f400eba8975c
diff --git a/ui/ui-animation-core/api/0.1.0-dev10.txt b/ui/ui-animation-core/api/0.1.0-dev10.txt
index 46130e3..f3716d0 100644
--- a/ui/ui-animation-core/api/0.1.0-dev10.txt
+++ b/ui/ui-animation-core/api/0.1.0-dev10.txt
@@ -2,7 +2,7 @@
package androidx.animation {
public abstract class AnimatedFloat extends androidx.animation.BaseAnimatedValue<java.lang.Float,androidx.animation.AnimationVector1D> {
- ctor public AnimatedFloat(androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedFloat(androidx.animation.AnimationClockObservable clock, float visibilityThreshold);
method public final float getMax();
method public final float getMin();
method public final float getVelocity();
@@ -14,15 +14,15 @@
}
public abstract class AnimatedValue<T, V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<T,V> {
- ctor public AnimatedValue(androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedValue(androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V? visibilityThreshold);
method public final V getVelocity();
property public final V velocity;
}
public final class AnimatedValueKt {
- method public static androidx.animation.AnimatedFloat AnimatedFloat(float initVal, androidx.animation.AnimationClockObservable clock);
- method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> AnimatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
- method public static <V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<V,V> AnimatedVector(V initVal, androidx.animation.AnimationClockObservable clock);
+ method public static androidx.animation.AnimatedFloat AnimatedFloat(float initVal, androidx.animation.AnimationClockObservable clock, float visibilityThreshold = 0.01f);
+ method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> AnimatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V visibilityThreshold = typeConverter.invoke(initVal).newInstanceOfValue(Spring.DefaultDisplacementThreshold));
+ method public static <V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<V,V> AnimatedVector(V initVal, androidx.animation.AnimationClockObservable clock, V visibilityThreshold = initVal.newInstanceOfValue(Spring.DefaultDisplacementThreshold));
method public static void fling(androidx.animation.AnimatedFloat, float startVelocity, androidx.animation.DecayAnimation decay = androidx.animation.ExponentialDecay(), kotlin.jvm.functions.Function3<? super androidx.animation.AnimationEndReason,? super java.lang.Float,? super java.lang.Float,kotlin.Unit>? >
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>? >
}
@@ -125,7 +125,7 @@
}
public abstract sealed class BaseAnimatedValue<T, V extends androidx.animation.AnimationVector> {
- method public final void animateTo(T? targetValue, androidx.animation.AnimationBuilder<T> anim = androidx.animation.PhysicsBuilder(), kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit>? >
+ method public final void animateTo(T? targetValue, androidx.animation.AnimationBuilder<T> anim = defaultPhysicsBuilder(), kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit>? >
method protected void checkFinished(long playtime);
method public final T! getTargetValue();
method public abstract T! getValue();
@@ -241,14 +241,12 @@
}
public final class PhysicsBuilder<T> extends androidx.animation.AnimationBuilder<T> {
+ ctor public PhysicsBuilder(float dampingRatio, float stiffness, T! displacementThreshold);
ctor public PhysicsBuilder(float dampingRatio, float stiffness, float displacementThreshold);
- ctor public PhysicsBuilder();
method public <V extends androidx.animation.AnimationVector> androidx.animation.Animation<V> build$lintWithKotlin(androidx.animation.TwoWayConverter<T,V> converter);
method public float getDampingRatio();
- method public float getDisplacementThreshold();
method public float getStiffness();
method public void setDampingRatio(float p);
- method public void setDisplacementThreshold(float p);
method public void setStiffness(float p);
}
@@ -284,6 +282,7 @@
field public static final float DampingRatioLowBouncy = 0.75f;
field public static final float DampingRatioMediumBouncy = 0.5f;
field public static final float DampingRatioNoBouncy = 1.0f;
+ field public static final float DefaultDisplacementThreshold = 0.01f;
field public static final androidx.animation.Spring! INSTANCE;
field public static final float StiffnessHigh = 10000.0f;
field public static final float StiffnessLow = 200.0f;
diff --git a/ui/ui-animation-core/api/current.txt b/ui/ui-animation-core/api/current.txt
index 46130e3..f3716d0 100644
--- a/ui/ui-animation-core/api/current.txt
+++ b/ui/ui-animation-core/api/current.txt
@@ -2,7 +2,7 @@
package androidx.animation {
public abstract class AnimatedFloat extends androidx.animation.BaseAnimatedValue<java.lang.Float,androidx.animation.AnimationVector1D> {
- ctor public AnimatedFloat(androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedFloat(androidx.animation.AnimationClockObservable clock, float visibilityThreshold);
method public final float getMax();
method public final float getMin();
method public final float getVelocity();
@@ -14,15 +14,15 @@
}
public abstract class AnimatedValue<T, V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<T,V> {
- ctor public AnimatedValue(androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedValue(androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V? visibilityThreshold);
method public final V getVelocity();
property public final V velocity;
}
public final class AnimatedValueKt {
- method public static androidx.animation.AnimatedFloat AnimatedFloat(float initVal, androidx.animation.AnimationClockObservable clock);
- method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> AnimatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
- method public static <V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<V,V> AnimatedVector(V initVal, androidx.animation.AnimationClockObservable clock);
+ method public static androidx.animation.AnimatedFloat AnimatedFloat(float initVal, androidx.animation.AnimationClockObservable clock, float visibilityThreshold = 0.01f);
+ method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> AnimatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V visibilityThreshold = typeConverter.invoke(initVal).newInstanceOfValue(Spring.DefaultDisplacementThreshold));
+ method public static <V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<V,V> AnimatedVector(V initVal, androidx.animation.AnimationClockObservable clock, V visibilityThreshold = initVal.newInstanceOfValue(Spring.DefaultDisplacementThreshold));
method public static void fling(androidx.animation.AnimatedFloat, float startVelocity, androidx.animation.DecayAnimation decay = androidx.animation.ExponentialDecay(), kotlin.jvm.functions.Function3<? super androidx.animation.AnimationEndReason,? super java.lang.Float,? super java.lang.Float,kotlin.Unit>? >
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>? >
}
@@ -125,7 +125,7 @@
}
public abstract sealed class BaseAnimatedValue<T, V extends androidx.animation.AnimationVector> {
- method public final void animateTo(T? targetValue, androidx.animation.AnimationBuilder<T> anim = androidx.animation.PhysicsBuilder(), kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit>? >
+ method public final void animateTo(T? targetValue, androidx.animation.AnimationBuilder<T> anim = defaultPhysicsBuilder(), kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit>? >
method protected void checkFinished(long playtime);
method public final T! getTargetValue();
method public abstract T! getValue();
@@ -241,14 +241,12 @@
}
public final class PhysicsBuilder<T> extends androidx.animation.AnimationBuilder<T> {
+ ctor public PhysicsBuilder(float dampingRatio, float stiffness, T! displacementThreshold);
ctor public PhysicsBuilder(float dampingRatio, float stiffness, float displacementThreshold);
- ctor public PhysicsBuilder();
method public <V extends androidx.animation.AnimationVector> androidx.animation.Animation<V> build$lintWithKotlin(androidx.animation.TwoWayConverter<T,V> converter);
method public float getDampingRatio();
- method public float getDisplacementThreshold();
method public float getStiffness();
method public void setDampingRatio(float p);
- method public void setDisplacementThreshold(float p);
method public void setStiffness(float p);
}
@@ -284,6 +282,7 @@
field public static final float DampingRatioLowBouncy = 0.75f;
field public static final float DampingRatioMediumBouncy = 0.5f;
field public static final float DampingRatioNoBouncy = 1.0f;
+ field public static final float DefaultDisplacementThreshold = 0.01f;
field public static final androidx.animation.Spring! INSTANCE;
field public static final float StiffnessHigh = 10000.0f;
field public static final float StiffnessLow = 200.0f;
diff --git a/ui/ui-animation-core/api/public_plus_experimental_0.1.0-dev10.txt b/ui/ui-animation-core/api/public_plus_experimental_0.1.0-dev10.txt
index 46130e3..f3716d0 100644
--- a/ui/ui-animation-core/api/public_plus_experimental_0.1.0-dev10.txt
+++ b/ui/ui-animation-core/api/public_plus_experimental_0.1.0-dev10.txt
@@ -2,7 +2,7 @@
package androidx.animation {
public abstract class AnimatedFloat extends androidx.animation.BaseAnimatedValue<java.lang.Float,androidx.animation.AnimationVector1D> {
- ctor public AnimatedFloat(androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedFloat(androidx.animation.AnimationClockObservable clock, float visibilityThreshold);
method public final float getMax();
method public final float getMin();
method public final float getVelocity();
@@ -14,15 +14,15 @@
}
public abstract class AnimatedValue<T, V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<T,V> {
- ctor public AnimatedValue(androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedValue(androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V? visibilityThreshold);
method public final V getVelocity();
property public final V velocity;
}
public final class AnimatedValueKt {
- method public static androidx.animation.AnimatedFloat AnimatedFloat(float initVal, androidx.animation.AnimationClockObservable clock);
- method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> AnimatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
- method public static <V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<V,V> AnimatedVector(V initVal, androidx.animation.AnimationClockObservable clock);
+ method public static androidx.animation.AnimatedFloat AnimatedFloat(float initVal, androidx.animation.AnimationClockObservable clock, float visibilityThreshold = 0.01f);
+ method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> AnimatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V visibilityThreshold = typeConverter.invoke(initVal).newInstanceOfValue(Spring.DefaultDisplacementThreshold));
+ method public static <V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<V,V> AnimatedVector(V initVal, androidx.animation.AnimationClockObservable clock, V visibilityThreshold = initVal.newInstanceOfValue(Spring.DefaultDisplacementThreshold));
method public static void fling(androidx.animation.AnimatedFloat, float startVelocity, androidx.animation.DecayAnimation decay = androidx.animation.ExponentialDecay(), kotlin.jvm.functions.Function3<? super androidx.animation.AnimationEndReason,? super java.lang.Float,? super java.lang.Float,kotlin.Unit>? >
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>? >
}
@@ -125,7 +125,7 @@
}
public abstract sealed class BaseAnimatedValue<T, V extends androidx.animation.AnimationVector> {
- method public final void animateTo(T? targetValue, androidx.animation.AnimationBuilder<T> anim = androidx.animation.PhysicsBuilder(), kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit>? >
+ method public final void animateTo(T? targetValue, androidx.animation.AnimationBuilder<T> anim = defaultPhysicsBuilder(), kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit>? >
method protected void checkFinished(long playtime);
method public final T! getTargetValue();
method public abstract T! getValue();
@@ -241,14 +241,12 @@
}
public final class PhysicsBuilder<T> extends androidx.animation.AnimationBuilder<T> {
+ ctor public PhysicsBuilder(float dampingRatio, float stiffness, T! displacementThreshold);
ctor public PhysicsBuilder(float dampingRatio, float stiffness, float displacementThreshold);
- ctor public PhysicsBuilder();
method public <V extends androidx.animation.AnimationVector> androidx.animation.Animation<V> build$lintWithKotlin(androidx.animation.TwoWayConverter<T,V> converter);
method public float getDampingRatio();
- method public float getDisplacementThreshold();
method public float getStiffness();
method public void setDampingRatio(float p);
- method public void setDisplacementThreshold(float p);
method public void setStiffness(float p);
}
@@ -284,6 +282,7 @@
field public static final float DampingRatioLowBouncy = 0.75f;
field public static final float DampingRatioMediumBouncy = 0.5f;
field public static final float DampingRatioNoBouncy = 1.0f;
+ field public static final float DefaultDisplacementThreshold = 0.01f;
field public static final androidx.animation.Spring! INSTANCE;
field public static final float StiffnessHigh = 10000.0f;
field public static final float StiffnessLow = 200.0f;
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 46130e3..f3716d0 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,7 @@
package androidx.animation {
public abstract class AnimatedFloat extends androidx.animation.BaseAnimatedValue<java.lang.Float,androidx.animation.AnimationVector1D> {
- ctor public AnimatedFloat(androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedFloat(androidx.animation.AnimationClockObservable clock, float visibilityThreshold);
method public final float getMax();
method public final float getMin();
method public final float getVelocity();
@@ -14,15 +14,15 @@
}
public abstract class AnimatedValue<T, V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<T,V> {
- ctor public AnimatedValue(androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedValue(androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V? visibilityThreshold);
method public final V getVelocity();
property public final V velocity;
}
public final class AnimatedValueKt {
- method public static androidx.animation.AnimatedFloat AnimatedFloat(float initVal, androidx.animation.AnimationClockObservable clock);
- method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> AnimatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
- method public static <V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<V,V> AnimatedVector(V initVal, androidx.animation.AnimationClockObservable clock);
+ method public static androidx.animation.AnimatedFloat AnimatedFloat(float initVal, androidx.animation.AnimationClockObservable clock, float visibilityThreshold = 0.01f);
+ method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> AnimatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V visibilityThreshold = typeConverter.invoke(initVal).newInstanceOfValue(Spring.DefaultDisplacementThreshold));
+ method public static <V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<V,V> AnimatedVector(V initVal, androidx.animation.AnimationClockObservable clock, V visibilityThreshold = initVal.newInstanceOfValue(Spring.DefaultDisplacementThreshold));
method public static void fling(androidx.animation.AnimatedFloat, float startVelocity, androidx.animation.DecayAnimation decay = androidx.animation.ExponentialDecay(), kotlin.jvm.functions.Function3<? super androidx.animation.AnimationEndReason,? super java.lang.Float,? super java.lang.Float,kotlin.Unit>? >
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>? >
}
@@ -125,7 +125,7 @@
}
public abstract sealed class BaseAnimatedValue<T, V extends androidx.animation.AnimationVector> {
- method public final void animateTo(T? targetValue, androidx.animation.AnimationBuilder<T> anim = androidx.animation.PhysicsBuilder(), kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit>? >
+ method public final void animateTo(T? targetValue, androidx.animation.AnimationBuilder<T> anim = defaultPhysicsBuilder(), kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit>? >
method protected void checkFinished(long playtime);
method public final T! getTargetValue();
method public abstract T! getValue();
@@ -241,14 +241,12 @@
}
public final class PhysicsBuilder<T> extends androidx.animation.AnimationBuilder<T> {
+ ctor public PhysicsBuilder(float dampingRatio, float stiffness, T! displacementThreshold);
ctor public PhysicsBuilder(float dampingRatio, float stiffness, float displacementThreshold);
- ctor public PhysicsBuilder();
method public <V extends androidx.animation.AnimationVector> androidx.animation.Animation<V> build$lintWithKotlin(androidx.animation.TwoWayConverter<T,V> converter);
method public float getDampingRatio();
- method public float getDisplacementThreshold();
method public float getStiffness();
method public void setDampingRatio(float p);
- method public void setDisplacementThreshold(float p);
method public void setStiffness(float p);
}
@@ -284,6 +282,7 @@
field public static final float DampingRatioLowBouncy = 0.75f;
field public static final float DampingRatioMediumBouncy = 0.5f;
field public static final float DampingRatioNoBouncy = 1.0f;
+ field public static final float DefaultDisplacementThreshold = 0.01f;
field public static final androidx.animation.Spring! INSTANCE;
field public static final float StiffnessHigh = 10000.0f;
field public static final float StiffnessLow = 200.0f;
diff --git a/ui/ui-animation-core/api/restricted_0.1.0-dev10.txt b/ui/ui-animation-core/api/restricted_0.1.0-dev10.txt
index 46130e3..f3716d0 100644
--- a/ui/ui-animation-core/api/restricted_0.1.0-dev10.txt
+++ b/ui/ui-animation-core/api/restricted_0.1.0-dev10.txt
@@ -2,7 +2,7 @@
package androidx.animation {
public abstract class AnimatedFloat extends androidx.animation.BaseAnimatedValue<java.lang.Float,androidx.animation.AnimationVector1D> {
- ctor public AnimatedFloat(androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedFloat(androidx.animation.AnimationClockObservable clock, float visibilityThreshold);
method public final float getMax();
method public final float getMin();
method public final float getVelocity();
@@ -14,15 +14,15 @@
}
public abstract class AnimatedValue<T, V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<T,V> {
- ctor public AnimatedValue(androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedValue(androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V? visibilityThreshold);
method public final V getVelocity();
property public final V velocity;
}
public final class AnimatedValueKt {
- method public static androidx.animation.AnimatedFloat AnimatedFloat(float initVal, androidx.animation.AnimationClockObservable clock);
- method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> AnimatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
- method public static <V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<V,V> AnimatedVector(V initVal, androidx.animation.AnimationClockObservable clock);
+ method public static androidx.animation.AnimatedFloat AnimatedFloat(float initVal, androidx.animation.AnimationClockObservable clock, float visibilityThreshold = 0.01f);
+ method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> AnimatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V visibilityThreshold = typeConverter.invoke(initVal).newInstanceOfValue(Spring.DefaultDisplacementThreshold));
+ method public static <V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<V,V> AnimatedVector(V initVal, androidx.animation.AnimationClockObservable clock, V visibilityThreshold = initVal.newInstanceOfValue(Spring.DefaultDisplacementThreshold));
method public static void fling(androidx.animation.AnimatedFloat, float startVelocity, androidx.animation.DecayAnimation decay = androidx.animation.ExponentialDecay(), kotlin.jvm.functions.Function3<? super androidx.animation.AnimationEndReason,? super java.lang.Float,? super java.lang.Float,kotlin.Unit>? >
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>? >
}
@@ -125,7 +125,7 @@
}
public abstract sealed class BaseAnimatedValue<T, V extends androidx.animation.AnimationVector> {
- method public final void animateTo(T? targetValue, androidx.animation.AnimationBuilder<T> anim = androidx.animation.PhysicsBuilder(), kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit>? >
+ method public final void animateTo(T? targetValue, androidx.animation.AnimationBuilder<T> anim = defaultPhysicsBuilder(), kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit>? >
method protected void checkFinished(long playtime);
method public final T! getTargetValue();
method public abstract T! getValue();
@@ -241,14 +241,12 @@
}
public final class PhysicsBuilder<T> extends androidx.animation.AnimationBuilder<T> {
+ ctor public PhysicsBuilder(float dampingRatio, float stiffness, T! displacementThreshold);
ctor public PhysicsBuilder(float dampingRatio, float stiffness, float displacementThreshold);
- ctor public PhysicsBuilder();
method public <V extends androidx.animation.AnimationVector> androidx.animation.Animation<V> build$lintWithKotlin(androidx.animation.TwoWayConverter<T,V> converter);
method public float getDampingRatio();
- method public float getDisplacementThreshold();
method public float getStiffness();
method public void setDampingRatio(float p);
- method public void setDisplacementThreshold(float p);
method public void setStiffness(float p);
}
@@ -284,6 +282,7 @@
field public static final float DampingRatioLowBouncy = 0.75f;
field public static final float DampingRatioMediumBouncy = 0.5f;
field public static final float DampingRatioNoBouncy = 1.0f;
+ field public static final float DefaultDisplacementThreshold = 0.01f;
field public static final androidx.animation.Spring! INSTANCE;
field public static final float StiffnessHigh = 10000.0f;
field public static final float StiffnessLow = 200.0f;
diff --git a/ui/ui-animation-core/api/restricted_current.txt b/ui/ui-animation-core/api/restricted_current.txt
index 46130e3..f3716d0 100644
--- a/ui/ui-animation-core/api/restricted_current.txt
+++ b/ui/ui-animation-core/api/restricted_current.txt
@@ -2,7 +2,7 @@
package androidx.animation {
public abstract class AnimatedFloat extends androidx.animation.BaseAnimatedValue<java.lang.Float,androidx.animation.AnimationVector1D> {
- ctor public AnimatedFloat(androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedFloat(androidx.animation.AnimationClockObservable clock, float visibilityThreshold);
method public final float getMax();
method public final float getMin();
method public final float getVelocity();
@@ -14,15 +14,15 @@
}
public abstract class AnimatedValue<T, V extends androidx.animation.AnimationVector> extends androidx.animation.BaseAnimatedValue<T,V> {
- ctor public AnimatedValue(androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedValue(androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V? visibilityThreshold);
method public final V getVelocity();
property public final V velocity;
}
public final class AnimatedValueKt {
- method public static androidx.animation.AnimatedFloat AnimatedFloat(float initVal, androidx.animation.AnimationClockObservable clock);
- method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> AnimatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
- method public static <V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<V,V> AnimatedVector(V initVal, androidx.animation.AnimationClockObservable clock);
+ method public static androidx.animation.AnimatedFloat AnimatedFloat(float initVal, androidx.animation.AnimationClockObservable clock, float visibilityThreshold = 0.01f);
+ method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> AnimatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V visibilityThreshold = typeConverter.invoke(initVal).newInstanceOfValue(Spring.DefaultDisplacementThreshold));
+ method public static <V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<V,V> AnimatedVector(V initVal, androidx.animation.AnimationClockObservable clock, V visibilityThreshold = initVal.newInstanceOfValue(Spring.DefaultDisplacementThreshold));
method public static void fling(androidx.animation.AnimatedFloat, float startVelocity, androidx.animation.DecayAnimation decay = androidx.animation.ExponentialDecay(), kotlin.jvm.functions.Function3<? super androidx.animation.AnimationEndReason,? super java.lang.Float,? super java.lang.Float,kotlin.Unit>? >
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>? >
}
@@ -125,7 +125,7 @@
}
public abstract sealed class BaseAnimatedValue<T, V extends androidx.animation.AnimationVector> {
- method public final void animateTo(T? targetValue, androidx.animation.AnimationBuilder<T> anim = androidx.animation.PhysicsBuilder(), kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit>? >
+ method public final void animateTo(T? targetValue, androidx.animation.AnimationBuilder<T> anim = defaultPhysicsBuilder(), kotlin.jvm.functions.Function2<? super androidx.animation.AnimationEndReason,? super T,kotlin.Unit>? >
method protected void checkFinished(long playtime);
method public final T! getTargetValue();
method public abstract T! getValue();
@@ -241,14 +241,12 @@
}
public final class PhysicsBuilder<T> extends androidx.animation.AnimationBuilder<T> {
+ ctor public PhysicsBuilder(float dampingRatio, float stiffness, T! displacementThreshold);
ctor public PhysicsBuilder(float dampingRatio, float stiffness, float displacementThreshold);
- ctor public PhysicsBuilder();
method public <V extends androidx.animation.AnimationVector> androidx.animation.Animation<V> build$lintWithKotlin(androidx.animation.TwoWayConverter<T,V> converter);
method public float getDampingRatio();
- method public float getDisplacementThreshold();
method public float getStiffness();
method public void setDampingRatio(float p);
- method public void setDisplacementThreshold(float p);
method public void setStiffness(float p);
}
@@ -284,6 +282,7 @@
field public static final float DampingRatioLowBouncy = 0.75f;
field public static final float DampingRatioMediumBouncy = 0.5f;
field public static final float DampingRatioNoBouncy = 1.0f;
+ field public static final float DefaultDisplacementThreshold = 0.01f;
field public static final androidx.animation.Spring! INSTANCE;
field public static final float StiffnessHigh = 10000.0f;
field public static final float StiffnessLow = 200.0f;
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 f001f21..ba766fc 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
@@ -34,10 +34,14 @@
* [AnimationVector2D], [AnimationVector3D], or [AnimationVector4D], and vice
* versa.
* @param clock An animation clock observable controlling the progression of the animated value
+ * @param visibilityThreshold Visibility threshold of the animation specifies the end condition:
+ * for t > duration, value < visibilityThreshold. Null value defaults to [PhysicsBuilder]
+ * default.
*/
sealed class BaseAnimatedValue<T, V : AnimationVector>(
internal val typeConverter: TwoWayConverter<T, V>,
- private val clock: AnimationClockObservable
+ private val clock: AnimationClockObservable,
+ internal val visibilityThreshold: V?
) {
/**
@@ -109,6 +113,12 @@
}
}
+ private fun defaultPhysicsBuilder(): PhysicsBuilder<T> {
+ return visibilityThreshold?.let {
+ PhysicsBuilder(displacementThreshold = typeConverter.convertFromVector(it))
+ } ?: PhysicsBuilder()
+ }
+
// TODO: Need a test for animateTo(...) being called with the same target value
/**
* Sets the target value, which effectively starts an animation to change the value from [value]
@@ -116,7 +126,7 @@
* the ongoing animation, invoke [onEnd] that is associated with that animation, and start
* a new animation from the current value to the new target value.
*
- * @param targetValue The new value to animate to.
+ * @param targetValue The new value to animate to
* @param anim The animation that will be used to animate from the current value to the new
* target value. If unspecified, a spring animation will be used by default.
* @param onEnd An optional callback that will be invoked when the animation finished by any
@@ -124,7 +134,7 @@
*/
fun animateTo(
targetValue: T,
- anim: AnimationBuilder<T> = PhysicsBuilder(),
+ anim: AnimationBuilder<T> = defaultPhysicsBuilder(),
onEnd: ((AnimationEndReason, T) -> Unit)? = null
) {
if (isRunning) {
@@ -249,8 +259,9 @@
*/
abstract class AnimatedValue<T, V : AnimationVector>(
typeConverter: TwoWayConverter<T, V>,
- clock: AnimationClockObservable
-) : BaseAnimatedValue<T, V>(typeConverter, clock) {
+ clock: AnimationClockObservable,
+ visibilityThreshold: V? = null
+) : BaseAnimatedValue<T, V>(typeConverter, clock, visibilityThreshold) {
val velocity: V
get() = velocityVector
}
@@ -264,8 +275,10 @@
* @param clock An animation clock observable controlling the progression of the animated value
*/
abstract class AnimatedFloat(
- clock: AnimationClockObservable
-) : BaseAnimatedValue<Float, AnimationVector1D>(FloatToVectorConverter, clock) {
+ clock: AnimationClockObservable,
+ visibilityThreshold: Float = Spring.DefaultDisplacementThreshold
+) : BaseAnimatedValue<Float, AnimationVector1D>(
+ FloatToVectorConverter, clock, AnimationVector(visibilityThreshold)) {
/**
* Lower bound of the animation value. When animations reach this lower bound, it will
@@ -425,9 +438,12 @@
fun <T, V : AnimationVector> AnimatedValue(
initVal: T,
typeConverter: TwoWayConverter<T, V>,
- clock: AnimationClockObservable
+ clock: AnimationClockObservable,
+ visibilityThreshold: V = typeConverter
+ .convertToVector(initVal)
+ .newInstanceOfValue(Spring.DefaultDisplacementThreshold)
): AnimatedValue<T, V> =
- AnimatedValueImpl(initVal, typeConverter, clock)
+ AnimatedValueImpl(initVal, typeConverter, clock, visibilityThreshold)
/**
* Factory method for creating an [AnimatedVector] object, and initialize the value field to
@@ -438,9 +454,10 @@
*/
fun <V : AnimationVector> AnimatedVector(
initVal: V,
- clock: AnimationClockObservable
+ clock: AnimationClockObservable,
+ visibilityThreshold: V = initVal.newInstanceOfValue(Spring.DefaultDisplacementThreshold)
): AnimatedValue<V, V> =
- AnimatedValueImpl(initVal, TwoWayConverter({ it }, { it }), clock)
+ AnimatedValueImpl(initVal, TwoWayConverter({ it }, { it }), clock, visibilityThreshold)
/**
* Factory method for creating an [AnimatedFloat] object, and initialize the value field to
@@ -448,23 +465,35 @@
*
* @param initVal Initial value to initialize the animation to.
* @param clock The animation clock used to drive the animation.
+ * @param visibilityThreshold Threshold at which the animation may round off to its target value.
*/
-fun AnimatedFloat(initVal: Float, clock: AnimationClockObservable): AnimatedFloat =
- AnimatedFloatImpl(initVal, clock)
+fun AnimatedFloat(
+ initVal: Float,
+ clock: AnimationClockObservable,
+ visibilityThreshold: Float = Spring.DefaultDisplacementThreshold
+): AnimatedFloat = AnimatedFloatImpl(initVal, clock, visibilityThreshold)
// Private impl for AnimatedValue
private class AnimatedValueImpl<T, V : AnimationVector>(
initVal: T,
typeConverter: TwoWayConverter<T, V>,
- clock: AnimationClockObservable
-) : AnimatedValue<T, V>(typeConverter, clock) {
+ clock: AnimationClockObservable,
+ visibilityThreshold: V
+) : AnimatedValue<T, V>(typeConverter, clock, visibilityThreshold) {
override var value: T = initVal
}
// Private impl for AnimatedFloat
private class AnimatedFloatImpl(
initVal: Float,
- clock: AnimationClockObservable
-) : AnimatedFloat(clock) {
+ clock: AnimationClockObservable,
+ visibilityThreshold: Float
+) : AnimatedFloat(clock, visibilityThreshold) {
override var value: Float = initVal
-}
\ No newline at end of file
+}
+
+private fun <V : AnimationVector> V.newInstanceOfValue(value: Float): V {
+ return newInstance().apply {
+ (0 until size).forEach { set(it, value) }
+ }
+}
diff --git a/ui/ui-animation-core/src/main/java/androidx/animation/AnimationBuilder.kt b/ui/ui-animation-core/src/main/java/androidx/animation/AnimationBuilder.kt
index 8f5a542..2a54865 100644
--- a/ui/ui-animation-core/src/main/java/androidx/animation/AnimationBuilder.kt
+++ b/ui/ui-animation-core/src/main/java/androidx/animation/AnimationBuilder.kt
@@ -17,6 +17,7 @@
package androidx.animation
import androidx.animation.Spring.DampingRatioNoBouncy
+import androidx.animation.Spring.DefaultDisplacementThreshold
import androidx.animation.Spring.StiffnessMedium
import androidx.animation.Spring.StiffnessVeryLow
@@ -203,15 +204,44 @@
* @param dampingRatio Damping ratio of the spring. Defaults to [DampingRatioNoBouncy]
* @param stiffness Stiffness of the spring. Defaults to [StiffnessVeryLow]
*/
-class PhysicsBuilder<T>(
+class PhysicsBuilder<T> private constructor(
var dampingRatio: Float = DampingRatioNoBouncy,
- var stiffness: Float = StiffnessMedium,
- var displacementThreshold: Float = 0.01f
+ var stiffness: Float = StiffnessMedium
) : AnimationBuilder<T>() {
+ private var genericThreshold: T? = null
+ private var floatThreshold: Float = DefaultDisplacementThreshold
+
+ constructor(
+ dampingRatio: Float = DampingRatioNoBouncy,
+ stiffness: Float = StiffnessMedium,
+ displacementThreshold: T
+ ) : this(dampingRatio, stiffness) {
+ this.genericThreshold = displacementThreshold
+ }
+
+ constructor(
+ dampingRatio: Float = DampingRatioNoBouncy,
+ stiffness: Float = StiffnessMedium,
+ displacementThreshold: Float = DefaultDisplacementThreshold
+ ) : this(dampingRatio, stiffness) {
+ floatThreshold = displacementThreshold
+ }
+
override fun <V : AnimationVector> build(converter: TwoWayConverter<T, V>): Animation<V> {
- return SpringAnimation(dampingRatio, stiffness, displacementThreshold)
- .buildMultiDimensAnim()
+ val floatThreshold = this.floatThreshold
+ val genericThreshold = this.genericThreshold
+
+ return if (genericThreshold != null) {
+ SpringAnimationVector(
+ dampingRatio,
+ stiffness,
+ converter.convertToVector(genericThreshold)
+ )
+ } else {
+ SpringAnimation(dampingRatio, stiffness, floatThreshold)
+ .buildMultiDimensAnim()
+ }
}
}
@@ -223,6 +253,49 @@
SnapAnimation()
}
+private class SpringAnimationVector<V : AnimationVector>(
+ val dampingRatio: Float,
+ val stiffness: Float,
+ val threshold: V
+) : Animation<V> {
+ private val anims = (0 until threshold.size).map { index ->
+ SpringAnimation(dampingRatio, stiffness, threshold[index])
+ }
+ private lateinit var valueVector: V
+ private lateinit var velocityVector: V
+
+ override fun getValue(playTime: Long, start: V, end: V, startVelocity: V): V {
+ if (!::valueVector.isInitialized) {
+ valueVector = start.newInstance()
+ }
+ for (i in 0 until valueVector.size) {
+ valueVector[i] = anims[i].getValue(playTime, start[i], end[i], startVelocity[i])
+ }
+ return valueVector
+ }
+
+ override fun getVelocity(playTime: Long, start: V, end: V, startVelocity: V): V {
+ if (!::velocityVector.isInitialized) {
+ velocityVector = startVelocity.newInstance()
+ }
+ for (i in 0 until velocityVector.size) {
+ velocityVector[i] = anims[i].getVelocity(playTime, start[i], end[i], startVelocity[i])
+ }
+ return velocityVector
+ }
+
+ override fun getDurationMillis(start: V, end: V, startVelocity: V): Long {
+ var maxDuration = 0L
+ (0 until start.size).forEach {
+ maxDuration = maxOf(
+ maxDuration,
+ anims[it].getDurationMillis(start[it], end[it], startVelocity[it])
+ )
+ }
+ return maxDuration
+ }
+}
+
/**
* Convert a 1D animation into a potential multi-dimensional animation by using the same 1D
* animation on all dimensions.
@@ -293,4 +366,4 @@
override fun getVelocity(playTime: Long, start: V, end: V, startVelocity: V): V {
return anim.getVelocity(playTime, start, end, startVelocity)
}
-}
\ No newline at end of file
+}
diff --git a/ui/ui-animation-core/src/main/java/androidx/animation/FloatAnimation.kt b/ui/ui-animation-core/src/main/java/androidx/animation/FloatAnimation.kt
index 38b5fc3..d7f3695 100644
--- a/ui/ui-animation-core/src/main/java/androidx/animation/FloatAnimation.kt
+++ b/ui/ui-animation-core/src/main/java/androidx/animation/FloatAnimation.kt
@@ -104,6 +104,10 @@
* without oscillating.
*/
const val DampingRatioNoBouncy = 1f
+ /**
+ * Default cutoff for rounding off physics based animations
+ */
+ const val DefaultDisplacementThreshold = 0.01f
}
/**
@@ -123,9 +127,9 @@
stiffness: Float = Spring.StiffnessMedium,
/**
* The value threshold such that the animation is no longer significant. An example would be
- * 1px for translation animations. Defaults to 0.01f
+ * 1px for translation animations. Defaults to [Spring.DefaultDisplacementThreshold]
*/
- private val displacementThreshold: Float = 0.01f
+ private val displacementThreshold: Float = Spring.DefaultDisplacementThreshold
) : FloatAnimation {
private val spring = SpringSimulation(1f).also {
diff --git a/ui/ui-animation-core/src/test/java/androidx/animation/PhysicsAnimationTest.kt b/ui/ui-animation-core/src/test/java/androidx/animation/PhysicsAnimationTest.kt
index 617b1f6..4df3aef 100644
--- a/ui/ui-animation-core/src/test/java/androidx/animation/PhysicsAnimationTest.kt
+++ b/ui/ui-animation-core/src/test/java/androidx/animation/PhysicsAnimationTest.kt
@@ -150,6 +150,7 @@
overWrapper.durationMillis
)
}
+
@Test
fun testUnderdampedDuration() {
val startValue = 100f
@@ -159,7 +160,7 @@
val delta = 1.0
val underBuilder = PhysicsBuilder<Float>(
- dampingRatio = .5f,
+ dampingRatio = 0.5f,
stiffness = stiffness,
displacementThreshold = 1f
)
@@ -188,6 +189,95 @@
}
}
+ @Test
+ fun testSpringVectorAnimationDuration() {
+ data class ClassToAnimate(var one: Float, var two: Float, var three: Float)
+ val springVectorAnimation = PhysicsBuilder(
+ displacementThreshold = ClassToAnimate(1f, 2f, 3f)
+ ).build(
+ TwoWayConverter<ClassToAnimate, AnimationVector3D>(
+ convertToVector = { it ->
+ AnimationVector(it.one, it.two, it.three)
+ },
+ convertFromVector = { it ->
+ ClassToAnimate(it.v1, it.v2, it.v3)
+ }
+ )
+ )
+ val floatAnimation = PhysicsBuilder<Float>(displacementThreshold = 1f).build()
+
+ val springVectorDuration = springVectorAnimation.getDurationMillis(
+ AnimationVector(100f, 100f, 100f),
+ AnimationVector(0f, 0f, 0f),
+ AnimationVector(0f, 0f, 0f)
+ )
+ val floatAnimationDuration = floatAnimation.getDurationMillis(
+ AnimationVector(100f),
+ AnimationVector(0f),
+ AnimationVector(0f)
+ )
+
+ // Vector duration should be the longest of all the sub animations
+ // In this case it should be the one with the lowest threshold.
+ assertEquals(springVectorDuration, floatAnimationDuration)
+ }
+
+ @Test
+ fun testSpringVectorAnimationValues() {
+ data class ClassToAnimate(var one: Float, var two: Float, var three: Float)
+ val springVectorAnimation = PhysicsBuilder(
+ displacementThreshold = ClassToAnimate(1f, 2f, 3f)
+ ).build(
+ TwoWayConverter<ClassToAnimate, AnimationVector3D>(
+ convertToVector = { it ->
+ AnimationVector(it.one, it.two, it.three)
+ },
+ convertFromVector = { it ->
+ ClassToAnimate(it.v1, it.v2, it.v3)
+ }
+ )
+ )
+ val floatAnimation1 = PhysicsBuilder<Float>(displacementThreshold = 1f).build()
+ val floatAnimation2 = PhysicsBuilder<Float>(displacementThreshold = 2f).build()
+ val floatAnimation3 = PhysicsBuilder<Float>(displacementThreshold = 3f).build()
+
+ val duration = springVectorAnimation.getDurationMillis(
+ AnimationVector(100f, 100f, 100f),
+ AnimationVector(0f, 0f, 0f),
+ AnimationVector(0f, 0f, 0f)
+ )
+
+ for (time in 0L until duration) {
+ val springVector = springVectorAnimation.getValue(
+ time,
+ AnimationVector(100f, 100f, 100f),
+ AnimationVector(0f, 0f, 0f),
+ AnimationVector(0f, 0f, 0f)
+ )
+ val float1 = floatAnimation1.getValue(
+ time,
+ AnimationVector(100f),
+ AnimationVector(0f),
+ AnimationVector(0f)
+ )
+ val float2 = floatAnimation2.getValue(
+ time,
+ AnimationVector(100f),
+ AnimationVector(0f),
+ AnimationVector(0f)
+ )
+ val float3 = floatAnimation3.getValue(
+ time,
+ AnimationVector(100f),
+ AnimationVector(0f),
+ AnimationVector(0f)
+ )
+ assertEquals(float1.value, springVector.v1, epsilon)
+ assertEquals(float2.value, springVector.v2, epsilon)
+ assertEquals(float3.value, springVector.v3, epsilon)
+ }
+ }
+
private fun Animation<AnimationVector1D>.toWrapper(
startValue: Float,
startVelocity: Float,
diff --git a/ui/ui-animation/api/0.1.0-dev10.txt b/ui/ui-animation/api/0.1.0-dev10.txt
index 398a5798..3e726b8 100644
--- a/ui/ui-animation/api/0.1.0-dev10.txt
+++ b/ui/ui-animation/api/0.1.0-dev10.txt
@@ -2,19 +2,19 @@
package androidx.ui.animation {
public final class AnimatedFloatModel extends androidx.animation.AnimatedFloat {
- ctor public AnimatedFloatModel(float value, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedFloatModel(float value, androidx.animation.AnimationClockObservable clock, float visibilityThreshold);
method public Float getValue();
method protected void setValue(float p);
}
public final class AnimatedValueEffectsKt {
method public static androidx.animation.AnimatedValue<androidx.ui.graphics.Color,androidx.animation.AnimationVector4D> animatedColor(androidx.ui.graphics.Color initVal, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
- method public static androidx.animation.AnimatedFloat animatedFloat(float initVal, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
- method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> animatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> converter, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
+ method public static androidx.animation.AnimatedFloat animatedFloat(float initVal, float visibilityThreshold = 0.01f, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
+ method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> animatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> converter, V? visibilityThreshold = null, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
}
public final class AnimatedValueModel<T, V extends androidx.animation.AnimationVector> extends androidx.animation.AnimatedValue<T,V> {
- ctor public AnimatedValueModel(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedValueModel(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V? visibilityThreshold);
method public T! getValue();
method protected void setValue(T? p);
}
diff --git a/ui/ui-animation/api/current.txt b/ui/ui-animation/api/current.txt
index 398a5798..3e726b8 100644
--- a/ui/ui-animation/api/current.txt
+++ b/ui/ui-animation/api/current.txt
@@ -2,19 +2,19 @@
package androidx.ui.animation {
public final class AnimatedFloatModel extends androidx.animation.AnimatedFloat {
- ctor public AnimatedFloatModel(float value, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedFloatModel(float value, androidx.animation.AnimationClockObservable clock, float visibilityThreshold);
method public Float getValue();
method protected void setValue(float p);
}
public final class AnimatedValueEffectsKt {
method public static androidx.animation.AnimatedValue<androidx.ui.graphics.Color,androidx.animation.AnimationVector4D> animatedColor(androidx.ui.graphics.Color initVal, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
- method public static androidx.animation.AnimatedFloat animatedFloat(float initVal, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
- method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> animatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> converter, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
+ method public static androidx.animation.AnimatedFloat animatedFloat(float initVal, float visibilityThreshold = 0.01f, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
+ method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> animatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> converter, V? visibilityThreshold = null, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
}
public final class AnimatedValueModel<T, V extends androidx.animation.AnimationVector> extends androidx.animation.AnimatedValue<T,V> {
- ctor public AnimatedValueModel(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedValueModel(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V? visibilityThreshold);
method public T! getValue();
method protected void setValue(T? p);
}
diff --git a/ui/ui-animation/api/public_plus_experimental_0.1.0-dev10.txt b/ui/ui-animation/api/public_plus_experimental_0.1.0-dev10.txt
index 398a5798..3e726b8 100644
--- a/ui/ui-animation/api/public_plus_experimental_0.1.0-dev10.txt
+++ b/ui/ui-animation/api/public_plus_experimental_0.1.0-dev10.txt
@@ -2,19 +2,19 @@
package androidx.ui.animation {
public final class AnimatedFloatModel extends androidx.animation.AnimatedFloat {
- ctor public AnimatedFloatModel(float value, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedFloatModel(float value, androidx.animation.AnimationClockObservable clock, float visibilityThreshold);
method public Float getValue();
method protected void setValue(float p);
}
public final class AnimatedValueEffectsKt {
method public static androidx.animation.AnimatedValue<androidx.ui.graphics.Color,androidx.animation.AnimationVector4D> animatedColor(androidx.ui.graphics.Color initVal, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
- method public static androidx.animation.AnimatedFloat animatedFloat(float initVal, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
- method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> animatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> converter, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
+ method public static androidx.animation.AnimatedFloat animatedFloat(float initVal, float visibilityThreshold = 0.01f, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
+ method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> animatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> converter, V? visibilityThreshold = null, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
}
public final class AnimatedValueModel<T, V extends androidx.animation.AnimationVector> extends androidx.animation.AnimatedValue<T,V> {
- ctor public AnimatedValueModel(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedValueModel(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V? visibilityThreshold);
method public T! getValue();
method protected void setValue(T? p);
}
diff --git a/ui/ui-animation/api/public_plus_experimental_current.txt b/ui/ui-animation/api/public_plus_experimental_current.txt
index 398a5798..3e726b8 100644
--- a/ui/ui-animation/api/public_plus_experimental_current.txt
+++ b/ui/ui-animation/api/public_plus_experimental_current.txt
@@ -2,19 +2,19 @@
package androidx.ui.animation {
public final class AnimatedFloatModel extends androidx.animation.AnimatedFloat {
- ctor public AnimatedFloatModel(float value, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedFloatModel(float value, androidx.animation.AnimationClockObservable clock, float visibilityThreshold);
method public Float getValue();
method protected void setValue(float p);
}
public final class AnimatedValueEffectsKt {
method public static androidx.animation.AnimatedValue<androidx.ui.graphics.Color,androidx.animation.AnimationVector4D> animatedColor(androidx.ui.graphics.Color initVal, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
- method public static androidx.animation.AnimatedFloat animatedFloat(float initVal, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
- method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> animatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> converter, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
+ method public static androidx.animation.AnimatedFloat animatedFloat(float initVal, float visibilityThreshold = 0.01f, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
+ method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> animatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> converter, V? visibilityThreshold = null, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
}
public final class AnimatedValueModel<T, V extends androidx.animation.AnimationVector> extends androidx.animation.AnimatedValue<T,V> {
- ctor public AnimatedValueModel(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedValueModel(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V? visibilityThreshold);
method public T! getValue();
method protected void setValue(T? p);
}
diff --git a/ui/ui-animation/api/restricted_0.1.0-dev10.txt b/ui/ui-animation/api/restricted_0.1.0-dev10.txt
index 398a5798..3e726b8 100644
--- a/ui/ui-animation/api/restricted_0.1.0-dev10.txt
+++ b/ui/ui-animation/api/restricted_0.1.0-dev10.txt
@@ -2,19 +2,19 @@
package androidx.ui.animation {
public final class AnimatedFloatModel extends androidx.animation.AnimatedFloat {
- ctor public AnimatedFloatModel(float value, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedFloatModel(float value, androidx.animation.AnimationClockObservable clock, float visibilityThreshold);
method public Float getValue();
method protected void setValue(float p);
}
public final class AnimatedValueEffectsKt {
method public static androidx.animation.AnimatedValue<androidx.ui.graphics.Color,androidx.animation.AnimationVector4D> animatedColor(androidx.ui.graphics.Color initVal, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
- method public static androidx.animation.AnimatedFloat animatedFloat(float initVal, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
- method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> animatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> converter, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
+ method public static androidx.animation.AnimatedFloat animatedFloat(float initVal, float visibilityThreshold = 0.01f, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
+ method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> animatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> converter, V? visibilityThreshold = null, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
}
public final class AnimatedValueModel<T, V extends androidx.animation.AnimationVector> extends androidx.animation.AnimatedValue<T,V> {
- ctor public AnimatedValueModel(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedValueModel(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V? visibilityThreshold);
method public T! getValue();
method protected void setValue(T? p);
}
diff --git a/ui/ui-animation/api/restricted_current.txt b/ui/ui-animation/api/restricted_current.txt
index 398a5798..3e726b8 100644
--- a/ui/ui-animation/api/restricted_current.txt
+++ b/ui/ui-animation/api/restricted_current.txt
@@ -2,19 +2,19 @@
package androidx.ui.animation {
public final class AnimatedFloatModel extends androidx.animation.AnimatedFloat {
- ctor public AnimatedFloatModel(float value, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedFloatModel(float value, androidx.animation.AnimationClockObservable clock, float visibilityThreshold);
method public Float getValue();
method protected void setValue(float p);
}
public final class AnimatedValueEffectsKt {
method public static androidx.animation.AnimatedValue<androidx.ui.graphics.Color,androidx.animation.AnimationVector4D> animatedColor(androidx.ui.graphics.Color initVal, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
- method public static androidx.animation.AnimatedFloat animatedFloat(float initVal, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
- method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> animatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> converter, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
+ method public static androidx.animation.AnimatedFloat animatedFloat(float initVal, float visibilityThreshold = 0.01f, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
+ method public static <T, V extends androidx.animation.AnimationVector> androidx.animation.AnimatedValue<T,V> animatedValue(T? initVal, androidx.animation.TwoWayConverter<T,V> converter, V? visibilityThreshold = null, androidx.animation.AnimationClockObservable clock = AnimationClockAmbient.current);
}
public final class AnimatedValueModel<T, V extends androidx.animation.AnimationVector> extends androidx.animation.AnimatedValue<T,V> {
- ctor public AnimatedValueModel(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock);
+ ctor public AnimatedValueModel(T! value, androidx.animation.TwoWayConverter<T,V> typeConverter, androidx.animation.AnimationClockObservable clock, V? visibilityThreshold);
method public T! getValue();
method protected void setValue(T? p);
}
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 de44e45..d0b2b88 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
@@ -21,6 +21,7 @@
import androidx.animation.AnimationClockObservable
import androidx.animation.AnimationVector
import androidx.animation.AnimationVector4D
+import androidx.animation.Spring
import androidx.animation.TwoWayConverter
import androidx.compose.Composable
import androidx.compose.Model
@@ -36,14 +37,19 @@
* @param initVal Initial value to set [AnimatedValue] to.
* @param converter A value type converter for transforming any type T to an animatable type (i.e.
* Floats, Vector2D, Vector3D, etc)
+ * @param visibilityThreshold Visibility threshold for the animatedValue to consider itself
+ * finished.
*/
@Composable
fun <T, V : AnimationVector> animatedValue(
initVal: T,
converter: TwoWayConverter<T, V>,
+ visibilityThreshold: V? = null,
clock: AnimationClockObservable = AnimationClockAmbient.current
): AnimatedValue<T, V> = clock.asDisposableClock().let { disposableClock ->
- remember(disposableClock) { AnimatedValueModel(initVal, converter, disposableClock) }
+ remember(disposableClock) {
+ AnimatedValueModel(initVal, converter, disposableClock, visibilityThreshold)
+ }
}
/**
@@ -56,9 +62,10 @@
@Composable
fun animatedFloat(
initVal: Float,
+ visibilityThreshold: Float = Spring.DefaultDisplacementThreshold,
clock: AnimationClockObservable = AnimationClockAmbient.current
): AnimatedFloat = clock.asDisposableClock().let { disposableClock ->
- remember(disposableClock) { AnimatedFloatModel(initVal, disposableClock) }
+ remember(disposableClock) { AnimatedFloatModel(initVal, disposableClock, visibilityThreshold) }
}
/**
@@ -95,8 +102,9 @@
class AnimatedValueModel<T, V : AnimationVector>(
override var value: T,
typeConverter: TwoWayConverter<T, V>,
- clock: AnimationClockObservable
-) : AnimatedValue<T, V>(typeConverter, clock)
+ clock: AnimationClockObservable,
+ visibilityThreshold: V? = null
+) : AnimatedValue<T, V>(typeConverter, clock, visibilityThreshold)
/**
* Model class for [AnimatedFloat]. This class tracks the value field change, so that composables
@@ -108,5 +116,6 @@
@Model
class AnimatedFloatModel(
override var value: Float,
- clock: AnimationClockObservable
-) : AnimatedFloat(clock)
\ No newline at end of file
+ clock: AnimationClockObservable,
+ visibilityThreshold: Float = Spring.DefaultDisplacementThreshold
+) : AnimatedFloat(clock, visibilityThreshold)
\ No newline at end of file
diff --git a/ui/ui-animation/src/main/java/androidx/ui/animation/SingleValueAnimation.kt b/ui/ui-animation/src/main/java/androidx/ui/animation/SingleValueAnimation.kt
index 5263ad7..7bf8141 100644
--- a/ui/ui-animation/src/main/java/androidx/ui/animation/SingleValueAnimation.kt
+++ b/ui/ui-animation/src/main/java/androidx/ui/animation/SingleValueAnimation.kt
@@ -89,10 +89,8 @@
animBuilder: AnimationBuilder<Color> = remember { PhysicsBuilder() },
endListener: ((Color) -> Unit)? = null
): Color {
- return animate(
- target, ColorToVectorConverter(target.colorSpace),
- animBuilder, endListener
- )
+ val converter = remember(target.colorSpace) { ColorToVectorConverter(target.colorSpace) }
+ return animate(target, converter, animBuilder, endListener)
}
/**
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/gestures/Scrollable.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/gestures/Scrollable.kt
index e3fc5c7..9739865 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/gestures/Scrollable.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/gestures/Scrollable.kt
@@ -20,6 +20,7 @@
import androidx.animation.AnimationClockObservable
import androidx.animation.AnimationClockObserver
import androidx.animation.AnimationEndReason
+import androidx.animation.Spring
import androidx.compose.Composable
import androidx.compose.mutableStateOf
import androidx.compose.onDispose
@@ -210,7 +211,7 @@
initial: Float,
clock: AnimationClockObservable,
private val onDelta: (Float) -> Float
-) : AnimatedFloat(clock) {
+) : AnimatedFloat(clock, Spring.DefaultDisplacementThreshold) {
override var value = initial
set(value) {
diff --git a/ui/ui-framework/api/api_lint.ignore b/ui/ui-framework/api/api_lint.ignore
index effbb61..1811601 100644
--- a/ui/ui-framework/api/api_lint.ignore
+++ b/ui/ui-framework/api/api_lint.ignore
@@ -1,8 +1,4 @@
// Baseline format: 1.0
-ArrayReturn: androidx.ui.core.LayoutKt#Layout(kotlin.jvm.functions.Function0<kotlin.Unit>[], androidx.ui.core.Modifier, kotlin.jvm.functions.Function4<? super androidx.ui.core.MeasureScope,? super androidx.ui.core.MultiComposableMeasurables,? super androidx.ui.core.Constraints,? super androidx.ui.core.LayoutDirection,? extends androidx.ui.core.MeasureScope.LayoutResult>) parameter #0:
- Method parameter should be Collection<Function0> (or subclass) instead of raw array; was `kotlin.jvm.functions.Function0<kotlin.Unit>[]`
-
-
CallbackName: androidx.ui.core.gesture.DragObserver:
Class should be named DragCallback
CallbackName: androidx.ui.core.gesture.LongPressDragObserver:
@@ -13,21 +9,9 @@
Class should be named ScaleCallback
-ContextFirst: androidx.compose.Compose#composeInto(androidx.ui.core.ComponentNode, android.content.Context, androidx.compose.CompositionReference, kotlin.jvm.functions.Function0<kotlin.Unit>) parameter #1:
- Context is distinct, so it must be the first argument (method `composeInto`)
-ContextFirst: androidx.compose.Compose#disposeComposition(androidx.ui.core.ComponentNode, android.content.Context, androidx.compose.CompositionReference) parameter #1:
- Context is distinct, so it must be the first argument (method `disposeComposition`)
ContextFirst: androidx.ui.core.WrapperKt#subcomposeInto(androidx.ui.core.ComponentNode, android.content.Context, androidx.compose.CompositionReference, kotlin.jvm.functions.Function0<kotlin.Unit>) parameter #1:
Context is distinct, so it must be the first argument (method `subcomposeInto`)
-DocumentExceptions: androidx.ui.core.MultiComposableMeasurables#get(kotlin.jvm.functions.Function0<kotlin.Unit>):
- Method MultiComposableMeasurables.get appears to be throwing java.lang.IllegalStateException; this should be listed in the documentation; see https://android.github.io/kotlin-guides/interop.html#document-exceptions
-
-
-KotlinOperator: androidx.ui.core.MultiComposableMeasurables#contains(androidx.ui.core.Measurable):
- Note that adding the `operator` keyword would allow calling this method using operator syntax
-
-
TopLevelBuilder: androidx.ui.graphics.vector.VectorAssetBuilder:
Builder should be defined as inner class: androidx.ui.graphics.vector.VectorAssetBuilder
diff --git a/ui/ui-graphics/api/api_lint.ignore b/ui/ui-graphics/api/api_lint.ignore
index fb19416..92e61bd 100644
--- a/ui/ui-graphics/api/api_lint.ignore
+++ b/ui/ui-graphics/api/api_lint.ignore
@@ -45,10 +45,6 @@
Method Vector4.set appears to be throwing java.lang.IllegalArgumentException; this should be listed in the documentation; see https://android.github.io/kotlin-guides/interop.html#document-exceptions
-KotlinOperator: androidx.ui.graphics.Path#contains(androidx.ui.geometry.Offset):
- Note that adding the `operator` keyword would allow calling this method using operator syntax
-
-
MissingBuildMethod: androidx.ui.graphics.vector.PathBuilder:
androidx.ui.graphics.vector.PathBuilder does not declare a `build()` method, but builder classes are expected to
diff --git a/ui/ui-platform/api/api_lint.ignore b/ui/ui-platform/api/api_lint.ignore
index 7a9539f..599ac2b 100644
--- a/ui/ui-platform/api/api_lint.ignore
+++ b/ui/ui-platform/api/api_lint.ignore
@@ -1,7 +1,3 @@
// Baseline format: 1.0
CallbackName: androidx.ui.core.ModelObserver:
Class should be named ModelCallback
-
-
-DocumentExceptions: androidx.ui.core.AndroidComposeView#onAttach(androidx.ui.core.ComponentNode):
- Method AndroidComposeView.onAttach appears to be throwing java.lang.IllegalStateException; this should be listed in the documentation; see https://android.github.io/kotlin-guides/interop.html#document-exceptions
diff --git a/ui/ui-util/api/api_lint.ignore b/ui/ui-util/api/api_lint.ignore
deleted file mode 100644
index cc585e2..0000000
--- a/ui/ui-util/api/api_lint.ignore
+++ /dev/null
@@ -1,9 +0,0 @@
-// Baseline format: 1.0
-NoByteOrShort: androidx.ui.util.Float16#Float16(short) parameter #0:
- Should avoid odd sized primitives; use `int` instead of `short` in parameter halfValue in androidx.ui.util.Float16(short halfValue)
-NoByteOrShort: androidx.ui.util.Float16#getHalfValue():
- Should avoid odd sized primitives; use `int` instead of `short` in method androidx.ui.util.Float16.getHalfValue()
-NoByteOrShort: androidx.ui.util.Float16#toByte():
- Should avoid odd sized primitives; use `int` instead of `byte` in method androidx.ui.util.Float16.toByte()
-NoByteOrShort: androidx.ui.util.Float16#toShort():
- Should avoid odd sized primitives; use `int` instead of `short` in method androidx.ui.util.Float16.toShort()