78 lines
3.2 KiB
Java
78 lines
3.2 KiB
Java
package com.bumptech.glide.load.engine;
|
|
|
|
import android.util.Log;
|
|
import androidx.core.util.Pools$Pool;
|
|
import com.bumptech.glide.load.Options;
|
|
import com.bumptech.glide.load.ResourceDecoder;
|
|
import com.bumptech.glide.load.data.DataRewinder;
|
|
import com.bumptech.glide.load.resource.transcode.ResourceTranscoder;
|
|
import com.bumptech.glide.util.Preconditions;
|
|
import java.io.IOException;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class DecodePath<DataType, ResourceType, Transcode> {
|
|
private final Class<DataType> a;
|
|
private final List<? extends ResourceDecoder<DataType, ResourceType>> b;
|
|
private final ResourceTranscoder<ResourceType, Transcode> c;
|
|
private final Pools$Pool<List<Throwable>> d;
|
|
private final String e;
|
|
|
|
interface DecodeCallback<ResourceType> {
|
|
Resource<ResourceType> a(Resource<ResourceType> resource);
|
|
}
|
|
|
|
public DecodePath(Class<DataType> cls, Class<ResourceType> cls2, Class<Transcode> cls3, List<? extends ResourceDecoder<DataType, ResourceType>> list, ResourceTranscoder<ResourceType, Transcode> resourceTranscoder, Pools$Pool<List<Throwable>> pools$Pool) {
|
|
this.a = cls;
|
|
this.b = list;
|
|
this.c = resourceTranscoder;
|
|
this.d = pools$Pool;
|
|
this.e = "Failed DecodePath{" + cls.getSimpleName() + "->" + cls2.getSimpleName() + "->" + cls3.getSimpleName() + "}";
|
|
}
|
|
|
|
public Resource<Transcode> a(DataRewinder<DataType> dataRewinder, int i, int i2, Options options, DecodeCallback<ResourceType> decodeCallback) throws GlideException {
|
|
return this.c.a(decodeCallback.a(a(dataRewinder, i, i2, options)), options);
|
|
}
|
|
|
|
public String toString() {
|
|
return "DecodePath{ dataClass=" + this.a + ", decoders=" + this.b + ", transcoder=" + this.c + '}';
|
|
}
|
|
|
|
private Resource<ResourceType> a(DataRewinder<DataType> dataRewinder, int i, int i2, Options options) throws GlideException {
|
|
List<Throwable> a = this.d.a();
|
|
Preconditions.a(a);
|
|
List<Throwable> list = a;
|
|
try {
|
|
return a(dataRewinder, i, i2, options, list);
|
|
} finally {
|
|
this.d.a(list);
|
|
}
|
|
}
|
|
|
|
private Resource<ResourceType> a(DataRewinder<DataType> dataRewinder, int i, int i2, Options options, List<Throwable> list) throws GlideException {
|
|
int size = this.b.size();
|
|
Resource<ResourceType> resource = null;
|
|
for (int i3 = 0; i3 < size; i3++) {
|
|
ResourceDecoder<DataType, ResourceType> resourceDecoder = this.b.get(i3);
|
|
try {
|
|
if (resourceDecoder.a(dataRewinder.a(), options)) {
|
|
resource = resourceDecoder.a(dataRewinder.a(), i, i2, options);
|
|
}
|
|
} catch (IOException | OutOfMemoryError | RuntimeException e) {
|
|
if (Log.isLoggable("DecodePath", 2)) {
|
|
Log.v("DecodePath", "Failed to decode data for " + resourceDecoder, e);
|
|
}
|
|
list.add(e);
|
|
}
|
|
if (resource != null) {
|
|
break;
|
|
}
|
|
}
|
|
if (resource != null) {
|
|
return resource;
|
|
}
|
|
throw new GlideException(this.e, new ArrayList(list));
|
|
}
|
|
}
|