package com.bumptech.glide.load.engine;

import com.bumptech.glide.load.DataSource;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public final class f0 implements h, com.bumptech.glide.load.data.d {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final g f5674a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final i f5675b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public int f5676c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f5677d = -1;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public a5.h f5678e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public List f5679f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public int f5680g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public volatile g5.a0 f5681h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public File f5682i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public g0 f5683j;

    public f0(i iVar, g gVar) {
        this.f5675b = iVar;
        this.f5674a = gVar;
    }

    @Override // com.bumptech.glide.load.engine.h
    public final boolean a() {
        ArrayList arrayListA = this.f5675b.a();
        boolean z10 = false;
        if (arrayListA.isEmpty()) {
            return false;
        }
        List listC = this.f5675b.c();
        if (listC.isEmpty()) {
            if (File.class.equals(this.f5675b.f5704k)) {
                return false;
            }
            throw new IllegalStateException("Failed to find any load path from " + this.f5675b.f5697d.getClass() + " to " + this.f5675b.f5704k);
        }
        while (true) {
            List list = this.f5679f;
            if (list != null && this.f5680g < list.size()) {
                this.f5681h = null;
                while (!z10 && this.f5680g < this.f5679f.size()) {
                    List list2 = this.f5679f;
                    int i10 = this.f5680g;
                    this.f5680g = i10 + 1;
                    g5.b0 b0Var = (g5.b0) list2.get(i10);
                    File file = this.f5682i;
                    i iVar = this.f5675b;
                    this.f5681h = b0Var.buildLoadData(file, iVar.f5698e, iVar.f5699f, iVar.f5702i);
                    if (this.f5681h != null) {
                        i iVar2 = this.f5675b;
                        if (iVar2.f5696c.f5581b.getLoadPath(this.f5681h.f26167c.a(), iVar2.f5700g, iVar2.f5704k) != null) {
                            this.f5681h.f26167c.e(this.f5675b.f5708o, this);
                            z10 = true;
                        }
                    }
                }
                return z10;
            }
            int i11 = this.f5677d + 1;
            this.f5677d = i11;
            if (i11 >= listC.size()) {
                int i12 = this.f5676c + 1;
                this.f5676c = i12;
                if (i12 >= arrayListA.size()) {
                    return false;
                }
                this.f5677d = 0;
            }
            a5.h hVar = (a5.h) arrayListA.get(this.f5676c);
            Class cls = (Class) listC.get(this.f5677d);
            a5.o oVarE = this.f5675b.e(cls);
            i iVar3 = this.f5675b;
            this.f5683j = new g0(iVar3.f5696c.f5580a, hVar, iVar3.f5707n, iVar3.f5698e, iVar3.f5699f, oVarE, cls, iVar3.f5702i);
            File file2 = iVar3.f5701h.a().get(this.f5683j);
            this.f5682i = file2;
            if (file2 != null) {
                this.f5678e = hVar;
                this.f5679f = this.f5675b.f5696c.f5581b.f(file2);
                this.f5680g = 0;
            }
        }
    }

    @Override // com.bumptech.glide.load.data.d
    public final void c(Exception exc) {
        this.f5674a.b(this.f5683j, exc, this.f5681h.f26167c, DataSource.f5592d);
    }

    @Override // com.bumptech.glide.load.engine.h
    public final void cancel() {
        g5.a0 a0Var = this.f5681h;
        if (a0Var != null) {
            a0Var.f26167c.cancel();
        }
    }

    @Override // com.bumptech.glide.load.data.d
    public final void onDataReady(Object obj) {
        this.f5674a.onDataFetcherReady(this.f5678e, obj, this.f5681h.f26167c, DataSource.f5592d, this.f5683j);
    }
}
