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 DataCacheGenerator implements DataFetcherGenerator, DataFetcher.DataCallback { private final List a; private final DecodeHelper b; private final DataFetcherGenerator.FetcherReadyCallback c; private int d; private Key e; private List> f; private int g; private volatile ModelLoader.LoadData h; private File i; DataCacheGenerator(DecodeHelper decodeHelper, DataFetcherGenerator.FetcherReadyCallback fetcherReadyCallback) { this(decodeHelper.c(), decodeHelper, fetcherReadyCallback); } private boolean b() { return this.g < this.f.size(); } @Override // com.bumptech.glide.load.engine.DataFetcherGenerator public boolean a() { while (true) { boolean z = false; 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 >= this.a.size()) { return false; } Key key = this.a.get(this.d); this.i = this.b.d().a(new DataCacheKey(key, this.b.k())); 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(); } } DataCacheGenerator(List list, DecodeHelper decodeHelper, DataFetcherGenerator.FetcherReadyCallback fetcherReadyCallback) { this.d = -1; this.a = list; this.b = decodeHelper; this.c = fetcherReadyCallback; } @Override // com.bumptech.glide.load.data.DataFetcher.DataCallback public void a(Object obj) { this.c.a(this.e, obj, this.h.c, DataSource.DATA_DISK_CACHE, this.e); } @Override // com.bumptech.glide.load.data.DataFetcher.DataCallback public void a(Exception exc) { this.c.a(this.e, exc, this.h.c, DataSource.DATA_DISK_CACHE); } }