package defpackage;

import defpackage.nq1;
import defpackage.oq1;
import defpackage.z76;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
class d28 implements oq1, nq1.a<Object> {
    public final oq1.a a;
    public final cx1 b;
    public int c;
    public int d = -1;
    public v25 e;
    public List f;
    public int i;
    public volatile z76.a j;
    public File k;
    public e28 l;

    public d28(cx1 cx1Var, oq1.a aVar) {
        this.b = cx1Var;
        this.a = aVar;
    }

    @Override // defpackage.oq1
    public final boolean b() {
        List list;
        ArrayList arrayListD;
        ArrayList arrayListA = this.b.a();
        boolean z = false;
        if (!arrayListA.isEmpty()) {
            cx1 cx1Var = this.b;
            ex7 ex7VarA = cx1Var.c.a();
            Class<?> cls = cx1Var.d.getClass();
            Class cls2 = cx1Var.g;
            Class cls3 = cx1Var.k;
            c86 c86Var = ex7VarA.h;
            nb6 nb6Var = (nb6) c86Var.a.getAndSet(null);
            if (nb6Var == null) {
                nb6Var = new nb6(cls, cls2, cls3);
            } else {
                nb6Var.a = cls;
                nb6Var.b = cls2;
                nb6Var.c = cls3;
            }
            synchronized (c86Var.b) {
                list = (List) c86Var.b.get(nb6Var);
            }
            c86Var.a.set(nb6Var);
            List list2 = list;
            if (list == null) {
                ArrayList arrayList = new ArrayList();
                b86 b86Var = ex7VarA.a;
                synchronized (b86Var) {
                    arrayListD = b86Var.a.d(cls);
                }
                Iterator it = arrayListD.iterator();
                while (it.hasNext()) {
                    for (Class cls4 : ex7VarA.c.c((Class) it.next(), cls2)) {
                        if (!ex7VarA.f.a(cls4, cls3).isEmpty() && !arrayList.contains(cls4)) {
                            arrayList.add(cls4);
                        }
                    }
                }
                c86 c86Var2 = ex7VarA.h;
                List listUnmodifiableList = Collections.unmodifiableList(arrayList);
                synchronized (c86Var2.b) {
                    c86Var2.b.put(new nb6(cls, cls2, cls3), listUnmodifiableList);
                }
                list2 = arrayList;
            }
            if (!list2.isEmpty()) {
                while (true) {
                    List list3 = this.f;
                    if (list3 != null && this.i < list3.size()) {
                        this.j = null;
                        while (!z && this.i < this.f.size()) {
                            List list4 = this.f;
                            int i = this.i;
                            this.i = i + 1;
                            z76 z76Var = (z76) list4.get(i);
                            File file = this.k;
                            cx1 cx1Var2 = this.b;
                            this.j = z76Var.b(file, cx1Var2.e, cx1Var2.f, cx1Var2.i);
                            if (this.j != null && this.b.c(this.j.c.a()) != null) {
                                this.j.c.d(this.b.o, this);
                                z = true;
                            }
                        }
                        return z;
                    }
                    int i2 = this.d + 1;
                    this.d = i2;
                    if (i2 >= list2.size()) {
                        int i3 = this.c + 1;
                        this.c = i3;
                        if (i3 >= arrayListA.size()) {
                            break;
                        }
                        this.d = 0;
                    }
                    v25 v25Var = (v25) arrayListA.get(this.c);
                    Class cls5 = (Class) list2.get(this.d);
                    et9 et9VarD = this.b.d(cls5);
                    cx1 cx1Var3 = this.b;
                    this.l = new e28(cx1Var3.c.a, v25Var, cx1Var3.n, cx1Var3.e, cx1Var3.f, et9VarD, cls5, cx1Var3.i);
                    File fileA = cx1Var3.h.a().a(this.l);
                    this.k = fileA;
                    if (fileA != null) {
                        this.e = v25Var;
                        this.f = this.b.c.a().a.b(fileA);
                        this.i = 0;
                    }
                }
            } else if (!File.class.equals(this.b.k)) {
                throw new IllegalStateException("Failed to find any load path from " + this.b.d.getClass() + " to " + this.b.k);
            }
        }
        return false;
    }

    @Override // nq1.a
    public final void c(Exception exc) {
        this.a.a(this.l, exc, this.j.c, zq1.d);
    }

    @Override // defpackage.oq1
    public final void cancel() {
        z76.a aVar = this.j;
        if (aVar != null) {
            aVar.c.cancel();
        }
    }

    @Override // nq1.a
    public final void f(Object obj) {
        this.a.c(this.e, obj, this.j.c, zq1.d, this.l);
    }
}
