discord-jadx/app/src/main/java/c/f/h/a/c/a.java

238 lines
7.1 KiB
Java

package c.f.h.a.c;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Rect;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
import c.f.g.e.e;
import java.util.Objects;
/* compiled from: AnimatedDrawable2 */
public class a extends Drawable implements Animatable, c.f.f.a.a {
public static final Class<?> i = a.class;
public static final b j = new b();
public c.f.h.a.a.a k;
public c.f.h.a.e.a l;
public volatile boolean m;
public long n;
public long o;
public long p;
public int q;
public long r;
/* renamed from: s reason: collision with root package name */
public long f418s;
public int t;
public long u;
public int v;
public volatile b w;
/* renamed from: x reason: collision with root package name */
public e f419x;
/* renamed from: y reason: collision with root package name */
public final Runnable f420y;
/* compiled from: AnimatedDrawable2 */
/* renamed from: c.f.h.a.c.a$a reason: collision with other inner class name */
public class RunnableC0063a implements Runnable {
public RunnableC0063a() {
}
@Override // java.lang.Runnable
public void run() {
a aVar = a.this;
aVar.unscheduleSelf(aVar.f420y);
a.this.invalidateSelf();
}
}
public a() {
this(null);
}
public a(c.f.h.a.a.a aVar) {
this.u = 8;
this.w = j;
this.f420y = new RunnableC0063a();
this.k = aVar;
this.l = aVar == null ? null : new c.f.h.a.e.a(aVar);
}
@Override // c.f.f.a.a
public void a() {
c.f.h.a.a.a aVar = this.k;
if (aVar != null) {
aVar.clear();
}
}
/* JADX WARNING: Removed duplicated region for block: B:52:0x00f4 */
/* JADX WARNING: Removed duplicated region for block: B:53:0x0104 */
@Override // android.graphics.drawable.Drawable
public void draw(Canvas canvas) {
long j2;
if (!(this.k == null || this.l == null)) {
long uptimeMillis = SystemClock.uptimeMillis();
long max = this.m ? (uptimeMillis - this.n) + 0 : Math.max(this.o, 0L);
c.f.h.a.e.a aVar = this.l;
long b = aVar.b();
boolean z2 = true;
int a = b == 0 ? aVar.a(0) : ((aVar.a.b() == 0) || max / b < ((long) aVar.a.b())) ? aVar.a(max % b) : -1;
if (a == -1) {
a = this.k.a() - 1;
Objects.requireNonNull(this.w);
this.m = false;
} else if (a == 0 && this.q != -1 && uptimeMillis >= this.p) {
Objects.requireNonNull(this.w);
}
boolean j3 = this.k.j(this, canvas, a);
if (j3) {
Objects.requireNonNull(this.w);
this.q = a;
}
if (!j3) {
this.v++;
c.f.d.e.a.h(2);
}
long uptimeMillis2 = SystemClock.uptimeMillis();
if (this.m) {
c.f.h.a.e.a aVar2 = this.l;
long j4 = uptimeMillis2 - this.n;
long b2 = aVar2.b();
if (b2 != 0) {
if (aVar2.a.b() != 0) {
z2 = false;
}
if (z2 || j4 / aVar2.b() < ((long) aVar2.a.b())) {
long j5 = j4 % b2;
int a2 = aVar2.a.a();
long j6 = 0;
for (int i2 = 0; i2 < a2 && j6 <= j5; i2++) {
j6 += (long) aVar2.a.e(i2);
}
j2 = (j6 - j5) + j4;
if (j2 == -1) {
long j7 = this.n + j2 + this.u;
this.p = j7;
scheduleSelf(this.f420y, j7);
} else {
Objects.requireNonNull(this.w);
this.m = false;
}
}
}
j2 = -1;
if (j2 == -1) {
}
}
this.o = max;
}
}
@Override // android.graphics.drawable.Drawable
public int getIntrinsicHeight() {
c.f.h.a.a.a aVar = this.k;
return aVar == null ? super.getIntrinsicHeight() : aVar.g();
}
@Override // android.graphics.drawable.Drawable
public int getIntrinsicWidth() {
c.f.h.a.a.a aVar = this.k;
return aVar == null ? super.getIntrinsicWidth() : aVar.i();
}
@Override // android.graphics.drawable.Drawable
public int getOpacity() {
return -3;
}
@Override // android.graphics.drawable.Animatable
public boolean isRunning() {
return this.m;
}
@Override // android.graphics.drawable.Drawable
public void onBoundsChange(Rect rect) {
super.onBoundsChange(rect);
c.f.h.a.a.a aVar = this.k;
if (aVar != null) {
aVar.h(rect);
}
}
@Override // android.graphics.drawable.Drawable
public boolean onLevelChange(int i2) {
if (this.m) {
return false;
}
long j2 = (long) i2;
if (this.o == j2) {
return false;
}
this.o = j2;
invalidateSelf();
return true;
}
@Override // android.graphics.drawable.Drawable
public void setAlpha(int i2) {
if (this.f419x == null) {
this.f419x = new e();
}
this.f419x.a = i2;
c.f.h.a.a.a aVar = this.k;
if (aVar != null) {
aVar.f(i2);
}
}
@Override // android.graphics.drawable.Drawable
public void setColorFilter(ColorFilter colorFilter) {
if (this.f419x == null) {
this.f419x = new e();
}
e eVar = this.f419x;
eVar.f395c = colorFilter;
eVar.b = true;
c.f.h.a.a.a aVar = this.k;
if (aVar != null) {
aVar.d(colorFilter);
}
}
@Override // android.graphics.drawable.Animatable
public void start() {
c.f.h.a.a.a aVar;
if (!this.m && (aVar = this.k) != null && aVar.a() > 1) {
this.m = true;
long uptimeMillis = SystemClock.uptimeMillis();
long j2 = uptimeMillis - this.r;
this.n = j2;
this.p = j2;
this.o = uptimeMillis - this.f418s;
this.q = this.t;
invalidateSelf();
Objects.requireNonNull(this.w);
}
}
@Override // android.graphics.drawable.Animatable
public void stop() {
if (this.m) {
long uptimeMillis = SystemClock.uptimeMillis();
this.r = uptimeMillis - this.n;
this.f418s = uptimeMillis - this.o;
this.t = this.q;
this.m = false;
this.n = 0;
this.p = 0;
this.o = -1;
this.q = -1;
unscheduleSelf(this.f420y);
Objects.requireNonNull(this.w);
}
}
}