package com.bumptech.glide.load.engine;

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

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

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

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

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

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

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

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

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

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

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

    public e(List list, i iVar, g gVar) {
        this.f5663a = list;
        this.f5664b = iVar;
        this.f5665c = gVar;
    }

    @Override // com.bumptech.glide.load.engine.h
    public final boolean a() {
        while (true) {
            List list = this.f5668f;
            boolean z10 = false;
            if (list != null && this.f5669g < list.size()) {
                this.f5670h = null;
                while (!z10 && this.f5669g < this.f5668f.size()) {
                    List list2 = this.f5668f;
                    int i10 = this.f5669g;
                    this.f5669g = i10 + 1;
                    g5.b0 b0Var = (g5.b0) list2.get(i10);
                    File file = this.f5671i;
                    i iVar = this.f5664b;
                    this.f5670h = b0Var.buildLoadData(file, iVar.f5698e, iVar.f5699f, iVar.f5702i);
                    if (this.f5670h != null) {
                        i iVar2 = this.f5664b;
                        if (iVar2.f5696c.f5581b.getLoadPath(this.f5670h.f26167c.a(), iVar2.f5700g, iVar2.f5704k) != null) {
                            this.f5670h.f26167c.e(this.f5664b.f5708o, this);
                            z10 = true;
                        }
                    }
                }
                return z10;
            }
            int i11 = this.f5666d + 1;
            this.f5666d = i11;
            if (i11 >= this.f5663a.size()) {
                return false;
            }
            a5.h hVar = (a5.h) this.f5663a.get(this.f5666d);
            i iVar3 = this.f5664b;
            File file2 = iVar3.f5701h.a().get(new f(hVar, iVar3.f5707n));
            this.f5671i = file2;
            if (file2 != null) {
                this.f5667e = hVar;
                this.f5668f = this.f5664b.f5696c.f5581b.f(file2);
                this.f5669g = 0;
            }
        }
    }

    @Override // com.bumptech.glide.load.data.d
    public final void c(Exception exc) {
        this.f5665c.b(this.f5667e, exc, this.f5670h.f26167c, DataSource.f5591c);
    }

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

    @Override // com.bumptech.glide.load.data.d
    public final void onDataReady(Object obj) {
        this.f5665c.onDataFetcherReady(this.f5667e, obj, this.f5670h.f26167c, DataSource.f5591c, this.f5667e);
    }
}
