package defpackage;

import com.bumptech.glide.load.data.a;
import defpackage.lv2;
import defpackage.vc7;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public class ex7 {
    public final b86 a;
    public final jl2 b;
    public final i28 c;
    public final l28 d;
    public final com.bumptech.glide.load.data.b e;
    public final ws9 f;
    public final xh4 g;
    public final c86 h = new c86();
    public final dd5 i = new dd5();
    public final vc7.a j;

    public static class a extends RuntimeException {
    }

    public static final class b extends a {
    }

    public static class c extends a {
    }

    public static class d extends a {
        public d(Class cls) {
            super("Failed to find result encoder for resource class: " + cls + ", you may need to consider registering a new Encoder for the requested type or DiskCacheStrategy.DATA/DiskCacheStrategy.NONE if caching your transformed resource is unnecessary.");
        }
    }

    public static class e extends a {
    }

    public ex7() {
        lv2.c cVar = new lv2.c(new vc7.c(20), new mv2(), new nv2());
        this.j = cVar;
        this.a = new b86(cVar);
        this.b = new jl2();
        this.c = new i28();
        this.d = new l28();
        this.e = new com.bumptech.glide.load.data.b();
        this.f = new ws9();
        this.g = new xh4();
        List listAsList = Arrays.asList("Animation", "Bitmap", "BitmapDrawable");
        ArrayList arrayList = new ArrayList(listAsList.size());
        arrayList.add("legacy_prepend_all");
        Iterator it = listAsList.iterator();
        while (it.hasNext()) {
            arrayList.add((String) it.next());
        }
        arrayList.add("legacy_append");
        i28 i28Var = this.c;
        synchronized (i28Var) {
            try {
                ArrayList<String> arrayList2 = new ArrayList(i28Var.a);
                i28Var.a.clear();
                Iterator it2 = arrayList.iterator();
                while (it2.hasNext()) {
                    i28Var.a.add((String) it2.next());
                }
                for (String str : arrayList2) {
                    if (!arrayList.contains(str)) {
                        i28Var.a.add(str);
                    }
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    public final void a(h28 h28Var, Class cls, Class cls2, String str) {
        this.c.a(h28Var, cls, cls2, str);
    }

    public final ArrayList b() {
        ArrayList arrayList;
        xh4 xh4Var = this.g;
        synchronized (xh4Var) {
            arrayList = xh4Var.a;
        }
        if (arrayList.isEmpty()) {
            throw new b("Failed to find image header parser.");
        }
        return arrayList;
    }

    public final com.bumptech.glide.load.data.a c(Object obj) {
        com.bumptech.glide.load.data.a aVarB;
        com.bumptech.glide.load.data.b bVar = this.e;
        synchronized (bVar) {
            try {
                gf7.b(obj);
                a.InterfaceC0080a interfaceC0080a = (a.InterfaceC0080a) bVar.a.get(obj.getClass());
                if (interfaceC0080a == null) {
                    Iterator it = bVar.a.values().iterator();
                    while (true) {
                        if (!it.hasNext()) {
                            break;
                        }
                        a.InterfaceC0080a interfaceC0080a2 = (a.InterfaceC0080a) it.next();
                        if (interfaceC0080a2.a().isAssignableFrom(obj.getClass())) {
                            interfaceC0080a = interfaceC0080a2;
                            break;
                        }
                    }
                }
                if (interfaceC0080a == null) {
                    interfaceC0080a = com.bumptech.glide.load.data.b.b;
                }
                aVarB = interfaceC0080a.b(obj);
            } catch (Throwable th) {
                throw th;
            }
        }
        return aVarB;
    }

    public final void d(a.InterfaceC0080a interfaceC0080a) {
        com.bumptech.glide.load.data.b bVar = this.e;
        synchronized (bVar) {
            bVar.a.put(interfaceC0080a.a(), interfaceC0080a);
        }
    }
}
