package com.bumptech.glide.load.engine; import com.bumptech.glide.load.DataSource; import com.bumptech.glide.load.Key; import com.bumptech.glide.load.data.DataFetcher; import com.bumptech.glide.load.engine.DataFetcherGenerator; import com.bumptech.glide.load.model.ModelLoader; import java.io.File; import java.util.List; /* loaded from: classes.dex */ class ResourceCacheGenerator implements DataFetcherGenerator, DataFetcher.DataCallback { private final DataFetcherGenerator.FetcherReadyCallback a; private final DecodeHelper b; private int c; private int d = -1; private Key e; private List> f; private int g; private volatile ModelLoader.LoadData h; private File i; private ResourceCacheKey j; ResourceCacheGenerator(DecodeHelper decodeHelper, DataFetcherGenerator.FetcherReadyCallback fetcherReadyCallback) { this.b = decodeHelper; this.a = fetcherReadyCallback; } private boolean b() { return this.g < this.f.size(); } @Override // com.bumptech.glide.load.engine.DataFetcherGenerator public boolean a() { List c = this.b.c(); boolean z = false; if (c.isEmpty()) { return false; } List> j = this.b.j(); if (j.isEmpty() && File.class.equals(this.b.l())) { return false; } while (true) { if (this.f != null && b()) { this.h = null; while (!z && b()) { List> list = this.f; int i = this.g; this.g = i + 1; this.h = list.get(i).a(this.i, this.b.m(), this.b.f(), this.b.h()); if (this.h != null && this.b.c(this.h.c.a())) { this.h.c.a(this.b.i(), this); z = true; } } return z; } this.d++; if (this.d >= j.size()) { this.c++; if (this.c >= c.size()) { return false; } this.d = 0; } Key key = c.get(this.c); Class cls = j.get(this.d); this.j = new ResourceCacheKey(this.b.b(), key, this.b.k(), this.b.m(), this.b.f(), this.b.b(cls), cls, this.b.h()); this.i = this.b.d().a(this.j); File file = this.i; if (file != null) { this.e = key; this.f = this.b.a(file); this.g = 0; } } } @Override // com.bumptech.glide.load.engine.DataFetcherGenerator public void cancel() { ModelLoader.LoadData loadData = this.h; if (loadData != null) { loadData.c.cancel(); } } @Override // com.bumptech.glide.load.data.DataFetcher.DataCallback public void a(Object obj) { this.a.a(this.e, obj, this.h.c, DataSource.RESOURCE_DISK_CACHE, this.j); } @Override // com.bumptech.glide.load.data.DataFetcher.DataCallback public void a(Exception exc) { this.a.a(this.j, exc, this.h.c, DataSource.RESOURCE_DISK_CACHE); } }