package i2; import android.content.Context; import android.graphics.drawable.Drawable; import android.util.Log; import androidx.appcompat.app.m; import com.bumptech.glide.c; import com.google.android.gms.ads.RequestConfiguration; import java.util.Iterator; import java.util.List; import java.util.concurrent.Executor; import s1.k; import s1.q; import s1.v; /* loaded from: classes.dex */ public final class h implements c, j2.g, g { private static final boolean C = Log.isLoggable("Request", 2); private boolean A; private RuntimeException B; /* renamed from: a, reason: collision with root package name */ private final String f10829a; /* renamed from: b, reason: collision with root package name */ private final n2.c f10830b; /* renamed from: c, reason: collision with root package name */ private final Object f10831c; /* renamed from: d, reason: collision with root package name */ private final d f10832d; /* renamed from: e, reason: collision with root package name */ private final Context f10833e; /* renamed from: f, reason: collision with root package name */ private final com.bumptech.glide.d f10834f; /* renamed from: g, reason: collision with root package name */ private final Object f10835g; /* renamed from: h, reason: collision with root package name */ private final Class f10836h; /* renamed from: i, reason: collision with root package name */ private final i2.a f10837i; /* renamed from: j, reason: collision with root package name */ private final int f10838j; /* renamed from: k, reason: collision with root package name */ private final int f10839k; /* renamed from: l, reason: collision with root package name */ private final com.bumptech.glide.g f10840l; /* renamed from: m, reason: collision with root package name */ private final j2.h f10841m; /* renamed from: n, reason: collision with root package name */ private final List f10842n; /* renamed from: o, reason: collision with root package name */ private final k2.c f10843o; /* renamed from: p, reason: collision with root package name */ private final Executor f10844p; /* renamed from: q, reason: collision with root package name */ private v f10845q; /* renamed from: r, reason: collision with root package name */ private k.d f10846r; /* renamed from: s, reason: collision with root package name */ private long f10847s; /* renamed from: t, reason: collision with root package name */ private volatile k f10848t; /* renamed from: u, reason: collision with root package name */ private a f10849u; /* renamed from: v, reason: collision with root package name */ private Drawable f10850v; /* renamed from: w, reason: collision with root package name */ private Drawable f10851w; /* renamed from: x, reason: collision with root package name */ private Drawable f10852x; /* renamed from: y, reason: collision with root package name */ private int f10853y; /* renamed from: z, reason: collision with root package name */ private int f10854z; private enum a { PENDING, RUNNING, WAITING_FOR_SIZE, COMPLETE, FAILED, CLEARED } private h(Context context, com.bumptech.glide.d dVar, Object obj, Object obj2, Class cls, i2.a aVar, int i10, int i11, com.bumptech.glide.g gVar, j2.h hVar, e eVar, List list, d dVar2, k kVar, k2.c cVar, Executor executor) { this.f10829a = C ? String.valueOf(super.hashCode()) : null; this.f10830b = n2.c.a(); this.f10831c = obj; this.f10833e = context; this.f10834f = dVar; this.f10835g = obj2; this.f10836h = cls; this.f10837i = aVar; this.f10838j = i10; this.f10839k = i11; this.f10840l = gVar; this.f10841m = hVar; this.f10842n = list; this.f10832d = dVar2; this.f10848t = kVar; this.f10843o = cVar; this.f10844p = executor; this.f10849u = a.PENDING; if (this.B == null && dVar.g().a(c.C0064c.class)) { this.B = new RuntimeException("Glide request origin trace"); } } private void A() { if (l()) { Drawable p10 = this.f10835g == null ? p() : null; if (p10 == null) { p10 = o(); } if (p10 == null) { p10 = q(); } this.f10841m.a(p10); } } private void j() { if (this.A) { throw new IllegalStateException("You can't start or clear loads in RequestListener or Target callbacks. If you're trying to start a fallback request when a load fails, use RequestBuilder#error(RequestBuilder). Otherwise consider posting your into() or clear() calls to the main thread using a Handler instead."); } } private boolean k() { d dVar = this.f10832d; return dVar == null || dVar.j(this); } private boolean l() { d dVar = this.f10832d; return dVar == null || dVar.f(this); } private boolean m() { d dVar = this.f10832d; return dVar == null || dVar.k(this); } private void n() { j(); this.f10830b.c(); this.f10841m.h(this); k.d dVar = this.f10846r; if (dVar != null) { dVar.a(); this.f10846r = null; } } private Drawable o() { if (this.f10850v == null) { Drawable k10 = this.f10837i.k(); this.f10850v = k10; if (k10 == null && this.f10837i.j() > 0) { this.f10850v = s(this.f10837i.j()); } } return this.f10850v; } private Drawable p() { if (this.f10852x == null) { Drawable l10 = this.f10837i.l(); this.f10852x = l10; if (l10 == null && this.f10837i.m() > 0) { this.f10852x = s(this.f10837i.m()); } } return this.f10852x; } private Drawable q() { if (this.f10851w == null) { Drawable r10 = this.f10837i.r(); this.f10851w = r10; if (r10 == null && this.f10837i.s() > 0) { this.f10851w = s(this.f10837i.s()); } } return this.f10851w; } private boolean r() { d dVar = this.f10832d; return dVar == null || !dVar.b().a(); } private Drawable s(int i10) { return b2.a.a(this.f10834f, i10, this.f10837i.x() != null ? this.f10837i.x() : this.f10833e.getTheme()); } private void t(String str) { Log.v("Request", str + " this: " + this.f10829a); } private static int u(int i10, float f10) { return i10 == Integer.MIN_VALUE ? i10 : Math.round(f10 * i10); } private void v() { d dVar = this.f10832d; if (dVar != null) { dVar.c(this); } } private void w() { d dVar = this.f10832d; if (dVar != null) { dVar.e(this); } } public static h x(Context context, com.bumptech.glide.d dVar, Object obj, Object obj2, Class cls, i2.a aVar, int i10, int i11, com.bumptech.glide.g gVar, j2.h hVar, e eVar, List list, d dVar2, k kVar, k2.c cVar, Executor executor) { return new h(context, dVar, obj, obj2, cls, aVar, i10, i11, gVar, hVar, eVar, list, dVar2, kVar, cVar, executor); } private void y(q qVar, int i10) { this.f10830b.c(); synchronized (this.f10831c) { qVar.k(this.B); int h10 = this.f10834f.h(); if (h10 <= i10) { Log.w("Glide", "Load failed for " + this.f10835g + " with size [" + this.f10853y + "x" + this.f10854z + "]", qVar); if (h10 <= 4) { qVar.g("Glide"); } } this.f10846r = null; this.f10849u = a.FAILED; this.A = true; try { List list = this.f10842n; if (list != null) { Iterator it = list.iterator(); if (it.hasNext()) { m.a(it.next()); r(); throw null; } } if (!(false | false)) { A(); } this.A = false; v(); } catch (Throwable th) { this.A = false; throw th; } } } private void z(v vVar, Object obj, q1.a aVar, boolean z10) { boolean r10 = r(); this.f10849u = a.COMPLETE; this.f10845q = vVar; if (this.f10834f.h() <= 3) { Log.d("Glide", "Finished loading " + obj.getClass().getSimpleName() + " from " + aVar + " for " + this.f10835g + " with size [" + this.f10853y + "x" + this.f10854z + "] in " + m2.f.a(this.f10847s) + " ms"); } this.A = true; try { List list = this.f10842n; if (list != null) { Iterator it = list.iterator(); if (it.hasNext()) { m.a(it.next()); throw null; } } if (!(false | false)) { this.f10841m.f(obj, this.f10843o.a(aVar, r10)); } this.A = false; w(); } catch (Throwable th) { this.A = false; throw th; } } @Override // i2.c public boolean a() { boolean z10; synchronized (this.f10831c) { z10 = this.f10849u == a.COMPLETE; } return z10; } @Override // i2.g public void b(v vVar, q1.a aVar, boolean z10) { this.f10830b.c(); v vVar2 = null; try { synchronized (this.f10831c) { try { this.f10846r = null; if (vVar == null) { e(new q("Expected to receive a Resource with an object of " + this.f10836h + " inside, but instead got null.")); return; } Object obj = vVar.get(); try { if (obj != null && this.f10836h.isAssignableFrom(obj.getClass())) { if (m()) { z(vVar, obj, aVar, z10); return; } this.f10845q = null; this.f10849u = a.COMPLETE; this.f10848t.k(vVar); return; } this.f10845q = null; StringBuilder sb = new StringBuilder(); sb.append("Expected to receive an object of "); sb.append(this.f10836h); sb.append(" but instead got "); sb.append(obj != null ? obj.getClass() : RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED); sb.append("{"); sb.append(obj); sb.append("} inside Resource{"); sb.append(vVar); sb.append("}."); sb.append(obj != null ? RequestConfiguration.MAX_AD_CONTENT_RATING_UNSPECIFIED : " To indicate failure return a null Resource object, rather than a Resource object containing null data."); e(new q(sb.toString())); this.f10848t.k(vVar); } catch (Throwable th) { vVar2 = vVar; th = th; throw th; } } catch (Throwable th2) { th = th2; } } } catch (Throwable th3) { if (vVar2 != null) { this.f10848t.k(vVar2); } throw th3; } } @Override // j2.g public void c(int i10, int i11) { Object obj; this.f10830b.c(); Object obj2 = this.f10831c; synchronized (obj2) { try { try { boolean z10 = C; if (z10) { t("Got onSizeReady in " + m2.f.a(this.f10847s)); } if (this.f10849u == a.WAITING_FOR_SIZE) { a aVar = a.RUNNING; this.f10849u = aVar; float w10 = this.f10837i.w(); this.f10853y = u(i10, w10); this.f10854z = u(i11, w10); if (z10) { t("finished setup for calling load in " + m2.f.a(this.f10847s)); } obj = obj2; try { this.f10846r = this.f10848t.f(this.f10834f, this.f10835g, this.f10837i.v(), this.f10853y, this.f10854z, this.f10837i.u(), this.f10836h, this.f10840l, this.f10837i.i(), this.f10837i.y(), this.f10837i.K(), this.f10837i.F(), this.f10837i.o(), this.f10837i.D(), this.f10837i.B(), this.f10837i.A(), this.f10837i.n(), this, this.f10844p); if (this.f10849u != aVar) { this.f10846r = null; } if (z10) { t("finished onSizeReady in " + m2.f.a(this.f10847s)); } } catch (Throwable th) { th = th; throw th; } } } catch (Throwable th2) { th = th2; obj = obj2; } } catch (Throwable th3) { th = th3; } } } @Override // i2.c public void clear() { synchronized (this.f10831c) { j(); this.f10830b.c(); a aVar = this.f10849u; a aVar2 = a.CLEARED; if (aVar == aVar2) { return; } n(); v vVar = this.f10845q; if (vVar != null) { this.f10845q = null; } else { vVar = null; } if (k()) { this.f10841m.d(q()); } this.f10849u = aVar2; if (vVar != null) { this.f10848t.k(vVar); } } } @Override // i2.c public boolean d() { boolean z10; synchronized (this.f10831c) { z10 = this.f10849u == a.CLEARED; } return z10; } @Override // i2.g public void e(q qVar) { y(qVar, 5); } @Override // i2.g public Object f() { this.f10830b.c(); return this.f10831c; } @Override // i2.c public void g() { synchronized (this.f10831c) { j(); this.f10830b.c(); this.f10847s = m2.f.b(); if (this.f10835g == null) { if (m2.k.s(this.f10838j, this.f10839k)) { this.f10853y = this.f10838j; this.f10854z = this.f10839k; } y(new q("Received null model"), p() == null ? 5 : 3); return; } a aVar = this.f10849u; a aVar2 = a.RUNNING; if (aVar == aVar2) { throw new IllegalArgumentException("Cannot restart a running request"); } if (aVar == a.COMPLETE) { b(this.f10845q, q1.a.MEMORY_CACHE, false); return; } a aVar3 = a.WAITING_FOR_SIZE; this.f10849u = aVar3; if (m2.k.s(this.f10838j, this.f10839k)) { c(this.f10838j, this.f10839k); } else { this.f10841m.g(this); } a aVar4 = this.f10849u; if ((aVar4 == aVar2 || aVar4 == aVar3) && l()) { this.f10841m.b(q()); } if (C) { t("finished run method in " + m2.f.a(this.f10847s)); } } } @Override // i2.c public boolean h() { boolean z10; synchronized (this.f10831c) { z10 = this.f10849u == a.COMPLETE; } return z10; } @Override // i2.c public boolean i(c cVar) { int i10; int i11; Object obj; Class cls; i2.a aVar; com.bumptech.glide.g gVar; int size; int i12; int i13; Object obj2; Class cls2; i2.a aVar2; com.bumptech.glide.g gVar2; int size2; if (!(cVar instanceof h)) { return false; } synchronized (this.f10831c) { i10 = this.f10838j; i11 = this.f10839k; obj = this.f10835g; cls = this.f10836h; aVar = this.f10837i; gVar = this.f10840l; List list = this.f10842n; size = list != null ? list.size() : 0; } h hVar = (h) cVar; synchronized (hVar.f10831c) { i12 = hVar.f10838j; i13 = hVar.f10839k; obj2 = hVar.f10835g; cls2 = hVar.f10836h; aVar2 = hVar.f10837i; gVar2 = hVar.f10840l; List list2 = hVar.f10842n; size2 = list2 != null ? list2.size() : 0; } return i10 == i12 && i11 == i13 && m2.k.b(obj, obj2) && cls.equals(cls2) && aVar.equals(aVar2) && gVar == gVar2 && size == size2; } @Override // i2.c public boolean isRunning() { boolean z10; synchronized (this.f10831c) { a aVar = this.f10849u; z10 = aVar == a.RUNNING || aVar == a.WAITING_FOR_SIZE; } return z10; } @Override // i2.c public void pause() { synchronized (this.f10831c) { if (isRunning()) { clear(); } } } }