mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-14 01:47:17 +01:00
134 lines
4.8 KiB
Java
134 lines
4.8 KiB
Java
package androidx.dynamicanimation.animation;
|
|
|
|
import androidx.annotation.FloatRange;
|
|
import androidx.dynamicanimation.animation.DynamicAnimation;
|
|
import rx.Single$$ExternalSyntheticBUOutline0;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes14.dex */
|
|
public final class FlingAnimation extends DynamicAnimation<FlingAnimation> {
|
|
private final DragForce mFlingForce;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static final class DragForce implements Force {
|
|
private static final float DEFAULT_FRICTION = -4.2f;
|
|
private static final float VELOCITY_THRESHOLD_MULTIPLIER = 62.5f;
|
|
private float mFriction = DEFAULT_FRICTION;
|
|
private final DynamicAnimation.MassState mMassState = new DynamicAnimation.MassState();
|
|
private float mVelocityThreshold;
|
|
|
|
@Override // androidx.dynamicanimation.animation.Force
|
|
public float getAcceleration(float f, float f2) {
|
|
return f2 * this.mFriction;
|
|
}
|
|
|
|
public float getFrictionScalar() {
|
|
return this.mFriction / DEFAULT_FRICTION;
|
|
}
|
|
|
|
@Override // androidx.dynamicanimation.animation.Force
|
|
public boolean isAtEquilibrium(float f, float f2) {
|
|
return Math.abs(f2) < this.mVelocityThreshold;
|
|
}
|
|
|
|
public void setFrictionScalar(float f) {
|
|
this.mFriction = f * DEFAULT_FRICTION;
|
|
}
|
|
|
|
public void setValueThreshold(float f) {
|
|
this.mVelocityThreshold = f * VELOCITY_THRESHOLD_MULTIPLIER;
|
|
}
|
|
|
|
public DynamicAnimation.MassState updateValueAndVelocity(float f, float f2, long j) {
|
|
this.mMassState.mVelocity = (float) (Math.exp((j / 1000.0f) * this.mFriction) * f2);
|
|
DynamicAnimation.MassState massState = this.mMassState;
|
|
float f3 = massState.mVelocity;
|
|
float f4 = ((f3 - f2) / this.mFriction) + f;
|
|
massState.mValue = f4;
|
|
if (isAtEquilibrium(f4, f3)) {
|
|
this.mMassState.mVelocity = 0.0f;
|
|
}
|
|
return this.mMassState;
|
|
}
|
|
}
|
|
|
|
public FlingAnimation(FloatValueHolder floatValueHolder) {
|
|
super(floatValueHolder);
|
|
DragForce dragForce = new DragForce();
|
|
this.mFlingForce = dragForce;
|
|
dragForce.setValueThreshold(getValueThreshold());
|
|
}
|
|
|
|
@Override // androidx.dynamicanimation.animation.DynamicAnimation
|
|
public float getAcceleration(float f, float f2) {
|
|
return this.mFlingForce.getAcceleration(f, f2);
|
|
}
|
|
|
|
public float getFriction() {
|
|
return this.mFlingForce.getFrictionScalar();
|
|
}
|
|
|
|
@Override // androidx.dynamicanimation.animation.DynamicAnimation
|
|
public boolean isAtEquilibrium(float f, float f2) {
|
|
return f >= this.mMaxValue || f <= this.mMinValue || this.mFlingForce.isAtEquilibrium(f, f2);
|
|
}
|
|
|
|
public FlingAnimation setFriction(@FloatRange(from = 0.0d, fromInclusive = false) float f) {
|
|
if (f > 0.0f) {
|
|
this.mFlingForce.setFrictionScalar(f);
|
|
return this;
|
|
}
|
|
Single$$ExternalSyntheticBUOutline0.m$3("Friction must be positive");
|
|
return null;
|
|
}
|
|
|
|
@Override // androidx.dynamicanimation.animation.DynamicAnimation
|
|
public void setValueThreshold(float f) {
|
|
this.mFlingForce.setValueThreshold(f);
|
|
}
|
|
|
|
@Override // androidx.dynamicanimation.animation.DynamicAnimation
|
|
public boolean updateValueAndVelocity(long j) {
|
|
DynamicAnimation.MassState updateValueAndVelocity = this.mFlingForce.updateValueAndVelocity(this.mValue, this.mVelocity, j);
|
|
float f = updateValueAndVelocity.mValue;
|
|
this.mValue = f;
|
|
float f2 = updateValueAndVelocity.mVelocity;
|
|
this.mVelocity = f2;
|
|
float f3 = this.mMinValue;
|
|
if (f < f3) {
|
|
this.mValue = f3;
|
|
return true;
|
|
}
|
|
float f4 = this.mMaxValue;
|
|
if (f <= f4) {
|
|
return isAtEquilibrium(f, f2);
|
|
}
|
|
this.mValue = f4;
|
|
return true;
|
|
}
|
|
|
|
@Override // androidx.dynamicanimation.animation.DynamicAnimation
|
|
public FlingAnimation setMaxValue(float f) {
|
|
super.setMaxValue(f);
|
|
return this;
|
|
}
|
|
|
|
@Override // androidx.dynamicanimation.animation.DynamicAnimation
|
|
public FlingAnimation setMinValue(float f) {
|
|
super.setMinValue(f);
|
|
return this;
|
|
}
|
|
|
|
@Override // androidx.dynamicanimation.animation.DynamicAnimation
|
|
public FlingAnimation setStartVelocity(float f) {
|
|
super.setStartVelocity(f);
|
|
return this;
|
|
}
|
|
|
|
public <K> FlingAnimation(K k, FloatPropertyCompat<K> floatPropertyCompat) {
|
|
super(k, floatPropertyCompat);
|
|
DragForce dragForce = new DragForce();
|
|
this.mFlingForce = dragForce;
|
|
dragForce.setValueThreshold(getValueThreshold());
|
|
}
|
|
}
|