package com.bumptech.glide.load.engine;

import android.os.SystemClock;
import android.util.Log;
import com.bumptech.glide.load.DataSource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public final class j0 implements h, g {

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

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

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public volatile e f5717d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public volatile Object f5718e;

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public volatile f f5720g;

    public j0(i iVar, g gVar) {
        this.f5714a = iVar;
        this.f5715b = gVar;
    }

    @Override // com.bumptech.glide.load.engine.h
    public final boolean a() {
        if (this.f5718e != null) {
            Object obj = this.f5718e;
            this.f5718e = null;
            try {
                if (!d(obj)) {
                    return true;
                }
            } catch (IOException unused) {
            }
        }
        if (this.f5717d != null && this.f5717d.a()) {
            return true;
        }
        this.f5717d = null;
        this.f5719f = null;
        boolean z10 = false;
        while (!z10 && this.f5716c < this.f5714a.b().size()) {
            ArrayList arrayListB = this.f5714a.b();
            int i10 = this.f5716c;
            this.f5716c = i10 + 1;
            this.f5719f = (g5.a0) arrayListB.get(i10);
            if (this.f5719f != null) {
                if (!this.f5714a.f5709p.a(this.f5719f.f26167c.d())) {
                    i iVar = this.f5714a;
                    if (iVar.f5696c.f5581b.getLoadPath(this.f5719f.f26167c.a(), iVar.f5700g, iVar.f5704k) != null) {
                    }
                }
                this.f5719f.f26167c.e(this.f5714a.f5708o, new i0(this, this.f5719f));
                z10 = true;
            }
        }
        return z10;
    }

    @Override // com.bumptech.glide.load.engine.g
    public final void b(a5.h hVar, Exception exc, com.bumptech.glide.load.data.e eVar, DataSource dataSource) {
        this.f5715b.b(hVar, exc, eVar, this.f5719f.f26167c.d());
    }

    @Override // com.bumptech.glide.load.engine.g
    public final void c() {
        throw new UnsupportedOperationException();
    }

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

    public final boolean d(Object obj) throws Throwable {
        int i10 = t5.i.f32966a;
        SystemClock.elapsedRealtimeNanos();
        boolean z10 = false;
        try {
            com.bumptech.glide.load.data.g gVarG = this.f5714a.f5696c.f5581b.g(obj);
            Object objC = gVarG.c();
            a5.a aVarD = this.f5714a.d(objC);
            k kVar = new k(aVarD, objC, this.f5714a.f5702i);
            a5.h hVar = this.f5719f.f26165a;
            i iVar = this.f5714a;
            f fVar = new f(hVar, iVar.f5707n);
            d5.c cVarA = iVar.f5701h.a();
            cVarA.f(fVar, kVar);
            if (Log.isLoggable("SourceGenerator", 2)) {
                fVar.toString();
                obj.toString();
                aVarD.toString();
                SystemClock.elapsedRealtimeNanos();
            }
            if (cVarA.get(fVar) != null) {
                this.f5720g = fVar;
                this.f5717d = new e(Collections.singletonList(this.f5719f.f26165a), this.f5714a, this);
                this.f5719f.f26167c.b();
                return true;
            }
            if (Log.isLoggable("SourceGenerator", 3)) {
                Objects.toString(this.f5720g);
                obj.toString();
            }
            try {
                this.f5715b.onDataFetcherReady(this.f5719f.f26165a, gVarG.c(), this.f5719f.f26167c, this.f5719f.f26167c.d(), this.f5719f.f26165a);
                return false;
            } catch (Throwable th) {
                th = th;
                z10 = true;
                if (!z10) {
                    this.f5719f.f26167c.b();
                }
                throw th;
            }
        } catch (Throwable th2) {
            th = th2;
        }
    }

    @Override // com.bumptech.glide.load.engine.g
    public final void onDataFetcherReady(a5.h hVar, Object obj, com.bumptech.glide.load.data.e eVar, DataSource dataSource, a5.h hVar2) {
        this.f5715b.onDataFetcherReady(hVar, obj, eVar, this.f5719f.f26167c.d(), hVar);
    }
}
