package d2; import android.content.Context; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.drawable.Animatable; import android.graphics.drawable.Drawable; import android.view.Gravity; import androidx.appcompat.app.m; import d2.g; import java.nio.ByteBuffer; import java.util.List; import q1.l; /* loaded from: classes.dex */ public class c extends Drawable implements g.b, Animatable { /* renamed from: a, reason: collision with root package name */ private final a f9063a; /* renamed from: b, reason: collision with root package name */ private boolean f9064b; /* renamed from: c, reason: collision with root package name */ private boolean f9065c; /* renamed from: d, reason: collision with root package name */ private boolean f9066d; /* renamed from: e, reason: collision with root package name */ private boolean f9067e; /* renamed from: f, reason: collision with root package name */ private int f9068f; /* renamed from: g, reason: collision with root package name */ private int f9069g; /* renamed from: h, reason: collision with root package name */ private boolean f9070h; /* renamed from: i, reason: collision with root package name */ private Paint f9071i; /* renamed from: j, reason: collision with root package name */ private Rect f9072j; /* renamed from: k, reason: collision with root package name */ private List f9073k; static final class a extends Drawable.ConstantState { /* renamed from: a, reason: collision with root package name */ final g f9074a; a(g gVar) { this.f9074a = gVar; } @Override // android.graphics.drawable.Drawable.ConstantState public int getChangingConfigurations() { return 0; } @Override // android.graphics.drawable.Drawable.ConstantState public Drawable newDrawable(Resources resources) { return newDrawable(); } @Override // android.graphics.drawable.Drawable.ConstantState public Drawable newDrawable() { return new c(this); } } public c(Context context, p1.a aVar, l lVar, int i10, int i11, Bitmap bitmap) { this(new a(new g(com.bumptech.glide.b.c(context), aVar, i10, i11, lVar, bitmap))); } /* JADX WARN: Multi-variable type inference failed */ private Drawable.Callback b() { Drawable.Callback callback = getCallback(); while (callback instanceof Drawable) { callback = ((Drawable) callback).getCallback(); } return callback; } private Rect d() { if (this.f9072j == null) { this.f9072j = new Rect(); } return this.f9072j; } private Paint h() { if (this.f9071i == null) { this.f9071i = new Paint(2); } return this.f9071i; } private void j() { List list = this.f9073k; if (list == null || list.size() <= 0) { return; } m.a(this.f9073k.get(0)); throw null; } private void l() { this.f9068f = 0; } private void n() { m2.j.a(!this.f9066d, "You cannot start a recycled Drawable. Ensure thatyou clear any references to the Drawable when clearing the corresponding request."); if (this.f9063a.f9074a.f() == 1) { invalidateSelf(); } else { if (this.f9064b) { return; } this.f9064b = true; this.f9063a.f9074a.r(this); invalidateSelf(); } } private void o() { this.f9064b = false; this.f9063a.f9074a.s(this); } @Override // d2.g.b public void a() { if (b() == null) { stop(); invalidateSelf(); return; } invalidateSelf(); if (g() == f() - 1) { this.f9068f++; } int i10 = this.f9069g; if (i10 == -1 || this.f9068f < i10) { return; } j(); stop(); } public ByteBuffer c() { return this.f9063a.f9074a.b(); } @Override // android.graphics.drawable.Drawable public void draw(Canvas canvas) { if (this.f9066d) { return; } if (this.f9070h) { Gravity.apply(119, getIntrinsicWidth(), getIntrinsicHeight(), getBounds(), d()); this.f9070h = false; } canvas.drawBitmap(this.f9063a.f9074a.c(), (Rect) null, d(), h()); } public Bitmap e() { return this.f9063a.f9074a.e(); } public int f() { return this.f9063a.f9074a.f(); } public int g() { return this.f9063a.f9074a.d(); } @Override // android.graphics.drawable.Drawable public Drawable.ConstantState getConstantState() { return this.f9063a; } @Override // android.graphics.drawable.Drawable public int getIntrinsicHeight() { return this.f9063a.f9074a.h(); } @Override // android.graphics.drawable.Drawable public int getIntrinsicWidth() { return this.f9063a.f9074a.k(); } @Override // android.graphics.drawable.Drawable public int getOpacity() { return -2; } public int i() { return this.f9063a.f9074a.j(); } @Override // android.graphics.drawable.Animatable public boolean isRunning() { return this.f9064b; } public void k() { this.f9066d = true; this.f9063a.f9074a.a(); } public void m(l lVar, Bitmap bitmap) { this.f9063a.f9074a.o(lVar, bitmap); } @Override // android.graphics.drawable.Drawable protected void onBoundsChange(Rect rect) { super.onBoundsChange(rect); this.f9070h = true; } @Override // android.graphics.drawable.Drawable public void setAlpha(int i10) { h().setAlpha(i10); } @Override // android.graphics.drawable.Drawable public void setColorFilter(ColorFilter colorFilter) { h().setColorFilter(colorFilter); } @Override // android.graphics.drawable.Drawable public boolean setVisible(boolean z10, boolean z11) { m2.j.a(!this.f9066d, "Cannot change the visibility of a recycled resource. Ensure that you unset the Drawable from your View before changing the View's visibility."); this.f9067e = z10; if (!z10) { o(); } else if (this.f9065c) { n(); } return super.setVisible(z10, z11); } @Override // android.graphics.drawable.Animatable public void start() { this.f9065c = true; l(); if (this.f9067e) { n(); } } @Override // android.graphics.drawable.Animatable public void stop() { this.f9065c = false; o(); } c(a aVar) { this.f9067e = true; this.f9069g = -1; this.f9063a = (a) m2.j.d(aVar); } }