package b6; 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 b6.b; import f6.k; import f6.m; 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 l6.a; import l6.b; import l6.d; import l6.e; import l6.f; import l6.k; import l6.q; import l6.r; import l6.s; import l6.t; import l6.u; import l6.v; import m6.a; import m6.b; import m6.c; import m6.d; import m6.e; import o6.a0; import o6.m; import o6.o; import o6.s; import o6.u; import o6.w; import o6.x; import o6.z; import p6.a; /* loaded from: classes2.dex */ public class e implements ComponentCallbacks2 { /* renamed from: l, reason: collision with root package name */ private static volatile e f3251l; /* renamed from: m, reason: collision with root package name */ private static volatile boolean f3252m; /* renamed from: a, reason: collision with root package name */ private final h6.d f3253a; /* renamed from: b, reason: collision with root package name */ private final i6.b f3254b; /* renamed from: c, reason: collision with root package name */ private final j6.g f3255c; /* renamed from: d, reason: collision with root package name */ private final c f3256d; /* renamed from: e, reason: collision with root package name */ private final h f3257e; /* renamed from: f, reason: collision with root package name */ private final i6.a f3258f; /* renamed from: g, reason: collision with root package name */ private final u6.g f3259g; /* renamed from: h, reason: collision with root package name */ private final u6.b f3260h; /* renamed from: j, reason: collision with root package name */ private final a f3262j; /* renamed from: i, reason: collision with root package name */ private final List f3261i = new ArrayList(); /* renamed from: k, reason: collision with root package name */ private f f3263k = f.NORMAL; public interface a { x6.f build(); } e(Context context, h6.d dVar, j6.g gVar, i6.b bVar, i6.a aVar, u6.g gVar2, u6.b bVar2, int i10, a aVar2, Map map, List list, d dVar2) { e6.l gVar3; e6.l xVar; h hVar; this.f3253a = dVar; this.f3254b = bVar; this.f3258f = aVar; this.f3255c = gVar; this.f3259g = gVar2; this.f3260h = bVar2; this.f3262j = aVar2; Resources resources = context.getResources(); h hVar2 = new h(); this.f3257e = hVar2; hVar2.o(new o6.k()); int i11 = Build.VERSION.SDK_INT; if (i11 >= 27) { hVar2.o(new o()); } List g10 = hVar2.g(); s6.a aVar3 = new s6.a(context, g10, bVar, aVar); e6.l h10 = a0.h(bVar); m mVar = new m(hVar2.g(), resources.getDisplayMetrics(), bVar, aVar); if (!dVar2.a(b.d.class) || i11 < 28) { gVar3 = new o6.g(mVar); xVar = new x(mVar, aVar); } else { xVar = new s(); gVar3 = new o6.h(); } q6.d dVar3 = new q6.d(context); q.c cVar = new q.c(resources); q.d dVar4 = new q.d(resources); q.b bVar3 = new q.b(resources); q.a aVar4 = new q.a(resources); o6.c cVar2 = new o6.c(aVar); t6.a aVar5 = new t6.a(); t6.d dVar5 = new t6.d(); ContentResolver contentResolver = context.getContentResolver(); hVar2.b(ByteBuffer.class, new l6.c()).b(InputStream.class, new r(aVar)).f("Bitmap", ByteBuffer.class, Bitmap.class, gVar3).f("Bitmap", InputStream.class, Bitmap.class, xVar); if (f6.m.c()) { hVar2.f("Bitmap", ParcelFileDescriptor.class, Bitmap.class, new u(mVar)); } hVar2.f("Bitmap", ParcelFileDescriptor.class, Bitmap.class, h10).f("Bitmap", AssetFileDescriptor.class, Bitmap.class, a0.e(bVar)).e(Bitmap.class, Bitmap.class, t.a.a()).f("Bitmap", Bitmap.class, Bitmap.class, new z()).c(Bitmap.class, cVar2).f("BitmapDrawable", ByteBuffer.class, BitmapDrawable.class, new o6.a(resources, gVar3)).f("BitmapDrawable", InputStream.class, BitmapDrawable.class, new o6.a(resources, xVar)).f("BitmapDrawable", ParcelFileDescriptor.class, BitmapDrawable.class, new o6.a(resources, h10)).c(BitmapDrawable.class, new o6.b(bVar, cVar2)).f("Gif", InputStream.class, s6.c.class, new s6.j(g10, aVar3, aVar)).f("Gif", ByteBuffer.class, s6.c.class, aVar3).c(s6.c.class, new s6.d()).e(d6.a.class, d6.a.class, t.a.a()).f("Bitmap", d6.a.class, Bitmap.class, new s6.h(bVar)).d(Uri.class, Drawable.class, dVar3).d(Uri.class, Bitmap.class, new w(dVar3, bVar)).p(new a.C0212a()).e(File.class, ByteBuffer.class, new d.a()).e(File.class, InputStream.class, new f.d()).d(File.class, File.class, new r6.a()).e(File.class, ParcelFileDescriptor.class, new f.b()).e(File.class, File.class, t.a.a()).p(new k.a(aVar)); if (f6.m.c()) { hVar = hVar2; hVar.p(new m.a()); } else { hVar = hVar2; } Class cls = Integer.TYPE; hVar.e(cls, InputStream.class, cVar).e(cls, ParcelFileDescriptor.class, bVar3).e(Integer.class, InputStream.class, cVar).e(Integer.class, ParcelFileDescriptor.class, bVar3).e(Integer.class, Uri.class, dVar4).e(cls, AssetFileDescriptor.class, aVar4).e(Integer.class, AssetFileDescriptor.class, aVar4).e(cls, Uri.class, dVar4).e(String.class, InputStream.class, new e.b()).e(Uri.class, InputStream.class, new e.b()).e(String.class, InputStream.class, new s.c()).e(String.class, ParcelFileDescriptor.class, new s.b()).e(String.class, AssetFileDescriptor.class, new s.a()).e(Uri.class, InputStream.class, new a.c(context.getAssets())).e(Uri.class, ParcelFileDescriptor.class, new a.b(context.getAssets())).e(Uri.class, InputStream.class, new b.a(context)).e(Uri.class, InputStream.class, new c.a(context)); if (i11 >= 29) { hVar.e(Uri.class, InputStream.class, new d.b(context)); hVar.e(Uri.class, ParcelFileDescriptor.class, new d.a(context)); } hVar.e(Uri.class, InputStream.class, new u.d(contentResolver)).e(Uri.class, ParcelFileDescriptor.class, new u.b(contentResolver)).e(Uri.class, AssetFileDescriptor.class, new u.a(contentResolver)).e(Uri.class, InputStream.class, new v.a()).e(URL.class, InputStream.class, new e.a()).e(Uri.class, File.class, new k.a(context)).e(l6.h.class, InputStream.class, new a.C0190a()).e(byte[].class, ByteBuffer.class, new b.a()).e(byte[].class, InputStream.class, new b.c()).e(Uri.class, Uri.class, t.a.a()).e(Drawable.class, Drawable.class, t.a.a()).d(Drawable.class, Drawable.class, new q6.e()).q(Bitmap.class, BitmapDrawable.class, new t6.b(resources)).q(Bitmap.class, byte[].class, aVar5).q(Drawable.class, byte[].class, new t6.c(bVar, aVar5, dVar5)).q(s6.c.class, byte[].class, dVar5); if (i11 >= 23) { e6.l g11 = a0.g(bVar); hVar.d(ByteBuffer.class, Bitmap.class, g11); hVar.d(ByteBuffer.class, BitmapDrawable.class, new o6.a(resources, g11)); } this.f3256d = new c(context, aVar, hVar, new y6.f(), aVar2, map, list, dVar, dVar2, i10); } private static l a(Context context) { try { androidx.appcompat.app.m.a(Class.forName("com.imgmodule.GeneratedAppImageModuleImpl").getDeclaredConstructor(Context.class).newInstance(context.getApplicationContext())); } catch (ClassNotFoundException unused) { if (Log.isLoggable("ImageModule", 5)) { Log.w("ImageModule", "Failed to find GeneratedAppImageModule. "); } } catch (IllegalAccessException e10) { f(e10); throw null; } catch (InstantiationException e11) { f(e11); throw null; } catch (NoSuchMethodException e12) { f(e12); throw null; } catch (InvocationTargetException e13) { f(e13); throw null; } return null; } private static void c(Context context, b bVar, l lVar) { Context applicationContext = context.getApplicationContext(); Collections.emptyList(); List c10 = new v6.d(applicationContext).c(); if (Log.isLoggable("ImageModule", 3)) { Iterator it = c10.iterator(); if (it.hasNext()) { androidx.appcompat.app.m.a(it.next()); new StringBuilder().append("Discovered imageModule from manifest: "); throw null; } } bVar.b(null); Iterator it2 = c10.iterator(); if (it2.hasNext()) { androidx.appcompat.app.m.a(it2.next()); throw null; } e a10 = bVar.a(applicationContext); Iterator it3 = c10.iterator(); if (!it3.hasNext()) { applicationContext.registerComponentCallbacks(a10); f3251l = a10; } else { androidx.appcompat.app.m.a(it3.next()); try { h hVar = a10.f3257e; throw null; } catch (AbstractMethodError unused) { new StringBuilder().append("Attempting to register a ImageModule v3 module. If you see this, you or one of your dependencies may be including ImageModule v3 even though you're using ImageModule v4. You'll need to find and remove (or update) the offending dependency. The v3 module name is: "); throw null; } } } private static void d(Context context, l lVar) { if (f3252m) { throw new IllegalStateException("You cannot call ImageModule.get() in registerComponents(), use the provided ImageModule instance instead"); } f3252m = true; j(context, lVar); f3252m = false; } private static void f(Exception exc) { throw new IllegalStateException("GeneratedAppImageModuleModuleImpl is implemented incorrectly. If you've manually implemented this class, remove your implementation. The Annotation processor will generate a correct implementation.", exc); } private static u6.g i(Context context) { b7.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 m(context).r(); } private static void j(Context context, l lVar) { c(context, new b(), lVar); } public static e m(Context context) { if (f3251l == null) { a(context.getApplicationContext()); synchronized (e.class) { if (f3251l == null) { d(context, null); } } } return f3251l; } public static j t(Context context) { return i(context).m(context); } u6.b b() { return this.f3260h; } void e(j jVar) { synchronized (this.f3261i) { if (this.f3261i.contains(jVar)) { throw new IllegalStateException("Cannot register already registered manager"); } this.f3261i.add(jVar); } } boolean g(y6.h hVar) { synchronized (this.f3261i) { Iterator it = this.f3261i.iterator(); while (it.hasNext()) { if (((j) it.next()).m(hVar)) { return true; } } return false; } } c h() { return this.f3256d; } void k(j jVar) { synchronized (this.f3261i) { if (!this.f3261i.contains(jVar)) { throw new IllegalStateException("Cannot unregister not yet registered manager"); } this.f3261i.remove(jVar); } } public void l() { b7.k.e(); this.f3255c.b(); this.f3254b.b(); this.f3258f.b(); } public i6.a n() { return this.f3258f; } public i6.b o() { return this.f3254b; } @Override // android.content.ComponentCallbacks public void onConfigurationChanged(Configuration configuration) { } @Override // android.content.ComponentCallbacks public void onLowMemory() { l(); } @Override // android.content.ComponentCallbacks2 public void onTrimMemory(int i10) { s(i10); } public Context p() { return this.f3256d.getBaseContext(); } public h q() { return this.f3257e; } public u6.g r() { return this.f3259g; } public void s(int i10) { b7.k.e(); synchronized (this.f3261i) { Iterator it = this.f3261i.iterator(); while (it.hasNext()) { ((j) it.next()).onTrimMemory(i10); } } this.f3255c.a(i10); this.f3254b.a(i10); this.f3258f.a(i10); } }