package s6; 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 e6.n; import java.nio.ByteBuffer; import java.util.List; import s6.g; /* loaded from: classes2.dex */ public class c extends Drawable implements g.a, Animatable { /* renamed from: a, reason: collision with root package name */ private final a f14019a; /* renamed from: b, reason: collision with root package name */ private boolean f14020b; /* renamed from: c, reason: collision with root package name */ private boolean f14021c; /* renamed from: d, reason: collision with root package name */ private boolean f14022d; /* renamed from: e, reason: collision with root package name */ private boolean f14023e; /* renamed from: f, reason: collision with root package name */ private int f14024f; /* renamed from: g, reason: collision with root package name */ private int f14025g; /* renamed from: h, reason: collision with root package name */ private boolean f14026h; /* renamed from: i, reason: collision with root package name */ private Paint f14027i; /* renamed from: j, reason: collision with root package name */ private Rect f14028j; /* renamed from: k, reason: collision with root package name */ private List f14029k; static final class a extends Drawable.ConstantState { /* renamed from: a, reason: collision with root package name */ final g f14030a; a(g gVar) { this.f14030a = gVar; } @Override // android.graphics.drawable.Drawable.ConstantState public int getChangingConfigurations() { return 0; } @Override // android.graphics.drawable.Drawable.ConstantState public Drawable newDrawable() { return new c(this); } @Override // android.graphics.drawable.Drawable.ConstantState public Drawable newDrawable(Resources resources) { return newDrawable(); } } public c(Context context, d6.a aVar, n nVar, int i10, int i11, Bitmap bitmap) { this(new a(new g(b6.e.m(context), aVar, i10, i11, nVar, 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 c() { if (this.f14028j == null) { this.f14028j = new Rect(); } return this.f14028j; } private Paint d() { if (this.f14027i == null) { this.f14027i = new Paint(2); } return this.f14027i; } private void e() { List list = this.f14029k; if (list == null || list.size() <= 0) { return; } m.a(this.f14029k.get(0)); throw null; } private void f() { this.f14024f = 0; } private void g() { b7.j.a(!this.f14022d, "You cannot start a recycled Drawable. Ensure thatyou clear any references to the Drawable when clearing the corresponding request."); if (this.f14019a.f14030a.k() != 1) { if (this.f14020b) { return; } this.f14020b = true; this.f14019a.f14030a.d(this); } invalidateSelf(); } private void h() { this.f14020b = false; this.f14019a.f14030a.g(this); } @Override // s6.g.a public void a() { if (b() == null) { stop(); invalidateSelf(); return; } invalidateSelf(); if (l() == k() - 1) { this.f14024f++; } int i10 = this.f14025g; if (i10 == -1 || this.f14024f < i10) { return; } e(); stop(); } @Override // android.graphics.drawable.Drawable public void draw(Canvas canvas) { if (this.f14022d) { return; } if (this.f14026h) { Gravity.apply(119, getIntrinsicWidth(), getIntrinsicHeight(), getBounds(), c()); this.f14026h = false; } canvas.drawBitmap(this.f14019a.f14030a.h(), (Rect) null, c(), d()); } @Override // android.graphics.drawable.Drawable public Drawable.ConstantState getConstantState() { return this.f14019a; } @Override // android.graphics.drawable.Drawable public int getIntrinsicHeight() { return this.f14019a.f14030a.m(); } @Override // android.graphics.drawable.Drawable public int getIntrinsicWidth() { return this.f14019a.f14030a.o(); } @Override // android.graphics.drawable.Drawable public int getOpacity() { return -2; } public ByteBuffer i() { return this.f14019a.f14030a.f(); } @Override // android.graphics.drawable.Animatable public boolean isRunning() { return this.f14020b; } public Bitmap j() { return this.f14019a.f14030a.j(); } public int k() { return this.f14019a.f14030a.k(); } public int l() { return this.f14019a.f14030a.i(); } public int m() { return this.f14019a.f14030a.n(); } public void n() { this.f14022d = true; this.f14019a.f14030a.b(); } public void o(n nVar, Bitmap bitmap) { this.f14019a.f14030a.c(nVar, bitmap); } @Override // android.graphics.drawable.Drawable protected void onBoundsChange(Rect rect) { super.onBoundsChange(rect); this.f14026h = true; } @Override // android.graphics.drawable.Drawable public void setAlpha(int i10) { d().setAlpha(i10); } @Override // android.graphics.drawable.Drawable public void setColorFilter(ColorFilter colorFilter) { d().setColorFilter(colorFilter); } @Override // android.graphics.drawable.Drawable public boolean setVisible(boolean z10, boolean z11) { b7.j.a(!this.f14022d, "Cannot change the visibility of a recycled resource. Ensure that you unset the Drawable from your View before changing the View's visibility."); this.f14023e = z10; if (!z10) { h(); } else if (this.f14021c) { g(); } return super.setVisible(z10, z11); } @Override // android.graphics.drawable.Animatable public void start() { this.f14021c = true; f(); if (this.f14023e) { g(); } } @Override // android.graphics.drawable.Animatable public void stop() { this.f14021c = false; h(); } c(a aVar) { this.f14023e = true; this.f14025g = -1; this.f14019a = (a) b7.j.d(aVar); } }