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

240 lines
7.2 KiB
Java

package b.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 b.f.g.e.e;
import java.util.Objects;
/* compiled from: AnimatedDrawable2 */
public class a extends Drawable implements Animatable, b.f.f.a.a {
public static final Class<?> j = a.class;
public static final b k = new b();
public b.f.h.a.a.a l;
public b.f.h.a.e.a m;
public volatile boolean n;
public long o;
public long p;
public long q;
public int r;
/* renamed from: s reason: collision with root package name */
public long f529s;
public long t;
public int u;
public long v;
public int w;
/* renamed from: x reason: collision with root package name */
public volatile b f530x;
/* renamed from: y reason: collision with root package name */
public e f531y;
/* renamed from: z reason: collision with root package name */
public final Runnable f532z;
/* compiled from: AnimatedDrawable2 */
/* renamed from: b.f.h.a.c.a$a reason: collision with other inner class name */
public class RunnableC0062a implements Runnable {
public RunnableC0062a() {
}
@Override // java.lang.Runnable
public void run() {
a aVar = a.this;
aVar.unscheduleSelf(aVar.f532z);
a.this.invalidateSelf();
}
}
public a() {
this(null);
}
public a(b.f.h.a.a.a aVar) {
this.v = 8;
this.f530x = k;
this.f532z = new RunnableC0062a();
this.l = aVar;
this.m = aVar == null ? null : new b.f.h.a.e.a(aVar);
}
@Override // b.f.f.a.a
public void a() {
b.f.h.a.a.a aVar = this.l;
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.l == null || this.m == null)) {
long uptimeMillis = SystemClock.uptimeMillis();
long max = this.n ? (uptimeMillis - this.o) + 0 : Math.max(this.p, 0L);
b.f.h.a.e.a aVar = this.m;
long b2 = aVar.b();
boolean z2 = true;
int a = b2 == 0 ? aVar.a(0) : ((aVar.a.b() == 0) || max / b2 < ((long) aVar.a.b())) ? aVar.a(max % b2) : -1;
if (a == -1) {
a = this.l.a() - 1;
Objects.requireNonNull(this.f530x);
this.n = false;
} else if (a == 0 && this.r != -1 && uptimeMillis >= this.q) {
Objects.requireNonNull(this.f530x);
}
boolean j3 = this.l.j(this, canvas, a);
if (j3) {
Objects.requireNonNull(this.f530x);
this.r = a;
}
if (!j3) {
this.w++;
b.f.d.e.a.h(2);
}
long uptimeMillis2 = SystemClock.uptimeMillis();
if (this.n) {
b.f.h.a.e.a aVar2 = this.m;
long j4 = uptimeMillis2 - this.o;
long b3 = aVar2.b();
if (b3 != 0) {
if (aVar2.a.b() != 0) {
z2 = false;
}
if (z2 || j4 / aVar2.b() < ((long) aVar2.a.b())) {
long j5 = j4 % b3;
int a2 = aVar2.a.a();
long j6 = 0;
for (int i = 0; i < a2 && j6 <= j5; i++) {
j6 += (long) aVar2.a.e(i);
}
j2 = (j6 - j5) + j4;
if (j2 == -1) {
long j7 = this.o + j2 + this.v;
this.q = j7;
scheduleSelf(this.f532z, j7);
} else {
Objects.requireNonNull(this.f530x);
this.n = false;
}
}
}
j2 = -1;
if (j2 == -1) {
}
}
this.p = max;
}
}
@Override // android.graphics.drawable.Drawable
public int getIntrinsicHeight() {
b.f.h.a.a.a aVar = this.l;
return aVar == null ? super.getIntrinsicHeight() : aVar.g();
}
@Override // android.graphics.drawable.Drawable
public int getIntrinsicWidth() {
b.f.h.a.a.a aVar = this.l;
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.n;
}
@Override // android.graphics.drawable.Drawable
public void onBoundsChange(Rect rect) {
super.onBoundsChange(rect);
b.f.h.a.a.a aVar = this.l;
if (aVar != null) {
aVar.h(rect);
}
}
@Override // android.graphics.drawable.Drawable
public boolean onLevelChange(int i) {
if (this.n) {
return false;
}
long j2 = (long) i;
if (this.p == j2) {
return false;
}
this.p = j2;
invalidateSelf();
return true;
}
@Override // android.graphics.drawable.Drawable
public void setAlpha(int i) {
if (this.f531y == null) {
this.f531y = new e();
}
this.f531y.a = i;
b.f.h.a.a.a aVar = this.l;
if (aVar != null) {
aVar.f(i);
}
}
@Override // android.graphics.drawable.Drawable
public void setColorFilter(ColorFilter colorFilter) {
if (this.f531y == null) {
this.f531y = new e();
}
e eVar = this.f531y;
eVar.c = colorFilter;
eVar.f503b = colorFilter != null;
b.f.h.a.a.a aVar = this.l;
if (aVar != null) {
aVar.d(colorFilter);
}
}
@Override // android.graphics.drawable.Animatable
public void start() {
b.f.h.a.a.a aVar;
if (!this.n && (aVar = this.l) != null && aVar.a() > 1) {
this.n = true;
long uptimeMillis = SystemClock.uptimeMillis();
long j2 = uptimeMillis - this.f529s;
this.o = j2;
this.q = j2;
this.p = uptimeMillis - this.t;
this.r = this.u;
invalidateSelf();
Objects.requireNonNull(this.f530x);
}
}
@Override // android.graphics.drawable.Animatable
public void stop() {
if (this.n) {
long uptimeMillis = SystemClock.uptimeMillis();
this.f529s = uptimeMillis - this.o;
this.t = uptimeMillis - this.p;
this.u = this.r;
this.n = false;
this.o = 0;
this.q = 0;
this.p = -1;
this.r = -1;
unscheduleSelf(this.f532z);
Objects.requireNonNull(this.f530x);
}
}
}