discord-jadx/app/src/main/java/c/c/a/b0/d.java

211 lines
5.8 KiB
Java

package c.c.a.b0;
import android.animation.Animator;
import android.graphics.PointF;
import android.view.Choreographer;
import androidx.annotation.FloatRange;
import androidx.annotation.MainThread;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import c.c.a.c;
/* compiled from: LottieValueAnimator */
public class d extends a implements Choreographer.FrameCallback {
public float k = 1.0f;
public boolean l = false;
public long m = 0;
public float n = 0.0f;
public int o = 0;
public float p = -2.14748365E9f;
public float q = 2.14748365E9f;
@Nullable
public c.c.a.d r;
@VisibleForTesting
/* renamed from: s reason: collision with root package name */
public boolean f257s = false;
@Override // android.animation.ValueAnimator, android.animation.Animator
@MainThread
public void cancel() {
for (Animator.AnimatorListener animatorListener : this.j) {
animatorListener.onAnimationCancel(this);
}
m();
}
@Override // android.view.Choreographer.FrameCallback
public void doFrame(long j) {
l();
c.c.a.d dVar = this.r;
if (dVar != null && this.f257s) {
long j2 = this.m;
long j3 = 0;
if (j2 != 0) {
j3 = j - j2;
}
float abs = ((float) j3) / ((1.0E9f / dVar.m) / Math.abs(this.k));
float f = this.n;
if (k()) {
abs = -abs;
}
float f2 = f + abs;
this.n = f2;
float j4 = j();
float i = i();
PointF pointF = f.a;
boolean z2 = !(f2 >= j4 && f2 <= i);
this.n = f.b(this.n, j(), i());
this.m = j;
f();
if (z2) {
if (getRepeatCount() == -1 || this.o < getRepeatCount()) {
for (Animator.AnimatorListener animatorListener : this.j) {
animatorListener.onAnimationRepeat(this);
}
this.o++;
if (getRepeatMode() == 2) {
this.l = !this.l;
this.k = -this.k;
} else {
this.n = k() ? i() : j();
}
this.m = j;
} else {
this.n = this.k < 0.0f ? j() : i();
m();
b(k());
}
}
if (this.r != null) {
float f3 = this.n;
if (f3 < this.p || f3 > this.q) {
throw new IllegalStateException(String.format("Frame must be [%f,%f]. It is %f", Float.valueOf(this.p), Float.valueOf(this.q), Float.valueOf(this.n)));
}
}
c.a("LottieValueAnimator#doFrame");
}
}
@MainThread
public void g() {
m();
b(k());
}
@Override // android.animation.ValueAnimator
@FloatRange(from = 0.0d, to = 1.0d)
public float getAnimatedFraction() {
float j;
float i;
float j2;
if (this.r == null) {
return 0.0f;
}
if (k()) {
j = i() - this.n;
i = i();
j2 = j();
} else {
j = this.n - j();
i = i();
j2 = j();
}
return j / (i - j2);
}
@Override // android.animation.ValueAnimator
public Object getAnimatedValue() {
return Float.valueOf(h());
}
@Override // android.animation.ValueAnimator, android.animation.Animator
public long getDuration() {
c.c.a.d dVar = this.r;
if (dVar == null) {
return 0;
}
return (long) dVar.b();
}
@FloatRange(from = 0.0d, to = 1.0d)
public float h() {
c.c.a.d dVar = this.r;
if (dVar == null) {
return 0.0f;
}
float f = this.n;
float f2 = dVar.k;
return (f - f2) / (dVar.l - f2);
}
public float i() {
c.c.a.d dVar = this.r;
if (dVar == null) {
return 0.0f;
}
float f = this.q;
return f == 2.14748365E9f ? dVar.l : f;
}
@Override // android.animation.ValueAnimator, android.animation.Animator
public boolean isRunning() {
return this.f257s;
}
public float j() {
c.c.a.d dVar = this.r;
if (dVar == null) {
return 0.0f;
}
float f = this.p;
return f == -2.14748365E9f ? dVar.k : f;
}
public final boolean k() {
return this.k < 0.0f;
}
public void l() {
if (this.f257s) {
Choreographer.getInstance().removeFrameCallback(this);
Choreographer.getInstance().postFrameCallback(this);
}
}
@MainThread
public void m() {
Choreographer.getInstance().removeFrameCallback(this);
this.f257s = false;
}
public void n(float f) {
if (this.n != f) {
this.n = f.b(f, j(), i());
this.m = 0;
f();
}
}
public void o(float f, float f2) {
if (f <= f2) {
c.c.a.d dVar = this.r;
float f3 = dVar == null ? -3.4028235E38f : dVar.k;
float f4 = dVar == null ? Float.MAX_VALUE : dVar.l;
this.p = f.b(f, f3, f4);
this.q = f.b(f2, f3, f4);
n((float) ((int) f.b(this.n, f, f2)));
return;
}
throw new IllegalArgumentException(String.format("minFrame (%s) must be <= maxFrame (%s)", Float.valueOf(f), Float.valueOf(f2)));
}
@Override // android.animation.ValueAnimator
public void setRepeatMode(int i) {
super.setRepeatMode(i);
if (i != 2 && this.l) {
this.l = false;
this.k = -this.k;
}
}
}