package w1; import com.bumptech.glide.load.data.d; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; import w1.m; /* loaded from: classes.dex */ class p implements m { /* renamed from: a, reason: collision with root package name */ private final List f15063a; /* renamed from: b, reason: collision with root package name */ private final y.e f15064b; static class a implements com.bumptech.glide.load.data.d, d.a { /* renamed from: a, reason: collision with root package name */ private final List f15065a; /* renamed from: b, reason: collision with root package name */ private final y.e f15066b; /* renamed from: c, reason: collision with root package name */ private int f15067c; /* renamed from: d, reason: collision with root package name */ private com.bumptech.glide.g f15068d; /* renamed from: e, reason: collision with root package name */ private d.a f15069e; /* renamed from: f, reason: collision with root package name */ private List f15070f; /* renamed from: g, reason: collision with root package name */ private boolean f15071g; a(List list, y.e eVar) { this.f15066b = eVar; m2.j.c(list); this.f15065a = list; this.f15067c = 0; } private void g() { if (this.f15071g) { return; } if (this.f15067c < this.f15065a.size() - 1) { this.f15067c++; f(this.f15068d, this.f15069e); } else { m2.j.d(this.f15070f); this.f15069e.c(new s1.q("Fetch failed", new ArrayList(this.f15070f))); } } @Override // com.bumptech.glide.load.data.d public Class a() { return ((com.bumptech.glide.load.data.d) this.f15065a.get(0)).a(); } @Override // com.bumptech.glide.load.data.d public void b() { List list = this.f15070f; if (list != null) { this.f15066b.a(list); } this.f15070f = null; Iterator it = this.f15065a.iterator(); while (it.hasNext()) { ((com.bumptech.glide.load.data.d) it.next()).b(); } } @Override // com.bumptech.glide.load.data.d.a public void c(Exception exc) { ((List) m2.j.d(this.f15070f)).add(exc); g(); } @Override // com.bumptech.glide.load.data.d public void cancel() { this.f15071g = true; Iterator it = this.f15065a.iterator(); while (it.hasNext()) { ((com.bumptech.glide.load.data.d) it.next()).cancel(); } } @Override // com.bumptech.glide.load.data.d public q1.a d() { return ((com.bumptech.glide.load.data.d) this.f15065a.get(0)).d(); } @Override // com.bumptech.glide.load.data.d.a public void e(Object obj) { if (obj != null) { this.f15069e.e(obj); } else { g(); } } @Override // com.bumptech.glide.load.data.d public void f(com.bumptech.glide.g gVar, d.a aVar) { this.f15068d = gVar; this.f15069e = aVar; this.f15070f = (List) this.f15066b.b(); ((com.bumptech.glide.load.data.d) this.f15065a.get(this.f15067c)).f(gVar, this); if (this.f15071g) { cancel(); } } } p(List list, y.e eVar) { this.f15063a = list; this.f15064b = eVar; } @Override // w1.m public boolean a(Object obj) { Iterator it = this.f15063a.iterator(); while (it.hasNext()) { if (((m) it.next()).a(obj)) { return true; } } return false; } @Override // w1.m public m.a b(Object obj, int i10, int i11, q1.h hVar) { m.a b10; int size = this.f15063a.size(); ArrayList arrayList = new ArrayList(size); q1.f fVar = null; for (int i12 = 0; i12 < size; i12++) { m mVar = (m) this.f15063a.get(i12); if (mVar.a(obj) && (b10 = mVar.b(obj, i10, i11, hVar)) != null) { fVar = b10.f15056a; arrayList.add(b10.f15058c); } } if (arrayList.isEmpty() || fVar == null) { return null; } return new m.a(fVar, new a(arrayList, this.f15064b)); } public String toString() { return "MultiModelLoader{modelLoaders=" + Arrays.toString(this.f15063a.toArray()) + '}'; } }