package p138.p145.p146.p151.p158;

import com.bumptech.glide.load.engine.GlideException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import p000.p001.p002.p003.p004.C0567;
import p037.p065.p077.InterfaceC1902;
import p138.p139.p143.p144.C2803;
import p138.p145.p146.EnumC2812;
import p138.p145.p146.p151.C2848;
import p138.p145.p146.p151.EnumC2840;
import p138.p145.p146.p151.InterfaceC2844;
import p138.p145.p146.p151.p152.InterfaceC2856;
import p138.p145.p146.p151.p158.InterfaceC3028;

/* JADX INFO: renamed from: ދ.ؠ.֏.ތ.ދ.ގ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C3034<Model, Data> implements InterfaceC3028<Model, Data> {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final List<InterfaceC3028<Model, Data>> f9206;

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final InterfaceC1902<List<Throwable>> f9207;

    /* JADX INFO: renamed from: ދ.ؠ.֏.ތ.ދ.ގ$֏, reason: contains not printable characters */
    public static class C3035<Data> implements InterfaceC2856<Data>, InterfaceC2856.InterfaceC2857<Data> {

        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
        public final List<InterfaceC2856<Data>> f9208;

        /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
        public final InterfaceC1902<List<Throwable>> f9209;

        /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
        public int f9210;

        /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
        public EnumC2812 f9211;

        /* JADX INFO: renamed from: އ, reason: contains not printable characters */
        public InterfaceC2856.InterfaceC2857<? super Data> f9212;

        /* JADX INFO: renamed from: ވ, reason: contains not printable characters */
        public List<Throwable> f9213;

        /* JADX INFO: renamed from: މ, reason: contains not printable characters */
        public boolean f9214;

        public C3035(List<InterfaceC2856<Data>> list, InterfaceC1902<List<Throwable>> interfaceC1902) {
            this.f9209 = interfaceC1902;
            if (list.isEmpty()) {
                throw new IllegalArgumentException("Must not be empty.");
            }
            this.f9208 = list;
            this.f9210 = 0;
        }

        @Override // p138.p145.p146.p151.p152.InterfaceC2856
        public void cancel() {
            this.f9214 = true;
            Iterator<InterfaceC2856<Data>> it = this.f9208.iterator();
            while (it.hasNext()) {
                it.next().cancel();
            }
        }

        @Override // p138.p145.p146.p151.p152.InterfaceC2856
        /* JADX INFO: renamed from: ֏ */
        public Class<Data> mo4969() {
            return this.f9208.get(0).mo4969();
        }

        @Override // p138.p145.p146.p151.p152.InterfaceC2856.InterfaceC2857
        /* JADX INFO: renamed from: ֏ */
        public void mo4989(Exception exc) {
            List<Throwable> list = this.f9213;
            C0567.m1858(list, "Argument must not be null");
            list.add(exc);
            m5153();
        }

        @Override // p138.p145.p146.p151.p152.InterfaceC2856.InterfaceC2857
        /* JADX INFO: renamed from: ֏ */
        public void mo4990(Data data) {
            if (data != null) {
                this.f9212.mo4990(data);
            } else {
                m5153();
            }
        }

        @Override // p138.p145.p146.p151.p152.InterfaceC2856
        /* JADX INFO: renamed from: ֏ */
        public void mo4970(EnumC2812 enumC2812, InterfaceC2856.InterfaceC2857<? super Data> interfaceC2857) {
            this.f9211 = enumC2812;
            this.f9212 = interfaceC2857;
            this.f9213 = this.f9209.mo3716();
            this.f9208.get(this.f9210).mo4970(enumC2812, this);
            if (this.f9214) {
                cancel();
            }
        }

        @Override // p138.p145.p146.p151.p152.InterfaceC2856
        /* JADX INFO: renamed from: ؠ */
        public void mo4973() {
            List<Throwable> list = this.f9213;
            if (list != null) {
                this.f9209.mo3715(list);
            }
            this.f9213 = null;
            Iterator<InterfaceC2856<Data>> it = this.f9208.iterator();
            while (it.hasNext()) {
                it.next().mo4973();
            }
        }

        @Override // p138.p145.p146.p151.p152.InterfaceC2856
        /* JADX INFO: renamed from: ހ */
        public EnumC2840 mo4974() {
            return this.f9208.get(0).mo4974();
        }

        /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
        public final void m5153() {
            if (this.f9214) {
                return;
            }
            if (this.f9210 < this.f9208.size() - 1) {
                this.f9210++;
                mo4970(this.f9211, this.f9212);
            } else {
                C0567.m1858(this.f9213, "Argument must not be null");
                this.f9212.mo4989((Exception) new GlideException("Fetch failed", new ArrayList(this.f9213)));
            }
        }
    }

    public C3034(List<InterfaceC3028<Model, Data>> list, InterfaceC1902<List<Throwable>> interfaceC1902) {
        this.f9206 = list;
        this.f9207 = interfaceC1902;
    }

    public String toString() {
        StringBuilder sbM4889 = C2803.m4889("MultiModelLoader{modelLoaders=");
        sbM4889.append(Arrays.toString(this.f9206.toArray()));
        sbM4889.append('}');
        return sbM4889.toString();
    }

    @Override // p138.p145.p146.p151.p158.InterfaceC3028
    /* JADX INFO: renamed from: ֏ */
    public InterfaceC3028.C3029<Data> mo2519(Model model, int i, int i2, C2848 c2848) {
        InterfaceC3028.C3029<Data> c3029Mo2519;
        int size = this.f9206.size();
        ArrayList arrayList = new ArrayList(size);
        InterfaceC2844 interfaceC2844 = null;
        for (int i3 = 0; i3 < size; i3++) {
            InterfaceC3028<Model, Data> interfaceC3028 = this.f9206.get(i3);
            if (interfaceC3028.mo2520(model) && (c3029Mo2519 = interfaceC3028.mo2519(model, i, i2, c2848)) != null) {
                interfaceC2844 = c3029Mo2519.f9199;
                arrayList.add(c3029Mo2519.f9201);
            }
        }
        if (arrayList.isEmpty() || interfaceC2844 == null) {
            return null;
        }
        return new InterfaceC3028.C3029<>(interfaceC2844, new C3035(arrayList, this.f9207));
    }

    @Override // p138.p145.p146.p151.p158.InterfaceC3028
    /* JADX INFO: renamed from: ֏ */
    public boolean mo2520(Model model) {
        Iterator<InterfaceC3028<Model, Data>> it = this.f9206.iterator();
        while (it.hasNext()) {
            if (it.next().mo2520(model)) {
                return true;
            }
        }
        return false;
    }
}
