package com.bumptech.glide; import a2.a; import android.content.ComponentCallbacks2; import android.content.ContentResolver; import android.content.Context; import android.content.res.AssetFileDescriptor; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; import android.os.ParcelFileDescriptor; import android.util.Log; import com.bumptech.glide.c; import com.bumptech.glide.load.data.ParcelFileDescriptorRewinder; import com.bumptech.glide.load.data.k; import f2.p; import java.io.File; import java.io.InputStream; import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; import w1.a; import w1.b; import w1.d; import w1.e; import w1.f; import w1.k; import w1.r; import w1.s; import w1.t; import w1.u; import w1.v; import w1.w; import x1.a; import x1.b; import x1.c; import x1.d; import x1.g; import z1.a0; import z1.c0; import z1.e0; import z1.f0; import z1.h0; import z1.j0; import z1.m; import z1.t; import z1.w; /* loaded from: classes.dex */ public class b implements ComponentCallbacks2 { /* renamed from: l, reason: collision with root package name */ private static volatile b f4104l; /* renamed from: m, reason: collision with root package name */ private static volatile boolean f4105m; /* renamed from: a, reason: collision with root package name */ private final s1.k f4106a; /* renamed from: b, reason: collision with root package name */ private final t1.d f4107b; /* renamed from: c, reason: collision with root package name */ private final u1.h f4108c; /* renamed from: d, reason: collision with root package name */ private final d f4109d; /* renamed from: e, reason: collision with root package name */ private final i f4110e; /* renamed from: f, reason: collision with root package name */ private final t1.b f4111f; /* renamed from: g, reason: collision with root package name */ private final p f4112g; /* renamed from: h, reason: collision with root package name */ private final f2.d f4113h; /* renamed from: j, reason: collision with root package name */ private final a f4115j; /* renamed from: i, reason: collision with root package name */ private final List f4114i = new ArrayList(); /* renamed from: k, reason: collision with root package name */ private f f4116k = f.NORMAL; public interface a { i2.f build(); } b(Context context, s1.k kVar, u1.h hVar, t1.d dVar, t1.b bVar, p pVar, f2.d dVar2, int i10, a aVar, Map map, List list, e eVar) { q1.j hVar2; q1.j f0Var; i iVar; this.f4106a = kVar; this.f4107b = dVar; this.f4111f = bVar; this.f4108c = hVar; this.f4112g = pVar; this.f4113h = dVar2; this.f4115j = aVar; Resources resources = context.getResources(); i iVar2 = new i(); this.f4110e = iVar2; iVar2.o(new m()); int i11 = Build.VERSION.SDK_INT; if (i11 >= 27) { iVar2.o(new w()); } List g10 = iVar2.g(); d2.a aVar2 = new d2.a(context, g10, dVar, bVar); q1.j h10 = j0.h(dVar); t tVar = new t(iVar2.g(), resources.getDisplayMetrics(), dVar, bVar); if (!eVar.a(c.b.class) || i11 < 28) { hVar2 = new z1.h(tVar); f0Var = new f0(tVar, bVar); } else { f0Var = new a0(); hVar2 = new z1.j(); } b2.d dVar3 = new b2.d(context); r.c cVar = new r.c(resources); r.d dVar4 = new r.d(resources); r.b bVar2 = new r.b(resources); r.a aVar3 = new r.a(resources); z1.c cVar2 = new z1.c(bVar); e2.a aVar4 = new e2.a(); e2.d dVar5 = new e2.d(); ContentResolver contentResolver = context.getContentResolver(); iVar2.c(ByteBuffer.class, new w1.c()).c(InputStream.class, new s(bVar)).e("Bitmap", ByteBuffer.class, Bitmap.class, hVar2).e("Bitmap", InputStream.class, Bitmap.class, f0Var); if (ParcelFileDescriptorRewinder.c()) { iVar2.e("Bitmap", ParcelFileDescriptor.class, Bitmap.class, new c0(tVar)); } iVar2.e("Bitmap", ParcelFileDescriptor.class, Bitmap.class, h10).e("Bitmap", AssetFileDescriptor.class, Bitmap.class, j0.c(dVar)).b(Bitmap.class, Bitmap.class, u.a.a()).e("Bitmap", Bitmap.class, Bitmap.class, new h0()).d(Bitmap.class, cVar2).e("BitmapDrawable", ByteBuffer.class, BitmapDrawable.class, new z1.a(resources, hVar2)).e("BitmapDrawable", InputStream.class, BitmapDrawable.class, new z1.a(resources, f0Var)).e("BitmapDrawable", ParcelFileDescriptor.class, BitmapDrawable.class, new z1.a(resources, h10)).d(BitmapDrawable.class, new z1.b(dVar, cVar2)).e("Gif", InputStream.class, d2.c.class, new d2.j(g10, aVar2, bVar)).e("Gif", ByteBuffer.class, d2.c.class, aVar2).d(d2.c.class, new d2.d()).b(p1.a.class, p1.a.class, u.a.a()).e("Bitmap", p1.a.class, Bitmap.class, new d2.h(dVar)).a(Uri.class, Drawable.class, dVar3).a(Uri.class, Bitmap.class, new e0(dVar3, dVar)).p(new a.C0002a()).b(File.class, ByteBuffer.class, new d.b()).b(File.class, InputStream.class, new f.e()).a(File.class, File.class, new c2.a()).b(File.class, ParcelFileDescriptor.class, new f.b()).b(File.class, File.class, u.a.a()).p(new k.a(bVar)); if (ParcelFileDescriptorRewinder.c()) { iVar = iVar2; iVar.p(new ParcelFileDescriptorRewinder.a()); } else { iVar = iVar2; } Class cls = Integer.TYPE; iVar.b(cls, InputStream.class, cVar).b(cls, ParcelFileDescriptor.class, bVar2).b(Integer.class, InputStream.class, cVar).b(Integer.class, ParcelFileDescriptor.class, bVar2).b(Integer.class, Uri.class, dVar4).b(cls, AssetFileDescriptor.class, aVar3).b(Integer.class, AssetFileDescriptor.class, aVar3).b(cls, Uri.class, dVar4).b(String.class, InputStream.class, new e.c()).b(Uri.class, InputStream.class, new e.c()).b(String.class, InputStream.class, new t.c()).b(String.class, ParcelFileDescriptor.class, new t.b()).b(String.class, AssetFileDescriptor.class, new t.a()).b(Uri.class, InputStream.class, new a.c(context.getAssets())).b(Uri.class, ParcelFileDescriptor.class, new a.b(context.getAssets())).b(Uri.class, InputStream.class, new b.a(context)).b(Uri.class, InputStream.class, new c.a(context)); if (i11 >= 29) { iVar.b(Uri.class, InputStream.class, new d.c(context)); iVar.b(Uri.class, ParcelFileDescriptor.class, new d.b(context)); } iVar.b(Uri.class, InputStream.class, new v.d(contentResolver)).b(Uri.class, ParcelFileDescriptor.class, new v.b(contentResolver)).b(Uri.class, AssetFileDescriptor.class, new v.a(contentResolver)).b(Uri.class, InputStream.class, new w.a()).b(URL.class, InputStream.class, new g.a()).b(Uri.class, File.class, new k.a(context)).b(w1.g.class, InputStream.class, new a.C0261a()).b(byte[].class, ByteBuffer.class, new b.a()).b(byte[].class, InputStream.class, new b.d()).b(Uri.class, Uri.class, u.a.a()).b(Drawable.class, Drawable.class, u.a.a()).a(Drawable.class, Drawable.class, new b2.e()).q(Bitmap.class, BitmapDrawable.class, new e2.b(resources)).q(Bitmap.class, byte[].class, aVar4).q(Drawable.class, byte[].class, new e2.c(dVar, aVar4, dVar5)).q(d2.c.class, byte[].class, dVar5); if (i11 >= 23) { q1.j d10 = j0.d(dVar); iVar.a(ByteBuffer.class, Bitmap.class, d10); iVar.a(ByteBuffer.class, BitmapDrawable.class, new z1.a(resources, d10)); } this.f4109d = new d(context, bVar, iVar, new j2.f(), aVar, map, list, kVar, eVar, i10); } private static void a(Context context, GeneratedAppGlideModule generatedAppGlideModule) { if (f4105m) { throw new IllegalStateException("You cannot call Glide.get() in registerComponents(), use the provided Glide instance instead"); } f4105m = true; m(context, generatedAppGlideModule); f4105m = false; } public static b c(Context context) { if (f4104l == null) { GeneratedAppGlideModule d10 = d(context.getApplicationContext()); synchronized (b.class) { if (f4104l == null) { a(context, d10); } } } return f4104l; } private static GeneratedAppGlideModule d(Context context) { try { return (GeneratedAppGlideModule) Class.forName("com.bumptech.glide.GeneratedAppGlideModuleImpl").getDeclaredConstructor(Context.class).newInstance(context.getApplicationContext()); } catch (ClassNotFoundException unused) { if (Log.isLoggable("Glide", 5)) { Log.w("Glide", "Failed to find GeneratedAppGlideModule. You should include an annotationProcessor compile dependency on com.github.bumptech.glide:compiler in your application and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored"); } return null; } catch (IllegalAccessException e10) { q(e10); return null; } catch (InstantiationException e11) { q(e11); return null; } catch (NoSuchMethodException e12) { q(e12); return null; } catch (InvocationTargetException e13) { q(e13); return null; } } private static p l(Context context) { m2.j.e(context, "You cannot start a load on a not yet attached View or a Fragment where getActivity() returns null (which usually occurs when getActivity() is called before the Fragment is attached or after the Fragment is destroyed)."); return c(context).k(); } private static void m(Context context, GeneratedAppGlideModule generatedAppGlideModule) { n(context, new c(), generatedAppGlideModule); } private static void n(Context context, c cVar, GeneratedAppGlideModule generatedAppGlideModule) { Context applicationContext = context.getApplicationContext(); List emptyList = Collections.emptyList(); if (generatedAppGlideModule == null || generatedAppGlideModule.c()) { emptyList = new g2.d(applicationContext).a(); } if (generatedAppGlideModule != null && !generatedAppGlideModule.d().isEmpty()) { generatedAppGlideModule.d(); Iterator it = emptyList.iterator(); if (it.hasNext()) { androidx.appcompat.app.m.a(it.next()); throw null; } } if (Log.isLoggable("Glide", 3)) { Iterator it2 = emptyList.iterator(); if (it2.hasNext()) { androidx.appcompat.app.m.a(it2.next()); new StringBuilder().append("Discovered GlideModule from manifest: "); throw null; } } cVar.b(generatedAppGlideModule != null ? generatedAppGlideModule.e() : null); Iterator it3 = emptyList.iterator(); if (it3.hasNext()) { androidx.appcompat.app.m.a(it3.next()); throw null; } if (generatedAppGlideModule != null) { generatedAppGlideModule.b(applicationContext, cVar); } b a10 = cVar.a(applicationContext); Iterator it4 = emptyList.iterator(); if (it4.hasNext()) { androidx.appcompat.app.m.a(it4.next()); try { i iVar = a10.f4110e; throw null; } catch (AbstractMethodError unused) { new StringBuilder().append("Attempting to register a Glide v3 module. If you see this, you or one of your dependencies may be including Glide v3 even though you're using Glide v4. You'll need to find and remove (or update) the offending dependency. The v3 module name is: "); throw null; } } if (generatedAppGlideModule != null) { generatedAppGlideModule.a(applicationContext, a10, a10.f4110e); } applicationContext.registerComponentCallbacks(a10); f4104l = a10; } private static void q(Exception exc) { throw new IllegalStateException("GeneratedAppGlideModuleImpl is implemented incorrectly. If you've manually implemented this class, remove your implementation. The Annotation processor will generate a correct implementation.", exc); } public static k t(Context context) { return l(context).f(context); } public void b() { m2.k.a(); this.f4108c.b(); this.f4107b.b(); this.f4111f.b(); } public t1.b e() { return this.f4111f; } public t1.d f() { return this.f4107b; } f2.d g() { return this.f4113h; } public Context h() { return this.f4109d.getBaseContext(); } d i() { return this.f4109d; } public i j() { return this.f4110e; } public p k() { return this.f4112g; } void o(k kVar) { synchronized (this.f4114i) { if (this.f4114i.contains(kVar)) { throw new IllegalStateException("Cannot register already registered manager"); } this.f4114i.add(kVar); } } @Override // android.content.ComponentCallbacks public void onConfigurationChanged(Configuration configuration) { } @Override // android.content.ComponentCallbacks public void onLowMemory() { b(); } @Override // android.content.ComponentCallbacks2 public void onTrimMemory(int i10) { r(i10); } boolean p(j2.h hVar) { synchronized (this.f4114i) { Iterator it = this.f4114i.iterator(); while (it.hasNext()) { if (((k) it.next()).w(hVar)) { return true; } } return false; } } public void r(int i10) { m2.k.a(); synchronized (this.f4114i) { Iterator it = this.f4114i.iterator(); while (it.hasNext()) { ((k) it.next()).onTrimMemory(i10); } } this.f4108c.a(i10); this.f4107b.a(i10); this.f4111f.a(i10); } void s(k kVar) { synchronized (this.f4114i) { if (!this.f4114i.contains(kVar)) { throw new IllegalStateException("Cannot unregister not yet registered manager"); } this.f4114i.remove(kVar); } } }