Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
package com.bumptech.glide.load;
/* loaded from: classes.dex */
public enum DataSource {
LOCAL,
REMOTE,
DATA_DISK_CACHE,
RESOURCE_DISK_CACHE,
MEMORY_CACHE
}

View File

@@ -0,0 +1,10 @@
package com.bumptech.glide.load;
/* loaded from: classes.dex */
public enum DecodeFormat {
PREFER_ARGB_8888,
PREFER_ARGB_8888_DISALLOW_HARDWARE,
PREFER_RGB_565;
public static final DecodeFormat DEFAULT = PREFER_ARGB_8888_DISALLOW_HARDWARE;
}

View File

@@ -0,0 +1,8 @@
package com.bumptech.glide.load;
/* loaded from: classes.dex */
public enum EncodeStrategy {
SOURCE,
TRANSFORMED,
NONE
}

View File

@@ -0,0 +1,8 @@
package com.bumptech.glide.load;
import java.io.File;
/* loaded from: classes.dex */
public interface Encoder<T> {
boolean a(T t, File file, Options options);
}

View File

@@ -0,0 +1,31 @@
package com.bumptech.glide.load;
import java.io.IOException;
/* loaded from: classes.dex */
public final class HttpException extends IOException {
public static final int UNKNOWN = -1;
private static final long serialVersionUID = 1;
private final int statusCode;
public HttpException(int i) {
this("Http request failed with status code: " + i, i);
}
public int getStatusCode() {
return this.statusCode;
}
public HttpException(String str) {
this(str, -1);
}
public HttpException(String str, int i) {
this(str, i, null);
}
public HttpException(String str, int i, Throwable th) {
super(str, th);
this.statusCode = i;
}
}

View File

@@ -0,0 +1,37 @@
package com.bumptech.glide.load;
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
/* loaded from: classes.dex */
public interface ImageHeaderParser {
public enum ImageType {
GIF(true),
JPEG(false),
RAW(false),
PNG_A(true),
PNG(false),
WEBP_A(true),
WEBP(false),
UNKNOWN(false);
private final boolean hasAlpha;
ImageType(boolean z) {
this.hasAlpha = z;
}
public boolean hasAlpha() {
return this.hasAlpha;
}
}
int a(InputStream inputStream, ArrayPool arrayPool) throws IOException;
ImageType a(InputStream inputStream) throws IOException;
ImageType a(ByteBuffer byteBuffer) throws IOException;
}

View File

@@ -0,0 +1,72 @@
package com.bumptech.glide.load;
import com.bumptech.glide.load.ImageHeaderParser;
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
import com.bumptech.glide.load.resource.bitmap.RecyclableBufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.List;
/* loaded from: classes.dex */
public final class ImageHeaderParserUtils {
public static ImageHeaderParser.ImageType a(List<ImageHeaderParser> list, ByteBuffer byteBuffer) throws IOException {
if (byteBuffer == null) {
return ImageHeaderParser.ImageType.UNKNOWN;
}
int size = list.size();
for (int i = 0; i < size; i++) {
ImageHeaderParser.ImageType a = list.get(i).a(byteBuffer);
if (a != ImageHeaderParser.ImageType.UNKNOWN) {
return a;
}
}
return ImageHeaderParser.ImageType.UNKNOWN;
}
public static ImageHeaderParser.ImageType b(List<ImageHeaderParser> list, InputStream inputStream, ArrayPool arrayPool) throws IOException {
if (inputStream == null) {
return ImageHeaderParser.ImageType.UNKNOWN;
}
if (!inputStream.markSupported()) {
inputStream = new RecyclableBufferedInputStream(inputStream, arrayPool);
}
inputStream.mark(5242880);
int size = list.size();
for (int i = 0; i < size; i++) {
try {
ImageHeaderParser.ImageType a = list.get(i).a(inputStream);
if (a != ImageHeaderParser.ImageType.UNKNOWN) {
return a;
}
inputStream.reset();
} finally {
inputStream.reset();
}
}
return ImageHeaderParser.ImageType.UNKNOWN;
}
public static int a(List<ImageHeaderParser> list, InputStream inputStream, ArrayPool arrayPool) throws IOException {
if (inputStream == null) {
return -1;
}
if (!inputStream.markSupported()) {
inputStream = new RecyclableBufferedInputStream(inputStream, arrayPool);
}
inputStream.mark(5242880);
int size = list.size();
for (int i = 0; i < size; i++) {
try {
int a = list.get(i).a(inputStream, arrayPool);
if (a != -1) {
return a;
}
inputStream.reset();
} finally {
inputStream.reset();
}
}
return -1;
}
}

View File

@@ -0,0 +1,15 @@
package com.bumptech.glide.load;
import java.nio.charset.Charset;
import java.security.MessageDigest;
/* loaded from: classes.dex */
public interface Key {
public static final Charset a = Charset.forName("UTF-8");
void a(MessageDigest messageDigest);
boolean equals(Object obj);
int hashCode();
}

View File

@@ -0,0 +1,75 @@
package com.bumptech.glide.load;
import com.bumptech.glide.util.Preconditions;
import java.security.MessageDigest;
/* loaded from: classes.dex */
public final class Option<T> {
private static final CacheKeyUpdater<Object> e = new CacheKeyUpdater<Object>() { // from class: com.bumptech.glide.load.Option.1
@Override // com.bumptech.glide.load.Option.CacheKeyUpdater
public void a(byte[] bArr, Object obj, MessageDigest messageDigest) {
}
};
private final T a;
private final CacheKeyUpdater<T> b;
private final String c;
private volatile byte[] d;
public interface CacheKeyUpdater<T> {
void a(byte[] bArr, T t, MessageDigest messageDigest);
}
private Option(String str, T t, CacheKeyUpdater<T> cacheKeyUpdater) {
Preconditions.a(str);
this.c = str;
this.a = t;
Preconditions.a(cacheKeyUpdater);
this.b = cacheKeyUpdater;
}
public static <T> Option<T> a(String str) {
return new Option<>(str, null, b());
}
private static <T> CacheKeyUpdater<T> b() {
return (CacheKeyUpdater<T>) e;
}
private byte[] c() {
if (this.d == null) {
this.d = this.c.getBytes(Key.a);
}
return this.d;
}
public boolean equals(Object obj) {
if (obj instanceof Option) {
return this.c.equals(((Option) obj).c);
}
return false;
}
public int hashCode() {
return this.c.hashCode();
}
public String toString() {
return "Option{key='" + this.c + "'}";
}
public static <T> Option<T> a(String str, T t) {
return new Option<>(str, t, b());
}
public static <T> Option<T> a(String str, T t, CacheKeyUpdater<T> cacheKeyUpdater) {
return new Option<>(str, t, cacheKeyUpdater);
}
public T a() {
return this.a;
}
public void a(T t, MessageDigest messageDigest) {
this.b.a(c(), t, messageDigest);
}
}

View File

@@ -0,0 +1,53 @@
package com.bumptech.glide.load;
import androidx.collection.ArrayMap;
import androidx.collection.SimpleArrayMap;
import com.bumptech.glide.util.CachedHashCodeArrayMap;
import java.security.MessageDigest;
/* loaded from: classes.dex */
public final class Options implements Key {
private final ArrayMap<Option<?>, Object> b = new CachedHashCodeArrayMap();
public void a(Options options) {
this.b.a((SimpleArrayMap<? extends Option<?>, ? extends Object>) options.b);
}
@Override // com.bumptech.glide.load.Key
public boolean equals(Object obj) {
if (obj instanceof Options) {
return this.b.equals(((Options) obj).b);
}
return false;
}
@Override // com.bumptech.glide.load.Key
public int hashCode() {
return this.b.hashCode();
}
public String toString() {
return "Options{values=" + this.b + '}';
}
public <T> Options a(Option<T> option, T t) {
this.b.put(option, t);
return this;
}
public <T> T a(Option<T> option) {
return this.b.containsKey(option) ? (T) this.b.get(option) : option.a();
}
@Override // com.bumptech.glide.load.Key
public void a(MessageDigest messageDigest) {
for (int i = 0; i < this.b.size(); i++) {
a(this.b.b(i), this.b.d(i), messageDigest);
}
}
/* JADX WARN: Multi-variable type inference failed */
private static <T> void a(Option<T> option, Object obj, MessageDigest messageDigest) {
option.a((Option<T>) obj, messageDigest);
}
}

View File

@@ -0,0 +1,11 @@
package com.bumptech.glide.load;
import com.bumptech.glide.load.engine.Resource;
import java.io.IOException;
/* loaded from: classes.dex */
public interface ResourceDecoder<T, Z> {
Resource<Z> a(T t, int i, int i2, Options options) throws IOException;
boolean a(T t, Options options) throws IOException;
}

View File

@@ -0,0 +1,8 @@
package com.bumptech.glide.load;
import com.bumptech.glide.load.engine.Resource;
/* loaded from: classes.dex */
public interface ResourceEncoder<T> extends Encoder<Resource<T>> {
EncodeStrategy a(Options options);
}

View File

@@ -0,0 +1,9 @@
package com.bumptech.glide.load;
import android.content.Context;
import com.bumptech.glide.load.engine.Resource;
/* loaded from: classes.dex */
public interface Transformation<T> extends Key {
Resource<T> a(Context context, Resource<T> resource, int i, int i2);
}

View File

@@ -0,0 +1,36 @@
package com.bumptech.glide.load.data;
import android.content.ContentResolver;
import android.content.res.AssetFileDescriptor;
import android.net.Uri;
import java.io.FileNotFoundException;
import java.io.IOException;
/* loaded from: classes.dex */
public final class AssetFileDescriptorLocalUriFetcher extends LocalUriFetcher<AssetFileDescriptor> {
public AssetFileDescriptorLocalUriFetcher(ContentResolver contentResolver, Uri uri) {
super(contentResolver, uri);
}
/* JADX INFO: Access modifiers changed from: protected */
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.load.data.LocalUriFetcher
public AssetFileDescriptor a(Uri uri, ContentResolver contentResolver) throws FileNotFoundException {
AssetFileDescriptor openAssetFileDescriptor = contentResolver.openAssetFileDescriptor(uri, "r");
if (openAssetFileDescriptor != null) {
return openAssetFileDescriptor;
}
throw new FileNotFoundException("FileDescriptor is null for: " + uri);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.bumptech.glide.load.data.LocalUriFetcher
public void a(AssetFileDescriptor assetFileDescriptor) throws IOException {
assetFileDescriptor.close();
}
@Override // com.bumptech.glide.load.data.DataFetcher
public Class<AssetFileDescriptor> a() {
return AssetFileDescriptor.class;
}
}

View File

@@ -0,0 +1,58 @@
package com.bumptech.glide.load.data;
import android.content.res.AssetManager;
import android.util.Log;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.data.DataFetcher;
import java.io.IOException;
/* loaded from: classes.dex */
public abstract class AssetPathFetcher<T> implements DataFetcher<T> {
private final String a;
private final AssetManager b;
private T c;
public AssetPathFetcher(AssetManager assetManager, String str) {
this.b = assetManager;
this.a = str;
}
protected abstract T a(AssetManager assetManager, String str) throws IOException;
@Override // com.bumptech.glide.load.data.DataFetcher
public void a(Priority priority, DataFetcher.DataCallback<? super T> dataCallback) {
try {
this.c = a(this.b, this.a);
dataCallback.a((DataFetcher.DataCallback<? super T>) this.c);
} catch (IOException e) {
if (Log.isLoggable("AssetPathFetcher", 3)) {
Log.d("AssetPathFetcher", "Failed to load data from asset manager", e);
}
dataCallback.a((Exception) e);
}
}
protected abstract void a(T t) throws IOException;
@Override // com.bumptech.glide.load.data.DataFetcher
public void b() {
T t = this.c;
if (t == null) {
return;
}
try {
a(t);
} catch (IOException unused) {
}
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void cancel() {
}
@Override // com.bumptech.glide.load.data.DataFetcher
public DataSource getDataSource() {
return DataSource.LOCAL;
}
}

View File

@@ -0,0 +1,95 @@
package com.bumptech.glide.load.data;
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
import java.io.IOException;
import java.io.OutputStream;
/* loaded from: classes.dex */
public final class BufferedOutputStream extends OutputStream {
private final OutputStream a;
private byte[] b;
private ArrayPool c;
private int d;
public BufferedOutputStream(OutputStream outputStream, ArrayPool arrayPool) {
this(outputStream, arrayPool, 65536);
}
private void a() throws IOException {
int i = this.d;
if (i > 0) {
this.a.write(this.b, 0, i);
this.d = 0;
}
}
private void b() throws IOException {
if (this.d == this.b.length) {
a();
}
}
private void c() {
byte[] bArr = this.b;
if (bArr != null) {
this.c.put(bArr);
this.b = null;
}
}
@Override // java.io.OutputStream, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
try {
flush();
this.a.close();
c();
} catch (Throwable th) {
this.a.close();
throw th;
}
}
@Override // java.io.OutputStream, java.io.Flushable
public void flush() throws IOException {
a();
this.a.flush();
}
@Override // java.io.OutputStream
public void write(int i) throws IOException {
byte[] bArr = this.b;
int i2 = this.d;
this.d = i2 + 1;
bArr[i2] = (byte) i;
b();
}
BufferedOutputStream(OutputStream outputStream, ArrayPool arrayPool, int i) {
this.a = outputStream;
this.c = arrayPool;
this.b = (byte[]) arrayPool.b(i, byte[].class);
}
@Override // java.io.OutputStream
public void write(byte[] bArr) throws IOException {
write(bArr, 0, bArr.length);
}
@Override // java.io.OutputStream
public void write(byte[] bArr, int i, int i2) throws IOException {
int i3 = 0;
do {
int i4 = i2 - i3;
int i5 = i + i3;
if (this.d == 0 && i4 >= this.b.length) {
this.a.write(bArr, i5, i4);
return;
}
int min = Math.min(i4, this.b.length - this.d);
System.arraycopy(bArr, i5, this.b, this.d, min);
this.d += min;
i3 += min;
b();
} while (i3 < i2);
}
}

View File

@@ -0,0 +1,24 @@
package com.bumptech.glide.load.data;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
/* loaded from: classes.dex */
public interface DataFetcher<T> {
public interface DataCallback<T> {
void a(Exception exc);
void a(T t);
}
Class<T> a();
void a(Priority priority, DataCallback<? super T> dataCallback);
void b();
void cancel();
DataSource getDataSource();
}

View File

@@ -0,0 +1,17 @@
package com.bumptech.glide.load.data;
import java.io.IOException;
/* loaded from: classes.dex */
public interface DataRewinder<T> {
public interface Factory<T> {
DataRewinder<T> a(T t);
Class<T> a();
}
T a() throws IOException;
void b();
}

View File

@@ -0,0 +1,67 @@
package com.bumptech.glide.load.data;
import com.bumptech.glide.load.data.DataRewinder;
import com.bumptech.glide.util.Preconditions;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/* loaded from: classes.dex */
public class DataRewinderRegistry {
private static final DataRewinder.Factory<?> b = new DataRewinder.Factory<Object>() { // from class: com.bumptech.glide.load.data.DataRewinderRegistry.1
@Override // com.bumptech.glide.load.data.DataRewinder.Factory
public DataRewinder<Object> a(Object obj) {
return new DefaultRewinder(obj);
}
@Override // com.bumptech.glide.load.data.DataRewinder.Factory
public Class<Object> a() {
throw new UnsupportedOperationException("Not implemented");
}
};
private final Map<Class<?>, DataRewinder.Factory<?>> a = new HashMap();
private static final class DefaultRewinder implements DataRewinder<Object> {
private final Object a;
DefaultRewinder(Object obj) {
this.a = obj;
}
@Override // com.bumptech.glide.load.data.DataRewinder
public Object a() {
return this.a;
}
@Override // com.bumptech.glide.load.data.DataRewinder
public void b() {
}
}
public synchronized void a(DataRewinder.Factory<?> factory) {
this.a.put(factory.a(), factory);
}
public synchronized <T> DataRewinder<T> a(T t) {
DataRewinder.Factory<?> factory;
Preconditions.a(t);
factory = this.a.get(t.getClass());
if (factory == null) {
Iterator<DataRewinder.Factory<?>> it = this.a.values().iterator();
while (true) {
if (!it.hasNext()) {
break;
}
DataRewinder.Factory<?> next = it.next();
if (next.a().isAssignableFrom(t.getClass())) {
factory = next;
break;
}
}
}
if (factory == null) {
factory = b;
}
return (DataRewinder<T>) factory.a(t);
}
}

View File

@@ -0,0 +1,81 @@
package com.bumptech.glide.load.data;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
/* loaded from: classes.dex */
public final class ExifOrientationStream extends FilterInputStream {
private static final byte[] c = {-1, -31, 0, 28, 69, 120, 105, 102, 0, 0, 77, 77, 0, 0, 0, 0, 0, 8, 0, 1, 1, 18, 0, 2, 0, 0, 0, 1, 0};
private static final int d = c.length;
private static final int e = d + 2;
private final byte a;
private int b;
public ExifOrientationStream(InputStream inputStream, int i) {
super(inputStream);
if (i >= -1 && i <= 8) {
this.a = (byte) i;
return;
}
throw new IllegalArgumentException("Cannot add invalid orientation: " + i);
}
@Override // java.io.FilterInputStream, java.io.InputStream
public void mark(int i) {
throw new UnsupportedOperationException();
}
@Override // java.io.FilterInputStream, java.io.InputStream
public boolean markSupported() {
return false;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public int read() throws IOException {
int i;
int i2 = this.b;
int read = (i2 < 2 || i2 > (i = e)) ? super.read() : i2 == i ? this.a : c[i2 - 2] & 255;
if (read != -1) {
this.b++;
}
return read;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public void reset() throws IOException {
throw new UnsupportedOperationException();
}
@Override // java.io.FilterInputStream, java.io.InputStream
public long skip(long j) throws IOException {
long skip = super.skip(j);
if (skip > 0) {
this.b = (int) (this.b + skip);
}
return skip;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public int read(byte[] bArr, int i, int i2) throws IOException {
int i3;
int i4 = this.b;
int i5 = e;
if (i4 > i5) {
i3 = super.read(bArr, i, i2);
} else if (i4 == i5) {
bArr[i] = this.a;
i3 = 1;
} else if (i4 < 2) {
i3 = super.read(bArr, i, 2 - i4);
} else {
int min = Math.min(i5 - i4, i2);
System.arraycopy(c, this.b - 2, bArr, i, min);
i3 = min;
}
if (i3 > 0) {
this.b += i3;
}
return i3;
}
}

View File

@@ -0,0 +1,30 @@
package com.bumptech.glide.load.data;
import android.content.res.AssetManager;
import android.os.ParcelFileDescriptor;
import java.io.IOException;
/* loaded from: classes.dex */
public class FileDescriptorAssetPathFetcher extends AssetPathFetcher<ParcelFileDescriptor> {
public FileDescriptorAssetPathFetcher(AssetManager assetManager, String str) {
super(assetManager, str);
}
/* JADX INFO: Access modifiers changed from: protected */
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.load.data.AssetPathFetcher
public ParcelFileDescriptor a(AssetManager assetManager, String str) throws IOException {
return assetManager.openFd(str).getParcelFileDescriptor();
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.bumptech.glide.load.data.AssetPathFetcher
public void a(ParcelFileDescriptor parcelFileDescriptor) throws IOException {
parcelFileDescriptor.close();
}
@Override // com.bumptech.glide.load.data.DataFetcher
public Class<ParcelFileDescriptor> a() {
return ParcelFileDescriptor.class;
}
}

View File

@@ -0,0 +1,37 @@
package com.bumptech.glide.load.data;
import android.content.ContentResolver;
import android.content.res.AssetFileDescriptor;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import java.io.FileNotFoundException;
import java.io.IOException;
/* loaded from: classes.dex */
public class FileDescriptorLocalUriFetcher extends LocalUriFetcher<ParcelFileDescriptor> {
public FileDescriptorLocalUriFetcher(ContentResolver contentResolver, Uri uri) {
super(contentResolver, uri);
}
/* JADX INFO: Access modifiers changed from: protected */
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.load.data.LocalUriFetcher
public ParcelFileDescriptor a(Uri uri, ContentResolver contentResolver) throws FileNotFoundException {
AssetFileDescriptor openAssetFileDescriptor = contentResolver.openAssetFileDescriptor(uri, "r");
if (openAssetFileDescriptor != null) {
return openAssetFileDescriptor.getParcelFileDescriptor();
}
throw new FileNotFoundException("FileDescriptor is null for: " + uri);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.bumptech.glide.load.data.LocalUriFetcher
public void a(ParcelFileDescriptor parcelFileDescriptor) throws IOException {
parcelFileDescriptor.close();
}
@Override // com.bumptech.glide.load.data.DataFetcher
public Class<ParcelFileDescriptor> a() {
return ParcelFileDescriptor.class;
}
}

View File

@@ -0,0 +1,180 @@
package com.bumptech.glide.load.data;
import android.text.TextUtils;
import android.util.Log;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.HttpException;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.util.ContentLengthInputStream;
import com.bumptech.glide.util.LogTime;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Map;
/* loaded from: classes.dex */
public class HttpUrlFetcher implements DataFetcher<InputStream> {
static final HttpUrlConnectionFactory g = new DefaultHttpUrlConnectionFactory();
private final GlideUrl a;
private final int b;
private final HttpUrlConnectionFactory c;
private HttpURLConnection d;
private InputStream e;
private volatile boolean f;
private static class DefaultHttpUrlConnectionFactory implements HttpUrlConnectionFactory {
DefaultHttpUrlConnectionFactory() {
}
@Override // com.bumptech.glide.load.data.HttpUrlFetcher.HttpUrlConnectionFactory
public HttpURLConnection a(URL url) throws IOException {
return (HttpURLConnection) url.openConnection();
}
}
interface HttpUrlConnectionFactory {
HttpURLConnection a(URL url) throws IOException;
}
public HttpUrlFetcher(GlideUrl glideUrl, int i) {
this(glideUrl, i, g);
}
private static boolean b(int i) {
return i / 100 == 3;
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void a(Priority priority, DataFetcher.DataCallback<? super InputStream> dataCallback) {
StringBuilder sb;
long a = LogTime.a();
try {
try {
dataCallback.a((DataFetcher.DataCallback<? super InputStream>) a(this.a.d(), 0, null, this.a.b()));
} catch (IOException e) {
if (Log.isLoggable("HttpUrlFetcher", 3)) {
Log.d("HttpUrlFetcher", "Failed to load data for url", e);
}
dataCallback.a((Exception) e);
if (!Log.isLoggable("HttpUrlFetcher", 2)) {
return;
} else {
sb = new StringBuilder();
}
}
if (Log.isLoggable("HttpUrlFetcher", 2)) {
sb = new StringBuilder();
sb.append("Finished http url fetcher fetch in ");
sb.append(LogTime.a(a));
Log.v("HttpUrlFetcher", sb.toString());
}
} catch (Throwable th) {
if (Log.isLoggable("HttpUrlFetcher", 2)) {
Log.v("HttpUrlFetcher", "Finished http url fetcher fetch in " + LogTime.a(a));
}
throw th;
}
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void cancel() {
this.f = true;
}
@Override // com.bumptech.glide.load.data.DataFetcher
public DataSource getDataSource() {
return DataSource.REMOTE;
}
HttpUrlFetcher(GlideUrl glideUrl, int i, HttpUrlConnectionFactory httpUrlConnectionFactory) {
this.a = glideUrl;
this.b = i;
this.c = httpUrlConnectionFactory;
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void b() {
InputStream inputStream = this.e;
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException unused) {
}
}
HttpURLConnection httpURLConnection = this.d;
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
this.d = null;
}
private InputStream a(URL url, int i, URL url2, Map<String, String> map) throws IOException {
if (i < 5) {
if (url2 != null) {
try {
if (url.toURI().equals(url2.toURI())) {
throw new HttpException("In re-direct loop");
}
} catch (URISyntaxException unused) {
}
}
this.d = this.c.a(url);
for (Map.Entry<String, String> entry : map.entrySet()) {
this.d.addRequestProperty(entry.getKey(), entry.getValue());
}
this.d.setConnectTimeout(this.b);
this.d.setReadTimeout(this.b);
this.d.setUseCaches(false);
this.d.setDoInput(true);
this.d.setInstanceFollowRedirects(false);
this.d.connect();
this.e = this.d.getInputStream();
if (this.f) {
return null;
}
int responseCode = this.d.getResponseCode();
if (a(responseCode)) {
return a(this.d);
}
if (!b(responseCode)) {
if (responseCode == -1) {
throw new HttpException(responseCode);
}
throw new HttpException(this.d.getResponseMessage(), responseCode);
}
String headerField = this.d.getHeaderField("Location");
if (!TextUtils.isEmpty(headerField)) {
URL url3 = new URL(url, headerField);
b();
return a(url3, i + 1, url, map);
}
throw new HttpException("Received empty or null redirect url");
}
throw new HttpException("Too many (> 5) redirects!");
}
private static boolean a(int i) {
return i / 100 == 2;
}
private InputStream a(HttpURLConnection httpURLConnection) throws IOException {
if (TextUtils.isEmpty(httpURLConnection.getContentEncoding())) {
this.e = ContentLengthInputStream.a(httpURLConnection.getInputStream(), httpURLConnection.getContentLength());
} else {
if (Log.isLoggable("HttpUrlFetcher", 3)) {
Log.d("HttpUrlFetcher", "Got non empty content encoding: " + httpURLConnection.getContentEncoding());
}
this.e = httpURLConnection.getInputStream();
}
return this.e;
}
@Override // com.bumptech.glide.load.data.DataFetcher
public Class<InputStream> a() {
return InputStream.class;
}
}

View File

@@ -0,0 +1,47 @@
package com.bumptech.glide.load.data;
import com.bumptech.glide.load.data.DataRewinder;
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
import com.bumptech.glide.load.resource.bitmap.RecyclableBufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
/* loaded from: classes.dex */
public final class InputStreamRewinder implements DataRewinder<InputStream> {
private final RecyclableBufferedInputStream a;
public static final class Factory implements DataRewinder.Factory<InputStream> {
private final ArrayPool a;
public Factory(ArrayPool arrayPool) {
this.a = arrayPool;
}
@Override // com.bumptech.glide.load.data.DataRewinder.Factory
public DataRewinder<InputStream> a(InputStream inputStream) {
return new InputStreamRewinder(inputStream, this.a);
}
@Override // com.bumptech.glide.load.data.DataRewinder.Factory
public Class<InputStream> a() {
return InputStream.class;
}
}
InputStreamRewinder(InputStream inputStream, ArrayPool arrayPool) {
this.a = new RecyclableBufferedInputStream(inputStream, arrayPool);
this.a.mark(5242880);
}
@Override // com.bumptech.glide.load.data.DataRewinder
public void b() {
this.a.b();
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.load.data.DataRewinder
public InputStream a() throws IOException {
this.a.reset();
return this.a;
}
}

View File

@@ -0,0 +1,59 @@
package com.bumptech.glide.load.data;
import android.content.ContentResolver;
import android.net.Uri;
import android.util.Log;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.data.DataFetcher;
import java.io.FileNotFoundException;
import java.io.IOException;
/* loaded from: classes.dex */
public abstract class LocalUriFetcher<T> implements DataFetcher<T> {
private final Uri a;
private final ContentResolver b;
private T c;
public LocalUriFetcher(ContentResolver contentResolver, Uri uri) {
this.b = contentResolver;
this.a = uri;
}
protected abstract T a(Uri uri, ContentResolver contentResolver) throws FileNotFoundException;
@Override // com.bumptech.glide.load.data.DataFetcher
public final void a(Priority priority, DataFetcher.DataCallback<? super T> dataCallback) {
try {
this.c = a(this.a, this.b);
dataCallback.a((DataFetcher.DataCallback<? super T>) this.c);
} catch (FileNotFoundException e) {
if (Log.isLoggable("LocalUriFetcher", 3)) {
Log.d("LocalUriFetcher", "Failed to open Uri", e);
}
dataCallback.a((Exception) e);
}
}
protected abstract void a(T t) throws IOException;
@Override // com.bumptech.glide.load.data.DataFetcher
public void b() {
T t = this.c;
if (t != null) {
try {
a(t);
} catch (IOException unused) {
}
}
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void cancel() {
}
@Override // com.bumptech.glide.load.data.DataFetcher
public DataSource getDataSource() {
return DataSource.LOCAL;
}
}

View File

@@ -0,0 +1,30 @@
package com.bumptech.glide.load.data;
import android.content.res.AssetManager;
import java.io.IOException;
import java.io.InputStream;
/* loaded from: classes.dex */
public class StreamAssetPathFetcher extends AssetPathFetcher<InputStream> {
public StreamAssetPathFetcher(AssetManager assetManager, String str) {
super(assetManager, str);
}
/* JADX INFO: Access modifiers changed from: protected */
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.load.data.AssetPathFetcher
public InputStream a(AssetManager assetManager, String str) throws IOException {
return assetManager.open(str);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.bumptech.glide.load.data.AssetPathFetcher
public void a(InputStream inputStream) throws IOException {
inputStream.close();
}
@Override // com.bumptech.glide.load.data.DataFetcher
public Class<InputStream> a() {
return InputStream.class;
}
}

View File

@@ -0,0 +1,70 @@
package com.bumptech.glide.load.data;
import android.content.ContentResolver;
import android.content.UriMatcher;
import android.net.Uri;
import android.provider.ContactsContract;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
/* loaded from: classes.dex */
public class StreamLocalUriFetcher extends LocalUriFetcher<InputStream> {
private static final UriMatcher d = new UriMatcher(-1);
static {
d.addURI("com.android.contacts", "contacts/lookup/*/#", 1);
d.addURI("com.android.contacts", "contacts/lookup/*", 1);
d.addURI("com.android.contacts", "contacts/#/photo", 2);
d.addURI("com.android.contacts", "contacts/#", 3);
d.addURI("com.android.contacts", "contacts/#/display_photo", 4);
d.addURI("com.android.contacts", "phone_lookup/*", 5);
}
public StreamLocalUriFetcher(ContentResolver contentResolver, Uri uri) {
super(contentResolver, uri);
}
private InputStream b(Uri uri, ContentResolver contentResolver) throws FileNotFoundException {
int match = d.match(uri);
if (match != 1) {
if (match == 3) {
return a(contentResolver, uri);
}
if (match != 5) {
return contentResolver.openInputStream(uri);
}
}
Uri lookupContact = ContactsContract.Contacts.lookupContact(contentResolver, uri);
if (lookupContact != null) {
return a(contentResolver, lookupContact);
}
throw new FileNotFoundException("Contact cannot be found");
}
/* JADX INFO: Access modifiers changed from: protected */
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.load.data.LocalUriFetcher
public InputStream a(Uri uri, ContentResolver contentResolver) throws FileNotFoundException {
InputStream b = b(uri, contentResolver);
if (b != null) {
return b;
}
throw new FileNotFoundException("InputStream is null for " + uri);
}
private InputStream a(ContentResolver contentResolver, Uri uri) {
return ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, uri, true);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.bumptech.glide.load.data.LocalUriFetcher
public void a(InputStream inputStream) throws IOException {
inputStream.close();
}
@Override // com.bumptech.glide.load.data.DataFetcher
public Class<InputStream> a() {
return InputStream.class;
}
}

View File

@@ -0,0 +1,21 @@
package com.bumptech.glide.load.data.mediastore;
import java.io.File;
/* loaded from: classes.dex */
class FileService {
FileService() {
}
public boolean a(File file) {
return file.exists();
}
public long b(File file) {
return file.length();
}
public File a(String str) {
return new File(str);
}
}

View File

@@ -0,0 +1,26 @@
package com.bumptech.glide.load.data.mediastore;
import android.net.Uri;
/* loaded from: classes.dex */
public final class MediaStoreUtil {
public static boolean a(int i, int i2) {
return i != Integer.MIN_VALUE && i2 != Integer.MIN_VALUE && i <= 512 && i2 <= 384;
}
public static boolean a(Uri uri) {
return b(uri) && !d(uri);
}
public static boolean b(Uri uri) {
return uri != null && "content".equals(uri.getScheme()) && "media".equals(uri.getAuthority());
}
public static boolean c(Uri uri) {
return b(uri) && d(uri);
}
private static boolean d(Uri uri) {
return uri.getPathSegments().contains("video");
}
}

View File

@@ -0,0 +1,112 @@
package com.bumptech.glide.load.data.mediastore;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;
import android.util.Log;
import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.data.ExifOrientationStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
/* loaded from: classes.dex */
public class ThumbFetcher implements DataFetcher<InputStream> {
private final Uri a;
private final ThumbnailStreamOpener b;
private InputStream c;
static class ImageThumbnailQuery implements ThumbnailQuery {
private static final String[] b = {"_data"};
private final ContentResolver a;
ImageThumbnailQuery(ContentResolver contentResolver) {
this.a = contentResolver;
}
@Override // com.bumptech.glide.load.data.mediastore.ThumbnailQuery
public Cursor a(Uri uri) {
return this.a.query(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, b, "kind = 1 AND image_id = ?", new String[]{uri.getLastPathSegment()}, null);
}
}
static class VideoThumbnailQuery implements ThumbnailQuery {
private static final String[] b = {"_data"};
private final ContentResolver a;
VideoThumbnailQuery(ContentResolver contentResolver) {
this.a = contentResolver;
}
@Override // com.bumptech.glide.load.data.mediastore.ThumbnailQuery
public Cursor a(Uri uri) {
return this.a.query(MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI, b, "kind = 1 AND video_id = ?", new String[]{uri.getLastPathSegment()}, null);
}
}
ThumbFetcher(Uri uri, ThumbnailStreamOpener thumbnailStreamOpener) {
this.a = uri;
this.b = thumbnailStreamOpener;
}
public static ThumbFetcher a(Context context, Uri uri) {
return a(context, uri, new ImageThumbnailQuery(context.getContentResolver()));
}
public static ThumbFetcher b(Context context, Uri uri) {
return a(context, uri, new VideoThumbnailQuery(context.getContentResolver()));
}
private InputStream c() throws FileNotFoundException {
InputStream b = this.b.b(this.a);
int a = b != null ? this.b.a(this.a) : -1;
return a != -1 ? new ExifOrientationStream(b, a) : b;
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void cancel() {
}
@Override // com.bumptech.glide.load.data.DataFetcher
public DataSource getDataSource() {
return DataSource.LOCAL;
}
private static ThumbFetcher a(Context context, Uri uri, ThumbnailQuery thumbnailQuery) {
return new ThumbFetcher(uri, new ThumbnailStreamOpener(Glide.b(context).h().a(), thumbnailQuery, Glide.b(context).c(), context.getContentResolver()));
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void b() {
InputStream inputStream = this.c;
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException unused) {
}
}
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void a(Priority priority, DataFetcher.DataCallback<? super InputStream> dataCallback) {
try {
this.c = c();
dataCallback.a((DataFetcher.DataCallback<? super InputStream>) this.c);
} catch (FileNotFoundException e) {
if (Log.isLoggable("MediaStoreThumbFetcher", 3)) {
Log.d("MediaStoreThumbFetcher", "Failed to find thumbnail file", e);
}
dataCallback.a((Exception) e);
}
}
@Override // com.bumptech.glide.load.data.DataFetcher
public Class<InputStream> a() {
return InputStream.class;
}
}

View File

@@ -0,0 +1,9 @@
package com.bumptech.glide.load.data.mediastore;
import android.database.Cursor;
import android.net.Uri;
/* loaded from: classes.dex */
interface ThumbnailQuery {
Cursor a(Uri uri);
}

View File

@@ -0,0 +1,115 @@
package com.bumptech.glide.load.data.mediastore;
import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import com.bumptech.glide.load.ImageHeaderParser;
import com.bumptech.glide.load.ImageHeaderParserUtils;
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
/* loaded from: classes.dex */
class ThumbnailStreamOpener {
private static final FileService f = new FileService();
private final FileService a;
private final ThumbnailQuery b;
private final ArrayPool c;
private final ContentResolver d;
private final List<ImageHeaderParser> e;
ThumbnailStreamOpener(List<ImageHeaderParser> list, ThumbnailQuery thumbnailQuery, ArrayPool arrayPool, ContentResolver contentResolver) {
this(list, f, thumbnailQuery, arrayPool, contentResolver);
}
private String c(Uri uri) {
Cursor a = this.b.a(uri);
if (a != null) {
try {
if (a.moveToFirst()) {
return a.getString(0);
}
} finally {
if (a != null) {
a.close();
}
}
}
if (a != null) {
a.close();
}
return null;
}
int a(Uri uri) {
InputStream inputStream = null;
try {
try {
inputStream = this.d.openInputStream(uri);
int a = ImageHeaderParserUtils.a(this.e, inputStream, this.c);
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException unused) {
}
}
return a;
} catch (IOException | NullPointerException e) {
if (Log.isLoggable("ThumbStreamOpener", 3)) {
Log.d("ThumbStreamOpener", "Failed to open uri: " + uri, e);
}
if (inputStream == null) {
return -1;
}
try {
inputStream.close();
return -1;
} catch (IOException unused2) {
return -1;
}
}
} catch (Throwable th) {
if (0 != 0) {
try {
inputStream.close();
} catch (IOException unused3) {
}
}
throw th;
}
}
public InputStream b(Uri uri) throws FileNotFoundException {
String c = c(uri);
if (TextUtils.isEmpty(c)) {
return null;
}
File a = this.a.a(c);
if (!a(a)) {
return null;
}
Uri fromFile = Uri.fromFile(a);
try {
return this.d.openInputStream(fromFile);
} catch (NullPointerException e) {
throw ((FileNotFoundException) new FileNotFoundException("NPE opening uri: " + uri + " -> " + fromFile).initCause(e));
}
}
ThumbnailStreamOpener(List<ImageHeaderParser> list, FileService fileService, ThumbnailQuery thumbnailQuery, ArrayPool arrayPool, ContentResolver contentResolver) {
this.a = fileService;
this.b = thumbnailQuery;
this.c = arrayPool;
this.d = contentResolver;
this.e = list;
}
private boolean a(File file) {
return this.a.a(file) && 0 < this.a.b(file);
}
}

View File

@@ -0,0 +1,141 @@
package com.bumptech.glide.load.engine;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.EngineResource;
import com.bumptech.glide.util.Preconditions;
import com.bumptech.glide.util.Util;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;
/* loaded from: classes.dex */
final class ActiveResources {
private final boolean a;
private final Handler b = new Handler(Looper.getMainLooper(), new Handler.Callback() { // from class: com.bumptech.glide.load.engine.ActiveResources.1
@Override // android.os.Handler.Callback
public boolean handleMessage(Message message) {
if (message.what != 1) {
return false;
}
ActiveResources.this.a((ResourceWeakReference) message.obj);
return true;
}
});
final Map<Key, ResourceWeakReference> c = new HashMap();
private EngineResource.ResourceListener d;
private ReferenceQueue<EngineResource<?>> e;
private Thread f;
private volatile boolean g;
private volatile DequeuedResourceCallback h;
interface DequeuedResourceCallback {
void a();
}
static final class ResourceWeakReference extends WeakReference<EngineResource<?>> {
final Key a;
final boolean b;
Resource<?> c;
ResourceWeakReference(Key key, EngineResource<?> engineResource, ReferenceQueue<? super EngineResource<?>> referenceQueue, boolean z) {
super(engineResource, referenceQueue);
Resource<?> resource;
Preconditions.a(key);
this.a = key;
if (engineResource.e() && z) {
Resource<?> d = engineResource.d();
Preconditions.a(d);
resource = d;
} else {
resource = null;
}
this.c = resource;
this.b = engineResource.e();
}
void a() {
this.c = null;
clear();
}
}
ActiveResources(boolean z) {
this.a = z;
}
void a(EngineResource.ResourceListener resourceListener) {
this.d = resourceListener;
}
EngineResource<?> b(Key key) {
ResourceWeakReference resourceWeakReference = this.c.get(key);
if (resourceWeakReference == null) {
return null;
}
EngineResource<?> engineResource = resourceWeakReference.get();
if (engineResource == null) {
a(resourceWeakReference);
}
return engineResource;
}
void a(Key key, EngineResource<?> engineResource) {
ResourceWeakReference put = this.c.put(key, new ResourceWeakReference(key, engineResource, b(), this.a));
if (put != null) {
put.a();
}
}
private ReferenceQueue<EngineResource<?>> b() {
if (this.e == null) {
this.e = new ReferenceQueue<>();
this.f = new Thread(new Runnable() { // from class: com.bumptech.glide.load.engine.ActiveResources.2
@Override // java.lang.Runnable
public void run() {
Process.setThreadPriority(10);
ActiveResources.this.a();
}
}, "glide-active-resources");
this.f.start();
}
return this.e;
}
void a(Key key) {
ResourceWeakReference remove = this.c.remove(key);
if (remove != null) {
remove.a();
}
}
void a(ResourceWeakReference resourceWeakReference) {
Resource<?> resource;
Util.b();
this.c.remove(resourceWeakReference.a);
if (!resourceWeakReference.b || (resource = resourceWeakReference.c) == null) {
return;
}
EngineResource<?> engineResource = new EngineResource<>(resource, true, false);
engineResource.a(resourceWeakReference.a, this.d);
this.d.a(resourceWeakReference.a, engineResource);
}
void a() {
while (!this.g) {
try {
this.b.obtainMessage(1, (ResourceWeakReference) this.e.remove()).sendToTarget();
DequeuedResourceCallback dequeuedResourceCallback = this.h;
if (dequeuedResourceCallback != null) {
dequeuedResourceCallback.a();
}
} catch (InterruptedException unused) {
Thread.currentThread().interrupt();
}
}
}
}

View File

@@ -0,0 +1,88 @@
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<Object> {
private final List<Key> a;
private final DecodeHelper<?> b;
private final DataFetcherGenerator.FetcherReadyCallback c;
private int d;
private Key e;
private List<ModelLoader<File, ?>> 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<ModelLoader<File, ?>> 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<Key> 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);
}
}

View File

@@ -0,0 +1,39 @@
package com.bumptech.glide.load.engine;
import com.bumptech.glide.load.Key;
import java.security.MessageDigest;
/* loaded from: classes.dex */
final class DataCacheKey implements Key {
private final Key b;
private final Key c;
DataCacheKey(Key key, Key key2) {
this.b = key;
this.c = key2;
}
@Override // com.bumptech.glide.load.Key
public void a(MessageDigest messageDigest) {
this.b.a(messageDigest);
this.c.a(messageDigest);
}
@Override // com.bumptech.glide.load.Key
public boolean equals(Object obj) {
if (!(obj instanceof DataCacheKey)) {
return false;
}
DataCacheKey dataCacheKey = (DataCacheKey) obj;
return this.b.equals(dataCacheKey.b) && this.c.equals(dataCacheKey.c);
}
@Override // com.bumptech.glide.load.Key
public int hashCode() {
return (this.b.hashCode() * 31) + this.c.hashCode();
}
public String toString() {
return "DataCacheKey{sourceKey=" + this.b + ", signature=" + this.c + '}';
}
}

View File

@@ -0,0 +1,24 @@
package com.bumptech.glide.load.engine;
import com.bumptech.glide.load.Encoder;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.engine.cache.DiskCache;
import java.io.File;
/* loaded from: classes.dex */
class DataCacheWriter<DataType> implements DiskCache.Writer {
private final Encoder<DataType> a;
private final DataType b;
private final Options c;
DataCacheWriter(Encoder<DataType> encoder, DataType datatype, Options options) {
this.a = encoder;
this.b = datatype;
this.c = options;
}
@Override // com.bumptech.glide.load.engine.cache.DiskCache.Writer
public boolean a(File file) {
return this.a.a(this.b, file, this.c);
}
}

View File

@@ -0,0 +1,21 @@
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;
/* loaded from: classes.dex */
interface DataFetcherGenerator {
public interface FetcherReadyCallback {
void a(Key key, Exception exc, DataFetcher<?> dataFetcher, DataSource dataSource);
void a(Key key, Object obj, DataFetcher<?> dataFetcher, DataSource dataSource, Key key2);
void d();
}
boolean a();
void cancel();
}

View File

@@ -0,0 +1,220 @@
package com.bumptech.glide.load.engine;
import com.bumptech.glide.GlideContext;
import com.bumptech.glide.Priority;
import com.bumptech.glide.Registry;
import com.bumptech.glide.load.Encoder;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceEncoder;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.DecodeJob;
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
import com.bumptech.glide.load.engine.cache.DiskCache;
import com.bumptech.glide.load.model.ModelLoader;
import com.bumptech.glide.load.resource.UnitTransformation;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/* loaded from: classes.dex */
final class DecodeHelper<Transcode> {
private final List<ModelLoader.LoadData<?>> a = new ArrayList();
private final List<Key> b = new ArrayList();
private GlideContext c;
private Object d;
private int e;
private int f;
private Class<?> g;
private DecodeJob.DiskCacheProvider h;
private Options i;
private Map<Class<?>, Transformation<?>> j;
private Class<Transcode> k;
private boolean l;
private boolean m;
private Key n;
private Priority o;
private DiskCacheStrategy p;
private boolean q;
private boolean r;
DecodeHelper() {
}
/* JADX WARN: Multi-variable type inference failed */
<R> void a(GlideContext glideContext, Object obj, Key key, int i, int i2, DiskCacheStrategy diskCacheStrategy, Class<?> cls, Class<R> cls2, Priority priority, Options options, Map<Class<?>, Transformation<?>> map, boolean z, boolean z2, DecodeJob.DiskCacheProvider diskCacheProvider) {
this.c = glideContext;
this.d = obj;
this.n = key;
this.e = i;
this.f = i2;
this.p = diskCacheStrategy;
this.g = cls;
this.h = diskCacheProvider;
this.k = cls2;
this.o = priority;
this.i = options;
this.j = map;
this.q = z;
this.r = z2;
}
ArrayPool b() {
return this.c.a();
}
/* JADX WARN: Multi-variable type inference failed */
boolean c(Class<?> cls) {
return a((Class) cls) != null;
}
DiskCache d() {
return this.h.a();
}
DiskCacheStrategy e() {
return this.p;
}
int f() {
return this.f;
}
List<ModelLoader.LoadData<?>> g() {
if (!this.l) {
this.l = true;
this.a.clear();
List a = this.c.e().a((Registry) this.d);
int size = a.size();
for (int i = 0; i < size; i++) {
ModelLoader.LoadData<?> a2 = ((ModelLoader) a.get(i)).a(this.d, this.e, this.f, this.i);
if (a2 != null) {
this.a.add(a2);
}
}
}
return this.a;
}
Options h() {
return this.i;
}
Priority i() {
return this.o;
}
List<Class<?>> j() {
return this.c.e().b(this.d.getClass(), this.g, this.k);
}
Key k() {
return this.n;
}
Class<?> l() {
return this.k;
}
int m() {
return this.e;
}
boolean n() {
return this.r;
}
<Z> Transformation<Z> b(Class<Z> cls) {
Transformation<Z> transformation = (Transformation) this.j.get(cls);
if (transformation == null) {
Iterator<Map.Entry<Class<?>, Transformation<?>>> it = this.j.entrySet().iterator();
while (true) {
if (!it.hasNext()) {
break;
}
Map.Entry<Class<?>, Transformation<?>> next = it.next();
if (next.getKey().isAssignableFrom(cls)) {
transformation = (Transformation) next.getValue();
break;
}
}
}
if (transformation != null) {
return transformation;
}
if (!this.j.isEmpty() || !this.q) {
return UnitTransformation.a();
}
throw new IllegalArgumentException("Missing transformation for " + cls + ". If you wish to ignore unknown resource types, use the optional transformation methods.");
}
List<Key> c() {
if (!this.m) {
this.m = true;
this.b.clear();
List<ModelLoader.LoadData<?>> g = g();
int size = g.size();
for (int i = 0; i < size; i++) {
ModelLoader.LoadData<?> loadData = g.get(i);
if (!this.b.contains(loadData.a)) {
this.b.add(loadData.a);
}
for (int i2 = 0; i2 < loadData.b.size(); i2++) {
if (!this.b.contains(loadData.b.get(i2))) {
this.b.add(loadData.b.get(i2));
}
}
}
}
return this.b;
}
boolean b(Resource<?> resource) {
return this.c.e().b(resource);
}
void a() {
this.c = null;
this.d = null;
this.n = null;
this.g = null;
this.k = null;
this.i = null;
this.o = null;
this.j = null;
this.p = null;
this.a.clear();
this.l = false;
this.b.clear();
this.m = false;
}
<Data> LoadPath<Data, ?, Transcode> a(Class<Data> cls) {
return this.c.e().a(cls, this.g, this.k);
}
<Z> ResourceEncoder<Z> a(Resource<Z> resource) {
return this.c.e().a((Resource) resource);
}
List<ModelLoader<File, ?>> a(File file) throws Registry.NoModelLoaderAvailableException {
return this.c.e().a((Registry) file);
}
boolean a(Key key) {
List<ModelLoader.LoadData<?>> g = g();
int size = g.size();
for (int i = 0; i < size; i++) {
if (g.get(i).a.equals(key)) {
return true;
}
}
return false;
}
<X> Encoder<X> a(X x) throws Registry.NoSourceEncoderAvailableException {
return this.c.e().c(x);
}
}

View File

@@ -0,0 +1,676 @@
package com.bumptech.glide.load.engine;
import android.os.Build;
import android.util.Log;
import androidx.core.util.Pools$Pool;
import com.bumptech.glide.GlideContext;
import com.bumptech.glide.Priority;
import com.bumptech.glide.Registry;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.EncodeStrategy;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceEncoder;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.data.DataRewinder;
import com.bumptech.glide.load.engine.DataFetcherGenerator;
import com.bumptech.glide.load.engine.DecodePath;
import com.bumptech.glide.load.engine.cache.DiskCache;
import com.bumptech.glide.load.resource.bitmap.Downsampler;
import com.bumptech.glide.util.LogTime;
import com.bumptech.glide.util.pool.FactoryPools;
import com.bumptech.glide.util.pool.GlideTrace;
import com.bumptech.glide.util.pool.StateVerifier;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/* loaded from: classes.dex */
class DecodeJob<R> implements DataFetcherGenerator.FetcherReadyCallback, Runnable, Comparable<DecodeJob<?>>, FactoryPools.Poolable {
private Object A;
private DataSource B;
private DataFetcher<?> C;
private volatile DataFetcherGenerator D;
private volatile boolean E;
private volatile boolean F;
private final DiskCacheProvider d;
private final Pools$Pool<DecodeJob<?>> e;
private GlideContext h;
private Key i;
private Priority j;
private EngineKey k;
private int l;
private int m;
private DiskCacheStrategy n;
private Options o;
private Callback<R> p;
private int q;
private Stage r;
private RunReason s;
private long t;
private boolean u;
private Object v;
private Thread x;
private Key y;
private Key z;
private final DecodeHelper<R> a = new DecodeHelper<>();
private final List<Throwable> b = new ArrayList();
private final StateVerifier c = StateVerifier.b();
private final DeferredEncodeManager<?> f = new DeferredEncodeManager<>();
private final ReleaseManager g = new ReleaseManager();
/* renamed from: com.bumptech.glide.load.engine.DecodeJob$1, reason: invalid class name */
static /* synthetic */ class AnonymousClass1 {
static final /* synthetic */ int[] a;
static final /* synthetic */ int[] b;
static final /* synthetic */ int[] c = new int[EncodeStrategy.values().length];
static {
try {
c[EncodeStrategy.SOURCE.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
c[EncodeStrategy.TRANSFORMED.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
b = new int[Stage.values().length];
try {
b[Stage.RESOURCE_CACHE.ordinal()] = 1;
} catch (NoSuchFieldError unused3) {
}
try {
b[Stage.DATA_CACHE.ordinal()] = 2;
} catch (NoSuchFieldError unused4) {
}
try {
b[Stage.SOURCE.ordinal()] = 3;
} catch (NoSuchFieldError unused5) {
}
try {
b[Stage.FINISHED.ordinal()] = 4;
} catch (NoSuchFieldError unused6) {
}
try {
b[Stage.INITIALIZE.ordinal()] = 5;
} catch (NoSuchFieldError unused7) {
}
a = new int[RunReason.values().length];
try {
a[RunReason.INITIALIZE.ordinal()] = 1;
} catch (NoSuchFieldError unused8) {
}
try {
a[RunReason.SWITCH_TO_SOURCE_SERVICE.ordinal()] = 2;
} catch (NoSuchFieldError unused9) {
}
try {
a[RunReason.DECODE_DATA.ordinal()] = 3;
} catch (NoSuchFieldError unused10) {
}
}
}
interface Callback<R> {
void a(DecodeJob<?> decodeJob);
void a(GlideException glideException);
void a(Resource<R> resource, DataSource dataSource);
}
private final class DecodeCallback<Z> implements DecodePath.DecodeCallback<Z> {
private final DataSource a;
DecodeCallback(DataSource dataSource) {
this.a = dataSource;
}
@Override // com.bumptech.glide.load.engine.DecodePath.DecodeCallback
public Resource<Z> a(Resource<Z> resource) {
return DecodeJob.this.a(this.a, resource);
}
}
interface DiskCacheProvider {
DiskCache a();
}
private enum RunReason {
INITIALIZE,
SWITCH_TO_SOURCE_SERVICE,
DECODE_DATA
}
private enum Stage {
INITIALIZE,
RESOURCE_CACHE,
DATA_CACHE,
SOURCE,
ENCODE,
FINISHED
}
DecodeJob(DiskCacheProvider diskCacheProvider, Pools$Pool<DecodeJob<?>> pools$Pool) {
this.d = diskCacheProvider;
this.e = pools$Pool;
}
/* JADX WARN: Multi-variable type inference failed */
private void b(Resource<R> resource, DataSource dataSource) {
if (resource instanceof Initializable) {
((Initializable) resource).c();
}
LockedResource lockedResource = 0;
if (this.f.b()) {
resource = LockedResource.b(resource);
lockedResource = resource;
}
a((Resource) resource, dataSource);
this.r = Stage.ENCODE;
try {
if (this.f.b()) {
this.f.a(this.d, this.o);
}
o();
} finally {
if (lockedResource != 0) {
lockedResource.d();
}
}
}
private void f() {
if (Log.isLoggable("DecodeJob", 2)) {
a("Retrieved data", this.t, "data: " + this.A + ", cache key: " + this.y + ", fetcher: " + this.C);
}
Resource<R> resource = null;
try {
resource = a(this.C, (DataFetcher<?>) this.A, this.B);
} catch (GlideException e) {
e.setLoggingDetails(this.z, this.B);
this.b.add(e);
}
if (resource != null) {
b(resource, this.B);
} else {
r();
}
}
private DataFetcherGenerator m() {
int i = AnonymousClass1.b[this.r.ordinal()];
if (i == 1) {
return new ResourceCacheGenerator(this.a, this);
}
if (i == 2) {
return new DataCacheGenerator(this.a, this);
}
if (i == 3) {
return new SourceGenerator(this.a, this);
}
if (i == 4) {
return null;
}
throw new IllegalStateException("Unrecognized stage: " + this.r);
}
private void n() {
t();
this.p.a(new GlideException("Failed to load resource", new ArrayList(this.b)));
p();
}
private void o() {
if (this.g.a()) {
q();
}
}
private void p() {
if (this.g.b()) {
q();
}
}
private void q() {
this.g.c();
this.f.a();
this.a.a();
this.E = false;
this.h = null;
this.i = null;
this.o = null;
this.j = null;
this.k = null;
this.p = null;
this.r = null;
this.D = null;
this.x = null;
this.y = null;
this.A = null;
this.B = null;
this.C = null;
this.t = 0L;
this.F = false;
this.v = null;
this.b.clear();
this.e.a(this);
}
private void r() {
this.x = Thread.currentThread();
this.t = LogTime.a();
boolean z = false;
while (!this.F && this.D != null && !(z = this.D.a())) {
this.r = a(this.r);
this.D = m();
if (this.r == Stage.SOURCE) {
d();
return;
}
}
if ((this.r == Stage.FINISHED || this.F) && !z) {
n();
}
}
private void s() {
int i = AnonymousClass1.a[this.s.ordinal()];
if (i == 1) {
this.r = a(Stage.INITIALIZE);
this.D = m();
r();
} else if (i == 2) {
r();
} else {
if (i == 3) {
f();
return;
}
throw new IllegalStateException("Unrecognized run reason: " + this.s);
}
}
private void t() {
this.c.a();
if (this.E) {
throw new IllegalStateException("Already notified");
}
this.E = true;
}
DecodeJob<R> a(GlideContext glideContext, Object obj, EngineKey engineKey, Key key, int i, int i2, Class<?> cls, Class<R> cls2, Priority priority, DiskCacheStrategy diskCacheStrategy, Map<Class<?>, Transformation<?>> map, boolean z, boolean z2, boolean z3, Options options, Callback<R> callback, int i3) {
this.a.a(glideContext, obj, key, i, i2, diskCacheStrategy, cls, cls2, priority, options, map, z, z2, this.d);
this.h = glideContext;
this.i = key;
this.j = priority;
this.k = engineKey;
this.l = i;
this.m = i2;
this.n = diskCacheStrategy;
this.u = z3;
this.o = options;
this.p = callback;
this.q = i3;
this.s = RunReason.INITIALIZE;
this.v = obj;
return this;
}
@Override // com.bumptech.glide.util.pool.FactoryPools.Poolable
public StateVerifier c() {
return this.c;
}
public void cancel() {
this.F = true;
DataFetcherGenerator dataFetcherGenerator = this.D;
if (dataFetcherGenerator != null) {
dataFetcherGenerator.cancel();
}
}
@Override // com.bumptech.glide.load.engine.DataFetcherGenerator.FetcherReadyCallback
public void d() {
this.s = RunReason.SWITCH_TO_SOURCE_SERVICE;
this.p.a((DecodeJob<?>) this);
}
boolean e() {
Stage a = a(Stage.INITIALIZE);
return a == Stage.RESOURCE_CACHE || a == Stage.DATA_CACHE;
}
/* JADX WARN: Code restructure failed: missing block: B:12:0x001e, code lost:
if (r1 != null) goto L12;
*/
@Override // java.lang.Runnable
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
public void run() {
/*
r5 = this;
java.lang.String r0 = "DecodeJob"
java.lang.Object r1 = r5.v
java.lang.String r2 = "DecodeJob#run(model=%s)"
com.bumptech.glide.util.pool.GlideTrace.a(r2, r1)
com.bumptech.glide.load.data.DataFetcher<?> r1 = r5.C
boolean r2 = r5.F // Catch: java.lang.Throwable -> L27
if (r2 == 0) goto L1b
r5.n() // Catch: java.lang.Throwable -> L27
if (r1 == 0) goto L17
r1.b()
L17:
com.bumptech.glide.util.pool.GlideTrace.a()
return
L1b:
r5.s() // Catch: java.lang.Throwable -> L27
if (r1 == 0) goto L23
L20:
r1.b()
L23:
com.bumptech.glide.util.pool.GlideTrace.a()
goto L64
L27:
r2 = move-exception
r3 = 3
boolean r3 = android.util.Log.isLoggable(r0, r3) // Catch: java.lang.Throwable -> L66
if (r3 == 0) goto L4f
java.lang.StringBuilder r3 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L66
r3.<init>() // Catch: java.lang.Throwable -> L66
java.lang.String r4 = "DecodeJob threw unexpectedly, isCancelled: "
r3.append(r4) // Catch: java.lang.Throwable -> L66
boolean r4 = r5.F // Catch: java.lang.Throwable -> L66
r3.append(r4) // Catch: java.lang.Throwable -> L66
java.lang.String r4 = ", stage: "
r3.append(r4) // Catch: java.lang.Throwable -> L66
com.bumptech.glide.load.engine.DecodeJob$Stage r4 = r5.r // Catch: java.lang.Throwable -> L66
r3.append(r4) // Catch: java.lang.Throwable -> L66
java.lang.String r3 = r3.toString() // Catch: java.lang.Throwable -> L66
android.util.Log.d(r0, r3, r2) // Catch: java.lang.Throwable -> L66
L4f:
com.bumptech.glide.load.engine.DecodeJob$Stage r0 = r5.r // Catch: java.lang.Throwable -> L66
com.bumptech.glide.load.engine.DecodeJob$Stage r3 = com.bumptech.glide.load.engine.DecodeJob.Stage.ENCODE // Catch: java.lang.Throwable -> L66
if (r0 == r3) goto L5d
java.util.List<java.lang.Throwable> r0 = r5.b // Catch: java.lang.Throwable -> L66
r0.add(r2) // Catch: java.lang.Throwable -> L66
r5.n() // Catch: java.lang.Throwable -> L66
L5d:
boolean r0 = r5.F // Catch: java.lang.Throwable -> L66
if (r0 == 0) goto L65
if (r1 == 0) goto L23
goto L20
L64:
return
L65:
throw r2 // Catch: java.lang.Throwable -> L66
L66:
r0 = move-exception
if (r1 == 0) goto L6c
r1.b()
L6c:
com.bumptech.glide.util.pool.GlideTrace.a()
throw r0
*/
throw new UnsupportedOperationException("Method not decompiled: com.bumptech.glide.load.engine.DecodeJob.run():void");
}
private static class ReleaseManager {
private boolean a;
private boolean b;
private boolean c;
ReleaseManager() {
}
synchronized boolean a(boolean z) {
this.a = true;
return b(z);
}
synchronized boolean b() {
this.c = true;
return b(false);
}
synchronized void c() {
this.b = false;
this.a = false;
this.c = false;
}
private boolean b(boolean z) {
return (this.c || z || this.b) && this.a;
}
synchronized boolean a() {
this.b = true;
return b(false);
}
}
private static class DeferredEncodeManager<Z> {
private Key a;
private ResourceEncoder<Z> b;
private LockedResource<Z> c;
DeferredEncodeManager() {
}
/* JADX WARN: Multi-variable type inference failed */
<X> void a(Key key, ResourceEncoder<X> resourceEncoder, LockedResource<X> lockedResource) {
this.a = key;
this.b = resourceEncoder;
this.c = lockedResource;
}
boolean b() {
return this.c != null;
}
void a(DiskCacheProvider diskCacheProvider, Options options) {
GlideTrace.a("DecodeJob.encode");
try {
diskCacheProvider.a().a(this.a, new DataCacheWriter(this.b, this.c, options));
} finally {
this.c.d();
GlideTrace.a();
}
}
void a() {
this.a = null;
this.b = null;
this.c = null;
}
}
void a(boolean z) {
if (this.g.a(z)) {
q();
}
}
@Override // java.lang.Comparable
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public int compareTo(DecodeJob<?> decodeJob) {
int a = a() - decodeJob.a();
return a == 0 ? this.q - decodeJob.q : a;
}
private int a() {
return this.j.ordinal();
}
private void a(Resource<R> resource, DataSource dataSource) {
t();
this.p.a(resource, dataSource);
}
private Stage a(Stage stage) {
int i = AnonymousClass1.b[stage.ordinal()];
if (i == 1) {
return this.n.a() ? Stage.DATA_CACHE : a(Stage.DATA_CACHE);
}
if (i == 2) {
return this.u ? Stage.FINISHED : Stage.SOURCE;
}
if (i == 3 || i == 4) {
return Stage.FINISHED;
}
if (i == 5) {
return this.n.b() ? Stage.RESOURCE_CACHE : a(Stage.RESOURCE_CACHE);
}
throw new IllegalArgumentException("Unrecognized stage: " + stage);
}
@Override // com.bumptech.glide.load.engine.DataFetcherGenerator.FetcherReadyCallback
public void a(Key key, Object obj, DataFetcher<?> dataFetcher, DataSource dataSource, Key key2) {
this.y = key;
this.A = obj;
this.C = dataFetcher;
this.B = dataSource;
this.z = key2;
if (Thread.currentThread() != this.x) {
this.s = RunReason.DECODE_DATA;
this.p.a((DecodeJob<?>) this);
} else {
GlideTrace.a("DecodeJob.decodeFromRetrievedData");
try {
f();
} finally {
GlideTrace.a();
}
}
}
@Override // com.bumptech.glide.load.engine.DataFetcherGenerator.FetcherReadyCallback
public void a(Key key, Exception exc, DataFetcher<?> dataFetcher, DataSource dataSource) {
dataFetcher.b();
GlideException glideException = new GlideException("Fetching data failed", exc);
glideException.setLoggingDetails(key, dataSource, dataFetcher.a());
this.b.add(glideException);
if (Thread.currentThread() != this.x) {
this.s = RunReason.SWITCH_TO_SOURCE_SERVICE;
this.p.a((DecodeJob<?>) this);
} else {
r();
}
}
private <Data> Resource<R> a(DataFetcher<?> dataFetcher, Data data, DataSource dataSource) throws GlideException {
if (data == null) {
return null;
}
try {
long a = LogTime.a();
Resource<R> a2 = a((DecodeJob<R>) data, dataSource);
if (Log.isLoggable("DecodeJob", 2)) {
a("Decoded result " + a2, a);
}
return a2;
} finally {
dataFetcher.b();
}
}
private <Data> Resource<R> a(Data data, DataSource dataSource) throws GlideException {
return a((DecodeJob<R>) data, dataSource, (LoadPath<DecodeJob<R>, ResourceType, R>) this.a.a((Class) data.getClass()));
}
private Options a(DataSource dataSource) {
Options options = this.o;
if (Build.VERSION.SDK_INT < 26 || options.a(Downsampler.h) != null) {
return options;
}
if (dataSource != DataSource.RESOURCE_DISK_CACHE && !this.a.n()) {
return options;
}
Options options2 = new Options();
options2.a(this.o);
options2.a(Downsampler.h, true);
return options2;
}
private <Data, ResourceType> Resource<R> a(Data data, DataSource dataSource, LoadPath<Data, ResourceType, R> loadPath) throws GlideException {
Options a = a(dataSource);
DataRewinder<Data> b = this.h.e().b((Registry) data);
try {
return loadPath.a(b, a, this.l, this.m, new DecodeCallback(dataSource));
} finally {
b.b();
}
}
private void a(String str, long j) {
a(str, j, (String) null);
}
private void a(String str, long j, String str2) {
String str3;
StringBuilder sb = new StringBuilder();
sb.append(str);
sb.append(" in ");
sb.append(LogTime.a(j));
sb.append(", load key: ");
sb.append(this.k);
if (str2 != null) {
str3 = ", " + str2;
} else {
str3 = "";
}
sb.append(str3);
sb.append(", thread: ");
sb.append(Thread.currentThread().getName());
Log.v("DecodeJob", sb.toString());
}
<Z> Resource<Z> a(DataSource dataSource, Resource<Z> resource) {
Resource<Z> resource2;
Transformation<Z> transformation;
EncodeStrategy encodeStrategy;
Key dataCacheKey;
Class<?> cls = resource.get().getClass();
ResourceEncoder<Z> resourceEncoder = null;
if (dataSource != DataSource.RESOURCE_DISK_CACHE) {
Transformation<Z> b = this.a.b(cls);
transformation = b;
resource2 = b.a(this.h, resource, this.l, this.m);
} else {
resource2 = resource;
transformation = null;
}
if (!resource.equals(resource2)) {
resource.a();
}
if (this.a.b((Resource<?>) resource2)) {
resourceEncoder = this.a.a((Resource) resource2);
encodeStrategy = resourceEncoder.a(this.o);
} else {
encodeStrategy = EncodeStrategy.NONE;
}
ResourceEncoder resourceEncoder2 = resourceEncoder;
if (!this.n.a(!this.a.a(this.y), dataSource, encodeStrategy)) {
return resource2;
}
if (resourceEncoder2 != null) {
int i = AnonymousClass1.c[encodeStrategy.ordinal()];
if (i == 1) {
dataCacheKey = new DataCacheKey(this.y, this.i);
} else if (i == 2) {
dataCacheKey = new ResourceCacheKey(this.a.b(), this.y, this.i, this.l, this.m, transformation, cls, this.o);
} else {
throw new IllegalArgumentException("Unknown strategy: " + encodeStrategy);
}
LockedResource b2 = LockedResource.b(resource2);
this.f.a(dataCacheKey, resourceEncoder2, b2);
return b2;
}
throw new Registry.NoResultEncoderAvailableException(resource2.get().getClass());
}
}

View File

@@ -0,0 +1,77 @@
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));
}
}

View File

@@ -0,0 +1,125 @@
package com.bumptech.glide.load.engine;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.EncodeStrategy;
/* loaded from: classes.dex */
public abstract class DiskCacheStrategy {
public static final DiskCacheStrategy a = new DiskCacheStrategy() { // from class: com.bumptech.glide.load.engine.DiskCacheStrategy.1
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean a() {
return true;
}
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean a(DataSource dataSource) {
return dataSource == DataSource.REMOTE;
}
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean b() {
return true;
}
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean a(boolean z, DataSource dataSource, EncodeStrategy encodeStrategy) {
return (dataSource == DataSource.RESOURCE_DISK_CACHE || dataSource == DataSource.MEMORY_CACHE) ? false : true;
}
};
public static final DiskCacheStrategy b = new DiskCacheStrategy() { // from class: com.bumptech.glide.load.engine.DiskCacheStrategy.2
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean a() {
return false;
}
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean a(DataSource dataSource) {
return false;
}
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean a(boolean z, DataSource dataSource, EncodeStrategy encodeStrategy) {
return false;
}
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean b() {
return false;
}
};
public static final DiskCacheStrategy c = new DiskCacheStrategy() { // from class: com.bumptech.glide.load.engine.DiskCacheStrategy.3
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean a() {
return true;
}
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean a(DataSource dataSource) {
return (dataSource == DataSource.DATA_DISK_CACHE || dataSource == DataSource.MEMORY_CACHE) ? false : true;
}
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean a(boolean z, DataSource dataSource, EncodeStrategy encodeStrategy) {
return false;
}
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean b() {
return false;
}
};
public static final DiskCacheStrategy d;
static {
new DiskCacheStrategy() { // from class: com.bumptech.glide.load.engine.DiskCacheStrategy.4
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean a() {
return false;
}
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean a(DataSource dataSource) {
return false;
}
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean a(boolean z, DataSource dataSource, EncodeStrategy encodeStrategy) {
return (dataSource == DataSource.RESOURCE_DISK_CACHE || dataSource == DataSource.MEMORY_CACHE) ? false : true;
}
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean b() {
return true;
}
};
d = new DiskCacheStrategy() { // from class: com.bumptech.glide.load.engine.DiskCacheStrategy.5
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean a() {
return true;
}
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean a(DataSource dataSource) {
return dataSource == DataSource.REMOTE;
}
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean b() {
return true;
}
@Override // com.bumptech.glide.load.engine.DiskCacheStrategy
public boolean a(boolean z, DataSource dataSource, EncodeStrategy encodeStrategy) {
return ((z && dataSource == DataSource.DATA_DISK_CACHE) || dataSource == DataSource.LOCAL) && encodeStrategy == EncodeStrategy.TRANSFORMED;
}
};
}
public abstract boolean a();
public abstract boolean a(DataSource dataSource);
public abstract boolean a(boolean z, DataSource dataSource, EncodeStrategy encodeStrategy);
public abstract boolean b();
}

View File

@@ -0,0 +1,275 @@
package com.bumptech.glide.load.engine;
import android.util.Log;
import androidx.core.util.Pools$Pool;
import com.bumptech.glide.GlideContext;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.DecodeJob;
import com.bumptech.glide.load.engine.EngineResource;
import com.bumptech.glide.load.engine.cache.DiskCache;
import com.bumptech.glide.load.engine.cache.DiskCacheAdapter;
import com.bumptech.glide.load.engine.cache.MemoryCache;
import com.bumptech.glide.load.engine.executor.GlideExecutor;
import com.bumptech.glide.request.ResourceCallback;
import com.bumptech.glide.util.LogTime;
import com.bumptech.glide.util.Preconditions;
import com.bumptech.glide.util.Util;
import com.bumptech.glide.util.pool.FactoryPools;
import java.util.Map;
/* loaded from: classes.dex */
public class Engine implements EngineJobListener, MemoryCache.ResourceRemovedListener, EngineResource.ResourceListener {
private static final boolean i = Log.isLoggable("Engine", 2);
private final Jobs a;
private final EngineKeyFactory b;
private final MemoryCache c;
private final EngineJobFactory d;
private final ResourceRecycler e;
private final LazyDiskCacheProvider f;
private final DecodeJobFactory g;
private final ActiveResources h;
static class DecodeJobFactory {
final DecodeJob.DiskCacheProvider a;
final Pools$Pool<DecodeJob<?>> b = FactoryPools.a(150, new FactoryPools.Factory<DecodeJob<?>>() { // from class: com.bumptech.glide.load.engine.Engine.DecodeJobFactory.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.util.pool.FactoryPools.Factory
public DecodeJob<?> a() {
DecodeJobFactory decodeJobFactory = DecodeJobFactory.this;
return new DecodeJob<>(decodeJobFactory.a, decodeJobFactory.b);
}
});
private int c;
DecodeJobFactory(DecodeJob.DiskCacheProvider diskCacheProvider) {
this.a = diskCacheProvider;
}
<R> DecodeJob<R> a(GlideContext glideContext, Object obj, EngineKey engineKey, Key key, int i, int i2, Class<?> cls, Class<R> cls2, Priority priority, DiskCacheStrategy diskCacheStrategy, Map<Class<?>, Transformation<?>> map, boolean z, boolean z2, boolean z3, Options options, DecodeJob.Callback<R> callback) {
DecodeJob a = this.b.a();
Preconditions.a(a);
DecodeJob decodeJob = a;
int i3 = this.c;
this.c = i3 + 1;
decodeJob.a(glideContext, obj, engineKey, key, i, i2, cls, cls2, priority, diskCacheStrategy, map, z, z2, z3, options, callback, i3);
return decodeJob;
}
}
static class EngineJobFactory {
final GlideExecutor a;
final GlideExecutor b;
final GlideExecutor c;
final GlideExecutor d;
final EngineJobListener e;
final Pools$Pool<EngineJob<?>> f = FactoryPools.a(150, new FactoryPools.Factory<EngineJob<?>>() { // from class: com.bumptech.glide.load.engine.Engine.EngineJobFactory.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.util.pool.FactoryPools.Factory
public EngineJob<?> a() {
EngineJobFactory engineJobFactory = EngineJobFactory.this;
return new EngineJob<>(engineJobFactory.a, engineJobFactory.b, engineJobFactory.c, engineJobFactory.d, engineJobFactory.e, engineJobFactory.f);
}
});
EngineJobFactory(GlideExecutor glideExecutor, GlideExecutor glideExecutor2, GlideExecutor glideExecutor3, GlideExecutor glideExecutor4, EngineJobListener engineJobListener) {
this.a = glideExecutor;
this.b = glideExecutor2;
this.c = glideExecutor3;
this.d = glideExecutor4;
this.e = engineJobListener;
}
<R> EngineJob<R> a(Key key, boolean z, boolean z2, boolean z3, boolean z4) {
EngineJob a = this.f.a();
Preconditions.a(a);
EngineJob engineJob = a;
engineJob.a(key, z, z2, z3, z4);
return engineJob;
}
}
private static class LazyDiskCacheProvider implements DecodeJob.DiskCacheProvider {
private final DiskCache.Factory a;
private volatile DiskCache b;
LazyDiskCacheProvider(DiskCache.Factory factory) {
this.a = factory;
}
@Override // com.bumptech.glide.load.engine.DecodeJob.DiskCacheProvider
public DiskCache a() {
if (this.b == null) {
synchronized (this) {
if (this.b == null) {
this.b = this.a.build();
}
if (this.b == null) {
this.b = new DiskCacheAdapter();
}
}
}
return this.b;
}
}
public static class LoadStatus {
private final EngineJob<?> a;
private final ResourceCallback b;
LoadStatus(ResourceCallback resourceCallback, EngineJob<?> engineJob) {
this.b = resourceCallback;
this.a = engineJob;
}
public void a() {
this.a.b(this.b);
}
}
public Engine(MemoryCache memoryCache, DiskCache.Factory factory, GlideExecutor glideExecutor, GlideExecutor glideExecutor2, GlideExecutor glideExecutor3, GlideExecutor glideExecutor4, boolean z) {
this(memoryCache, factory, glideExecutor, glideExecutor2, glideExecutor3, glideExecutor4, null, null, null, null, null, null, z);
}
private EngineResource<?> b(Key key, boolean z) {
if (!z) {
return null;
}
EngineResource<?> a = a(key);
if (a != null) {
a.c();
this.h.a(key, a);
}
return a;
}
public <R> LoadStatus a(GlideContext glideContext, Object obj, Key key, int i2, int i3, Class<?> cls, Class<R> cls2, Priority priority, DiskCacheStrategy diskCacheStrategy, Map<Class<?>, Transformation<?>> map, boolean z, boolean z2, Options options, boolean z3, boolean z4, boolean z5, boolean z6, ResourceCallback resourceCallback) {
Util.b();
long a = i ? LogTime.a() : 0L;
EngineKey a2 = this.b.a(obj, key, i2, i3, map, cls, cls2, options);
EngineResource<?> a3 = a(a2, z3);
if (a3 != null) {
resourceCallback.a(a3, DataSource.MEMORY_CACHE);
if (i) {
a("Loaded resource from active resources", a, a2);
}
return null;
}
EngineResource<?> b = b(a2, z3);
if (b != null) {
resourceCallback.a(b, DataSource.MEMORY_CACHE);
if (i) {
a("Loaded resource from cache", a, a2);
}
return null;
}
EngineJob<?> a4 = this.a.a(a2, z6);
if (a4 != null) {
a4.a(resourceCallback);
if (i) {
a("Added to existing load", a, a2);
}
return new LoadStatus(resourceCallback, a4);
}
EngineJob<R> a5 = this.d.a(a2, z3, z4, z5, z6);
DecodeJob<R> a6 = this.g.a(glideContext, obj, a2, key, i2, i3, cls, cls2, priority, diskCacheStrategy, map, z, z2, z6, options, a5);
this.a.a((Key) a2, (EngineJob<?>) a5);
a5.a(resourceCallback);
a5.b(a6);
if (i) {
a("Started new load", a, a2);
}
return new LoadStatus(resourceCallback, a5);
}
Engine(MemoryCache memoryCache, DiskCache.Factory factory, GlideExecutor glideExecutor, GlideExecutor glideExecutor2, GlideExecutor glideExecutor3, GlideExecutor glideExecutor4, Jobs jobs, EngineKeyFactory engineKeyFactory, ActiveResources activeResources, EngineJobFactory engineJobFactory, DecodeJobFactory decodeJobFactory, ResourceRecycler resourceRecycler, boolean z) {
this.c = memoryCache;
this.f = new LazyDiskCacheProvider(factory);
ActiveResources activeResources2 = activeResources == null ? new ActiveResources(z) : activeResources;
this.h = activeResources2;
activeResources2.a(this);
this.b = engineKeyFactory == null ? new EngineKeyFactory() : engineKeyFactory;
this.a = jobs == null ? new Jobs() : jobs;
this.d = engineJobFactory == null ? new EngineJobFactory(glideExecutor, glideExecutor2, glideExecutor3, glideExecutor4, this) : engineJobFactory;
this.g = decodeJobFactory == null ? new DecodeJobFactory(this.f) : decodeJobFactory;
this.e = resourceRecycler == null ? new ResourceRecycler() : resourceRecycler;
memoryCache.a(this);
}
public void b(Resource<?> resource) {
Util.b();
if (resource instanceof EngineResource) {
((EngineResource) resource).f();
return;
}
throw new IllegalArgumentException("Cannot release anything but an EngineResource");
}
private static void a(String str, long j, Key key) {
Log.v("Engine", str + " in " + LogTime.a(j) + "ms, key: " + key);
}
private EngineResource<?> a(Key key, boolean z) {
if (!z) {
return null;
}
EngineResource<?> b = this.h.b(key);
if (b != null) {
b.c();
}
return b;
}
private EngineResource<?> a(Key key) {
Resource<?> a = this.c.a(key);
if (a == null) {
return null;
}
if (a instanceof EngineResource) {
return (EngineResource) a;
}
return new EngineResource<>(a, true, true);
}
@Override // com.bumptech.glide.load.engine.EngineJobListener
public void a(EngineJob<?> engineJob, Key key, EngineResource<?> engineResource) {
Util.b();
if (engineResource != null) {
engineResource.a(key, this);
if (engineResource.e()) {
this.h.a(key, engineResource);
}
}
this.a.b(key, engineJob);
}
@Override // com.bumptech.glide.load.engine.EngineJobListener
public void a(EngineJob<?> engineJob, Key key) {
Util.b();
this.a.b(key, engineJob);
}
@Override // com.bumptech.glide.load.engine.cache.MemoryCache.ResourceRemovedListener
public void a(Resource<?> resource) {
Util.b();
this.e.a(resource);
}
@Override // com.bumptech.glide.load.engine.EngineResource.ResourceListener
public void a(Key key, EngineResource<?> engineResource) {
Util.b();
this.h.a(key);
if (engineResource.e()) {
this.c.a(key, engineResource);
} else {
this.e.a(engineResource);
}
}
public void a() {
this.f.a().clear();
}
}

View File

@@ -0,0 +1,269 @@
package com.bumptech.glide.load.engine;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import androidx.core.util.Pools$Pool;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.DecodeJob;
import com.bumptech.glide.load.engine.executor.GlideExecutor;
import com.bumptech.glide.request.ResourceCallback;
import com.bumptech.glide.util.Util;
import com.bumptech.glide.util.pool.FactoryPools;
import com.bumptech.glide.util.pool.StateVerifier;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes.dex */
class EngineJob<R> implements DecodeJob.Callback<R>, FactoryPools.Poolable {
private static final EngineResourceFactory y = new EngineResourceFactory();
private static final Handler z = new Handler(Looper.getMainLooper(), new MainThreadCallback());
private final List<ResourceCallback> a;
private final StateVerifier b;
private final Pools$Pool<EngineJob<?>> c;
private final EngineResourceFactory d;
private final EngineJobListener e;
private final GlideExecutor f;
private final GlideExecutor g;
private final GlideExecutor h;
private final GlideExecutor i;
private Key j;
private boolean k;
private boolean l;
private boolean m;
private boolean n;
private Resource<?> o;
private DataSource p;
private boolean q;
private GlideException r;
private boolean s;
private List<ResourceCallback> t;
private EngineResource<?> u;
private DecodeJob<R> v;
private volatile boolean x;
static class EngineResourceFactory {
EngineResourceFactory() {
}
public <R> EngineResource<R> a(Resource<R> resource, boolean z) {
return new EngineResource<>(resource, z, true);
}
}
private static class MainThreadCallback implements Handler.Callback {
MainThreadCallback() {
}
@Override // android.os.Handler.Callback
public boolean handleMessage(Message message) {
EngineJob engineJob = (EngineJob) message.obj;
int i = message.what;
if (i == 1) {
engineJob.e();
} else if (i == 2) {
engineJob.d();
} else {
if (i != 3) {
throw new IllegalStateException("Unrecognized message: " + message.what);
}
engineJob.b();
}
return true;
}
}
EngineJob(GlideExecutor glideExecutor, GlideExecutor glideExecutor2, GlideExecutor glideExecutor3, GlideExecutor glideExecutor4, EngineJobListener engineJobListener, Pools$Pool<EngineJob<?>> pools$Pool) {
this(glideExecutor, glideExecutor2, glideExecutor3, glideExecutor4, engineJobListener, pools$Pool, y);
}
private void c(ResourceCallback resourceCallback) {
if (this.t == null) {
this.t = new ArrayList(2);
}
if (this.t.contains(resourceCallback)) {
return;
}
this.t.add(resourceCallback);
}
private boolean d(ResourceCallback resourceCallback) {
List<ResourceCallback> list = this.t;
return list != null && list.contains(resourceCallback);
}
private GlideExecutor g() {
return this.l ? this.h : this.m ? this.i : this.g;
}
EngineJob<R> a(Key key, boolean z2, boolean z3, boolean z4, boolean z5) {
this.j = key;
this.k = z2;
this.l = z3;
this.m = z4;
this.n = z5;
return this;
}
public void b(DecodeJob<R> decodeJob) {
this.v = decodeJob;
(decodeJob.e() ? this.f : g()).execute(decodeJob);
}
void e() {
this.b.a();
if (this.x) {
this.o.a();
a(false);
return;
}
if (this.a.isEmpty()) {
throw new IllegalStateException("Received a resource without any callbacks to notify");
}
if (this.q) {
throw new IllegalStateException("Already have resource");
}
this.u = this.d.a(this.o, this.k);
this.q = true;
this.u.c();
this.e.a(this, this.j, this.u);
int size = this.a.size();
for (int i = 0; i < size; i++) {
ResourceCallback resourceCallback = this.a.get(i);
if (!d(resourceCallback)) {
this.u.c();
resourceCallback.a(this.u, this.p);
}
}
this.u.f();
a(false);
}
boolean f() {
return this.n;
}
EngineJob(GlideExecutor glideExecutor, GlideExecutor glideExecutor2, GlideExecutor glideExecutor3, GlideExecutor glideExecutor4, EngineJobListener engineJobListener, Pools$Pool<EngineJob<?>> pools$Pool, EngineResourceFactory engineResourceFactory) {
this.a = new ArrayList(2);
this.b = StateVerifier.b();
this.f = glideExecutor;
this.g = glideExecutor2;
this.h = glideExecutor3;
this.i = glideExecutor4;
this.e = engineJobListener;
this.c = pools$Pool;
this.d = engineResourceFactory;
}
void d() {
this.b.a();
if (this.x) {
a(false);
return;
}
if (this.a.isEmpty()) {
throw new IllegalStateException("Received an exception without any callbacks to notify");
}
if (this.s) {
throw new IllegalStateException("Already failed once");
}
this.s = true;
this.e.a(this, this.j, null);
for (ResourceCallback resourceCallback : this.a) {
if (!d(resourceCallback)) {
resourceCallback.a(this.r);
}
}
a(false);
}
@Override // com.bumptech.glide.util.pool.FactoryPools.Poolable
public StateVerifier c() {
return this.b;
}
void a(ResourceCallback resourceCallback) {
Util.b();
this.b.a();
if (this.q) {
resourceCallback.a(this.u, this.p);
} else if (this.s) {
resourceCallback.a(this.r);
} else {
this.a.add(resourceCallback);
}
}
void b(ResourceCallback resourceCallback) {
Util.b();
this.b.a();
if (!this.q && !this.s) {
this.a.remove(resourceCallback);
if (this.a.isEmpty()) {
a();
return;
}
return;
}
c(resourceCallback);
}
void a() {
if (this.s || this.q || this.x) {
return;
}
this.x = true;
this.v.cancel();
this.e.a(this, this.j);
}
void b() {
this.b.a();
if (this.x) {
this.e.a(this, this.j);
a(false);
return;
}
throw new IllegalStateException("Not cancelled");
}
private void a(boolean z2) {
Util.b();
this.a.clear();
this.j = null;
this.u = null;
this.o = null;
List<ResourceCallback> list = this.t;
if (list != null) {
list.clear();
}
this.s = false;
this.x = false;
this.q = false;
this.v.a(z2);
this.v = null;
this.r = null;
this.p = null;
this.c.a(this);
}
/* JADX WARN: Multi-variable type inference failed */
@Override // com.bumptech.glide.load.engine.DecodeJob.Callback
public void a(Resource<R> resource, DataSource dataSource) {
this.o = resource;
this.p = dataSource;
z.obtainMessage(1, this).sendToTarget();
}
@Override // com.bumptech.glide.load.engine.DecodeJob.Callback
public void a(GlideException glideException) {
this.r = glideException;
z.obtainMessage(2, this).sendToTarget();
}
@Override // com.bumptech.glide.load.engine.DecodeJob.Callback
public void a(DecodeJob<?> decodeJob) {
g().execute(decodeJob);
}
}

View File

@@ -0,0 +1,10 @@
package com.bumptech.glide.load.engine;
import com.bumptech.glide.load.Key;
/* loaded from: classes.dex */
interface EngineJobListener {
void a(EngineJob<?> engineJob, Key key);
void a(EngineJob<?> engineJob, Key key, EngineResource<?> engineResource);
}

View File

@@ -0,0 +1,71 @@
package com.bumptech.glide.load.engine;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.util.Preconditions;
import java.security.MessageDigest;
import java.util.Map;
/* loaded from: classes.dex */
class EngineKey implements Key {
private final Object b;
private final int c;
private final int d;
private final Class<?> e;
private final Class<?> f;
private final Key g;
private final Map<Class<?>, Transformation<?>> h;
private final Options i;
private int j;
EngineKey(Object obj, Key key, int i, int i2, Map<Class<?>, Transformation<?>> map, Class<?> cls, Class<?> cls2, Options options) {
Preconditions.a(obj);
this.b = obj;
Preconditions.a(key, "Signature must not be null");
this.g = key;
this.c = i;
this.d = i2;
Preconditions.a(map);
this.h = map;
Preconditions.a(cls, "Resource class must not be null");
this.e = cls;
Preconditions.a(cls2, "Transcode class must not be null");
this.f = cls2;
Preconditions.a(options);
this.i = options;
}
@Override // com.bumptech.glide.load.Key
public void a(MessageDigest messageDigest) {
throw new UnsupportedOperationException();
}
@Override // com.bumptech.glide.load.Key
public boolean equals(Object obj) {
if (!(obj instanceof EngineKey)) {
return false;
}
EngineKey engineKey = (EngineKey) obj;
return this.b.equals(engineKey.b) && this.g.equals(engineKey.g) && this.d == engineKey.d && this.c == engineKey.c && this.h.equals(engineKey.h) && this.e.equals(engineKey.e) && this.f.equals(engineKey.f) && this.i.equals(engineKey.i);
}
@Override // com.bumptech.glide.load.Key
public int hashCode() {
if (this.j == 0) {
this.j = this.b.hashCode();
this.j = (this.j * 31) + this.g.hashCode();
this.j = (this.j * 31) + this.c;
this.j = (this.j * 31) + this.d;
this.j = (this.j * 31) + this.h.hashCode();
this.j = (this.j * 31) + this.e.hashCode();
this.j = (this.j * 31) + this.f.hashCode();
this.j = (this.j * 31) + this.i.hashCode();
}
return this.j;
}
public String toString() {
return "EngineKey{model=" + this.b + ", width=" + this.c + ", height=" + this.d + ", resourceClass=" + this.e + ", transcodeClass=" + this.f + ", signature=" + this.g + ", hashCode=" + this.j + ", transformations=" + this.h + ", options=" + this.i + '}';
}
}

View File

@@ -0,0 +1,16 @@
package com.bumptech.glide.load.engine;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.Transformation;
import java.util.Map;
/* loaded from: classes.dex */
class EngineKeyFactory {
EngineKeyFactory() {
}
EngineKey a(Object obj, Key key, int i, int i2, Map<Class<?>, Transformation<?>> map, Class<?> cls, Class<?> cls2, Options options) {
return new EngineKey(obj, key, i, i2, map, cls, cls2, options);
}
}

View File

@@ -0,0 +1,99 @@
package com.bumptech.glide.load.engine;
import android.os.Looper;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.util.Preconditions;
/* loaded from: classes.dex */
class EngineResource<Z> implements Resource<Z> {
private final boolean a;
private final boolean b;
private ResourceListener c;
private Key d;
private int e;
private boolean f;
private final Resource<Z> g;
interface ResourceListener {
void a(Key key, EngineResource<?> engineResource);
}
EngineResource(Resource<Z> resource, boolean z, boolean z2) {
Preconditions.a(resource);
this.g = resource;
this.a = z;
this.b = z2;
}
void a(Key key, ResourceListener resourceListener) {
this.d = key;
this.c = resourceListener;
}
@Override // com.bumptech.glide.load.engine.Resource
public Class<Z> b() {
return this.g.b();
}
void c() {
if (this.f) {
throw new IllegalStateException("Cannot acquire a recycled resource");
}
if (!Looper.getMainLooper().equals(Looper.myLooper())) {
throw new IllegalThreadStateException("Must call acquire on the main thread");
}
this.e++;
}
Resource<Z> d() {
return this.g;
}
boolean e() {
return this.a;
}
void f() {
if (this.e <= 0) {
throw new IllegalStateException("Cannot release a recycled or not yet acquired resource");
}
if (!Looper.getMainLooper().equals(Looper.myLooper())) {
throw new IllegalThreadStateException("Must call release on the main thread");
}
int i = this.e - 1;
this.e = i;
if (i == 0) {
this.c.a(this.d, this);
}
}
@Override // com.bumptech.glide.load.engine.Resource
public Z get() {
return this.g.get();
}
@Override // com.bumptech.glide.load.engine.Resource
public int getSize() {
return this.g.getSize();
}
public String toString() {
return "EngineResource{isCacheable=" + this.a + ", listener=" + this.c + ", key=" + this.d + ", acquired=" + this.e + ", isRecycled=" + this.f + ", resource=" + this.g + '}';
}
@Override // com.bumptech.glide.load.engine.Resource
public void a() {
if (this.e <= 0) {
if (!this.f) {
this.f = true;
if (this.b) {
this.g.a();
return;
}
return;
}
throw new IllegalStateException("Cannot recycle a resource that has already been recycled");
}
throw new IllegalStateException("Cannot recycle a resource while it is still acquired");
}
}

View File

@@ -0,0 +1,218 @@
package com.bumptech.glide.load.engine;
import android.util.Log;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.Key;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/* loaded from: classes.dex */
public final class GlideException extends Exception {
private static final StackTraceElement[] EMPTY_ELEMENTS = new StackTraceElement[0];
private static final long serialVersionUID = 1;
private final List<Throwable> causes;
private Class<?> dataClass;
private DataSource dataSource;
private String detailMessage;
private Key key;
public GlideException(String str) {
this(str, (List<Throwable>) Collections.emptyList());
}
private void addRootCauses(Throwable th, List<Throwable> list) {
if (!(th instanceof GlideException)) {
list.add(th);
return;
}
Iterator<Throwable> it = ((GlideException) th).getCauses().iterator();
while (it.hasNext()) {
addRootCauses(it.next(), list);
}
}
private static void appendCauses(List<Throwable> list, Appendable appendable) {
try {
appendCausesWrapped(list, appendable);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static void appendCausesWrapped(List<Throwable> list, Appendable appendable) throws IOException {
int size = list.size();
int i = 0;
while (i < size) {
int i2 = i + 1;
appendable.append("Cause (").append(String.valueOf(i2)).append(" of ").append(String.valueOf(size)).append("): ");
Throwable th = list.get(i);
if (th instanceof GlideException) {
((GlideException) th).printStackTrace(appendable);
} else {
appendExceptionMessage(th, appendable);
}
i = i2;
}
}
private static void appendExceptionMessage(Throwable th, Appendable appendable) {
try {
appendable.append(th.getClass().toString()).append(": ").append(th.getMessage()).append('\n');
} catch (IOException unused) {
throw new RuntimeException(th);
}
}
@Override // java.lang.Throwable
public Throwable fillInStackTrace() {
return this;
}
public List<Throwable> getCauses() {
return this.causes;
}
@Override // java.lang.Throwable
public String getMessage() {
StringBuilder sb = new StringBuilder(71);
sb.append(this.detailMessage);
sb.append(this.dataClass != null ? ", " + this.dataClass : "");
sb.append(this.dataSource != null ? ", " + this.dataSource : "");
sb.append(this.key != null ? ", " + this.key : "");
List<Throwable> rootCauses = getRootCauses();
if (rootCauses.isEmpty()) {
return sb.toString();
}
if (rootCauses.size() == 1) {
sb.append("\nThere was 1 cause:");
} else {
sb.append("\nThere were ");
sb.append(rootCauses.size());
sb.append(" causes:");
}
for (Throwable th : rootCauses) {
sb.append('\n');
sb.append(th.getClass().getName());
sb.append('(');
sb.append(th.getMessage());
sb.append(')');
}
sb.append("\n call GlideException#logRootCauses(String) for more detail");
return sb.toString();
}
public List<Throwable> getRootCauses() {
ArrayList arrayList = new ArrayList();
addRootCauses(this, arrayList);
return arrayList;
}
public void logRootCauses(String str) {
List<Throwable> rootCauses = getRootCauses();
int size = rootCauses.size();
int i = 0;
while (i < size) {
StringBuilder sb = new StringBuilder();
sb.append("Root cause (");
int i2 = i + 1;
sb.append(i2);
sb.append(" of ");
sb.append(size);
sb.append(")");
Log.i(str, sb.toString(), rootCauses.get(i));
i = i2;
}
}
@Override // java.lang.Throwable
public void printStackTrace() {
printStackTrace(System.err);
}
void setLoggingDetails(Key key, DataSource dataSource) {
setLoggingDetails(key, dataSource, null);
}
public GlideException(String str, Throwable th) {
this(str, (List<Throwable>) Collections.singletonList(th));
}
@Override // java.lang.Throwable
public void printStackTrace(PrintStream printStream) {
printStackTrace((Appendable) printStream);
}
void setLoggingDetails(Key key, DataSource dataSource, Class<?> cls) {
this.key = key;
this.dataSource = dataSource;
this.dataClass = cls;
}
public GlideException(String str, List<Throwable> list) {
this.detailMessage = str;
setStackTrace(EMPTY_ELEMENTS);
this.causes = list;
}
@Override // java.lang.Throwable
public void printStackTrace(PrintWriter printWriter) {
printStackTrace((Appendable) printWriter);
}
private void printStackTrace(Appendable appendable) {
appendExceptionMessage(this, appendable);
appendCauses(getCauses(), new IndentedAppendable(appendable));
}
private static final class IndentedAppendable implements Appendable {
private final Appendable a;
private boolean b = true;
IndentedAppendable(Appendable appendable) {
this.a = appendable;
}
private CharSequence a(CharSequence charSequence) {
return charSequence == null ? "" : charSequence;
}
@Override // java.lang.Appendable
public Appendable append(char c) throws IOException {
if (this.b) {
this.b = false;
this.a.append(" ");
}
this.b = c == '\n';
this.a.append(c);
return this;
}
@Override // java.lang.Appendable
public Appendable append(CharSequence charSequence) throws IOException {
CharSequence a = a(charSequence);
append(a, 0, a.length());
return this;
}
@Override // java.lang.Appendable
public Appendable append(CharSequence charSequence, int i, int i2) throws IOException {
CharSequence a = a(charSequence);
boolean z = false;
if (this.b) {
this.b = false;
this.a.append(" ");
}
if (a.length() > 0 && a.charAt(i2 - 1) == '\n') {
z = true;
}
this.b = z;
this.a.append(a, i, i2);
return this;
}
}
}

View File

@@ -0,0 +1,6 @@
package com.bumptech.glide.load.engine;
/* loaded from: classes.dex */
public interface Initializable {
void c();
}

View File

@@ -0,0 +1,33 @@
package com.bumptech.glide.load.engine;
import com.bumptech.glide.load.Key;
import java.util.HashMap;
import java.util.Map;
/* loaded from: classes.dex */
final class Jobs {
private final Map<Key, EngineJob<?>> a = new HashMap();
private final Map<Key, EngineJob<?>> b = new HashMap();
Jobs() {
}
EngineJob<?> a(Key key, boolean z) {
return a(z).get(key);
}
void b(Key key, EngineJob<?> engineJob) {
Map<Key, EngineJob<?>> a = a(engineJob.f());
if (engineJob.equals(a.get(key))) {
a.remove(key);
}
}
void a(Key key, EngineJob<?> engineJob) {
a(engineJob.f()).put(key, engineJob);
}
private Map<Key, EngineJob<?>> a(boolean z) {
return z ? this.b : this.a;
}
}

View File

@@ -0,0 +1,58 @@
package com.bumptech.glide.load.engine;
import androidx.core.util.Pools$Pool;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.data.DataRewinder;
import com.bumptech.glide.load.engine.DecodePath;
import com.bumptech.glide.util.Preconditions;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/* loaded from: classes.dex */
public class LoadPath<Data, ResourceType, Transcode> {
private final Pools$Pool<List<Throwable>> a;
private final List<? extends DecodePath<Data, ResourceType, Transcode>> b;
private final String c;
public LoadPath(Class<Data> cls, Class<ResourceType> cls2, Class<Transcode> cls3, List<DecodePath<Data, ResourceType, Transcode>> list, Pools$Pool<List<Throwable>> pools$Pool) {
this.a = pools$Pool;
Preconditions.a(list);
this.b = list;
this.c = "Failed LoadPath{" + cls.getSimpleName() + "->" + cls2.getSimpleName() + "->" + cls3.getSimpleName() + "}";
}
public Resource<Transcode> a(DataRewinder<Data> dataRewinder, Options options, int i, int i2, DecodePath.DecodeCallback<ResourceType> decodeCallback) throws GlideException {
List<Throwable> a = this.a.a();
Preconditions.a(a);
List<Throwable> list = a;
try {
return a(dataRewinder, options, i, i2, decodeCallback, list);
} finally {
this.a.a(list);
}
}
public String toString() {
return "LoadPath{decodePaths=" + Arrays.toString(this.b.toArray()) + '}';
}
private Resource<Transcode> a(DataRewinder<Data> dataRewinder, Options options, int i, int i2, DecodePath.DecodeCallback<ResourceType> decodeCallback, List<Throwable> list) throws GlideException {
int size = this.b.size();
Resource<Transcode> resource = null;
for (int i3 = 0; i3 < size; i3++) {
try {
resource = this.b.get(i3).a(dataRewinder, i, i2, options, decodeCallback);
} catch (GlideException e) {
list.add(e);
}
if (resource != null) {
break;
}
}
if (resource != null) {
return resource;
}
throw new GlideException(this.c, new ArrayList(list));
}
}

View File

@@ -0,0 +1,84 @@
package com.bumptech.glide.load.engine;
import androidx.core.util.Pools$Pool;
import com.bumptech.glide.util.Preconditions;
import com.bumptech.glide.util.pool.FactoryPools;
import com.bumptech.glide.util.pool.StateVerifier;
/* loaded from: classes.dex */
final class LockedResource<Z> implements Resource<Z>, FactoryPools.Poolable {
private static final Pools$Pool<LockedResource<?>> e = FactoryPools.b(20, new FactoryPools.Factory<LockedResource<?>>() { // from class: com.bumptech.glide.load.engine.LockedResource.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.util.pool.FactoryPools.Factory
public LockedResource<?> a() {
return new LockedResource<>();
}
});
private final StateVerifier a = StateVerifier.b();
private Resource<Z> b;
private boolean c;
private boolean d;
LockedResource() {
}
private void a(Resource<Z> resource) {
this.d = false;
this.c = true;
this.b = resource;
}
static <Z> LockedResource<Z> b(Resource<Z> resource) {
LockedResource a = e.a();
Preconditions.a(a);
LockedResource lockedResource = a;
lockedResource.a(resource);
return lockedResource;
}
private void e() {
this.b = null;
e.a(this);
}
@Override // com.bumptech.glide.util.pool.FactoryPools.Poolable
public StateVerifier c() {
return this.a;
}
synchronized void d() {
this.a.a();
if (!this.c) {
throw new IllegalStateException("Already unlocked");
}
this.c = false;
if (this.d) {
a();
}
}
@Override // com.bumptech.glide.load.engine.Resource
public Z get() {
return this.b.get();
}
@Override // com.bumptech.glide.load.engine.Resource
public int getSize() {
return this.b.getSize();
}
@Override // com.bumptech.glide.load.engine.Resource
public Class<Z> b() {
return this.b.b();
}
@Override // com.bumptech.glide.load.engine.Resource
public synchronized void a() {
this.a.a();
this.d = true;
if (!this.c) {
this.b.a();
e();
}
}
}

View File

@@ -0,0 +1,12 @@
package com.bumptech.glide.load.engine;
/* loaded from: classes.dex */
public interface Resource<Z> {
void a();
Class<Z> b();
Z get();
int getSize();
}

View File

@@ -0,0 +1,97 @@
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<Object> {
private final DataFetcherGenerator.FetcherReadyCallback a;
private final DecodeHelper<?> b;
private int c;
private int d = -1;
private Key e;
private List<ModelLoader<File, ?>> 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<Key> c = this.b.c();
boolean z = false;
if (c.isEmpty()) {
return false;
}
List<Class<?>> 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<ModelLoader<File, ?>> 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);
}
}

View File

@@ -0,0 +1,83 @@
package com.bumptech.glide.load.engine;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool;
import com.bumptech.glide.util.LruCache;
import com.bumptech.glide.util.Util;
import java.nio.ByteBuffer;
import java.security.MessageDigest;
/* loaded from: classes.dex */
final class ResourceCacheKey implements Key {
private static final LruCache<Class<?>, byte[]> j = new LruCache<>(50);
private final ArrayPool b;
private final Key c;
private final Key d;
private final int e;
private final int f;
private final Class<?> g;
private final Options h;
private final Transformation<?> i;
ResourceCacheKey(ArrayPool arrayPool, Key key, Key key2, int i, int i2, Transformation<?> transformation, Class<?> cls, Options options) {
this.b = arrayPool;
this.c = key;
this.d = key2;
this.e = i;
this.f = i2;
this.i = transformation;
this.g = cls;
this.h = options;
}
@Override // com.bumptech.glide.load.Key
public void a(MessageDigest messageDigest) {
byte[] bArr = (byte[]) this.b.a(8, byte[].class);
ByteBuffer.wrap(bArr).putInt(this.e).putInt(this.f).array();
this.d.a(messageDigest);
this.c.a(messageDigest);
messageDigest.update(bArr);
Transformation<?> transformation = this.i;
if (transformation != null) {
transformation.a(messageDigest);
}
this.h.a(messageDigest);
messageDigest.update(a());
this.b.put(bArr);
}
@Override // com.bumptech.glide.load.Key
public boolean equals(Object obj) {
if (!(obj instanceof ResourceCacheKey)) {
return false;
}
ResourceCacheKey resourceCacheKey = (ResourceCacheKey) obj;
return this.f == resourceCacheKey.f && this.e == resourceCacheKey.e && Util.b(this.i, resourceCacheKey.i) && this.g.equals(resourceCacheKey.g) && this.c.equals(resourceCacheKey.c) && this.d.equals(resourceCacheKey.d) && this.h.equals(resourceCacheKey.h);
}
@Override // com.bumptech.glide.load.Key
public int hashCode() {
int hashCode = (((((this.c.hashCode() * 31) + this.d.hashCode()) * 31) + this.e) * 31) + this.f;
Transformation<?> transformation = this.i;
if (transformation != null) {
hashCode = (hashCode * 31) + transformation.hashCode();
}
return (((hashCode * 31) + this.g.hashCode()) * 31) + this.h.hashCode();
}
public String toString() {
return "ResourceCacheKey{sourceKey=" + this.c + ", signature=" + this.d + ", width=" + this.e + ", height=" + this.f + ", decodedResourceClass=" + this.g + ", transformation='" + this.i + "', options=" + this.h + '}';
}
private byte[] a() {
byte[] a = j.a((LruCache<Class<?>, byte[]>) this.g);
if (a != null) {
return a;
}
byte[] bytes = this.g.getName().getBytes(Key.a);
j.b(this.g, bytes);
return bytes;
}
}

View File

@@ -0,0 +1,40 @@
package com.bumptech.glide.load.engine;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import com.bumptech.glide.util.Util;
/* loaded from: classes.dex */
class ResourceRecycler {
private boolean a;
private final Handler b = new Handler(Looper.getMainLooper(), new ResourceRecyclerCallback());
private static final class ResourceRecyclerCallback implements Handler.Callback {
ResourceRecyclerCallback() {
}
@Override // android.os.Handler.Callback
public boolean handleMessage(Message message) {
if (message.what != 1) {
return false;
}
((Resource) message.obj).a();
return true;
}
}
ResourceRecycler() {
}
void a(Resource<?> resource) {
Util.b();
if (this.a) {
this.b.obtainMessage(1, resource).sendToTarget();
return;
}
this.a = true;
resource.a();
this.a = false;
}
}

View File

@@ -0,0 +1,116 @@
package com.bumptech.glide.load.engine;
import android.util.Log;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.Encoder;
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 com.bumptech.glide.util.LogTime;
import java.util.Collections;
import java.util.List;
/* loaded from: classes.dex */
class SourceGenerator implements DataFetcherGenerator, DataFetcher.DataCallback<Object>, DataFetcherGenerator.FetcherReadyCallback {
private final DecodeHelper<?> a;
private final DataFetcherGenerator.FetcherReadyCallback b;
private int c;
private DataCacheGenerator d;
private Object e;
private volatile ModelLoader.LoadData<?> f;
private DataCacheKey g;
SourceGenerator(DecodeHelper<?> decodeHelper, DataFetcherGenerator.FetcherReadyCallback fetcherReadyCallback) {
this.a = decodeHelper;
this.b = fetcherReadyCallback;
}
private boolean b() {
return this.c < this.a.g().size();
}
@Override // com.bumptech.glide.load.engine.DataFetcherGenerator
public boolean a() {
Object obj = this.e;
if (obj != null) {
this.e = null;
b(obj);
}
DataCacheGenerator dataCacheGenerator = this.d;
if (dataCacheGenerator != null && dataCacheGenerator.a()) {
return true;
}
this.d = null;
this.f = null;
boolean z = false;
while (!z && b()) {
List<ModelLoader.LoadData<?>> g = this.a.g();
int i = this.c;
this.c = i + 1;
this.f = g.get(i);
if (this.f != null && (this.a.e().a(this.f.c.getDataSource()) || this.a.c(this.f.c.a()))) {
this.f.c.a(this.a.i(), this);
z = true;
}
}
return z;
}
@Override // com.bumptech.glide.load.engine.DataFetcherGenerator
public void cancel() {
ModelLoader.LoadData<?> loadData = this.f;
if (loadData != null) {
loadData.c.cancel();
}
}
@Override // com.bumptech.glide.load.engine.DataFetcherGenerator.FetcherReadyCallback
public void d() {
throw new UnsupportedOperationException();
}
private void b(Object obj) {
long a = LogTime.a();
try {
Encoder<X> a2 = this.a.a((DecodeHelper<?>) obj);
DataCacheWriter dataCacheWriter = new DataCacheWriter(a2, obj, this.a.h());
this.g = new DataCacheKey(this.f.a, this.a.k());
this.a.d().a(this.g, dataCacheWriter);
if (Log.isLoggable("SourceGenerator", 2)) {
Log.v("SourceGenerator", "Finished encoding source to cache, key: " + this.g + ", data: " + obj + ", encoder: " + a2 + ", duration: " + LogTime.a(a));
}
this.f.c.b();
this.d = new DataCacheGenerator(Collections.singletonList(this.f.a), this.a, this);
} catch (Throwable th) {
this.f.c.b();
throw th;
}
}
@Override // com.bumptech.glide.load.data.DataFetcher.DataCallback
public void a(Object obj) {
DiskCacheStrategy e = this.a.e();
if (obj != null && e.a(this.f.c.getDataSource())) {
this.e = obj;
this.b.d();
} else {
this.b.a(this.f.a, obj, this.f.c, this.f.c.getDataSource(), this.g);
}
}
@Override // com.bumptech.glide.load.data.DataFetcher.DataCallback
public void a(Exception exc) {
this.b.a(this.g, exc, this.f.c, this.f.c.getDataSource());
}
@Override // com.bumptech.glide.load.engine.DataFetcherGenerator.FetcherReadyCallback
public void a(Key key, Object obj, DataFetcher<?> dataFetcher, DataSource dataSource, Key key2) {
this.b.a(key, obj, dataFetcher, this.f.c.getDataSource(), key);
}
@Override // com.bumptech.glide.load.engine.DataFetcherGenerator.FetcherReadyCallback
public void a(Key key, Exception exc, DataFetcher<?> dataFetcher, DataSource dataSource) {
this.b.a(key, exc, dataFetcher, this.f.c.getDataSource());
}
}

View File

@@ -0,0 +1,12 @@
package com.bumptech.glide.load.engine.bitmap_recycle;
/* loaded from: classes.dex */
interface ArrayAdapterInterface<T> {
int a(T t);
String a();
int b();
T newArray(int i);
}

View File

@@ -0,0 +1,14 @@
package com.bumptech.glide.load.engine.bitmap_recycle;
/* loaded from: classes.dex */
public interface ArrayPool {
<T> T a(int i, Class<T> cls);
void a();
void a(int i);
<T> T b(int i, Class<T> cls);
<T> void put(T t);
}

View File

@@ -0,0 +1,113 @@
package com.bumptech.glide.load.engine.bitmap_recycle;
import android.graphics.Bitmap;
import com.bumptech.glide.util.Util;
/* loaded from: classes.dex */
class AttributeStrategy implements LruPoolStrategy {
private final KeyPool a = new KeyPool();
private final GroupedLinkedMap<Key, Bitmap> b = new GroupedLinkedMap<>();
static class KeyPool extends BaseKeyPool<Key> {
KeyPool() {
}
Key a(int i, int i2, Bitmap.Config config) {
Key b = b();
b.a(i, i2, config);
return b;
}
/* JADX INFO: Access modifiers changed from: protected */
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.load.engine.bitmap_recycle.BaseKeyPool
public Key a() {
return new Key(this);
}
}
AttributeStrategy() {
}
private static String d(Bitmap bitmap) {
return c(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.LruPoolStrategy
public void a(Bitmap bitmap) {
this.b.a(this.a.a(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig()), bitmap);
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.LruPoolStrategy
public String b(int i, int i2, Bitmap.Config config) {
return c(i, i2, config);
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.LruPoolStrategy
public String c(Bitmap bitmap) {
return d(bitmap);
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.LruPoolStrategy
public Bitmap removeLast() {
return this.b.a();
}
public String toString() {
return "AttributeStrategy:\n " + this.b;
}
static String c(int i, int i2, Bitmap.Config config) {
return "[" + i + "x" + i2 + "], " + config;
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.LruPoolStrategy
public int b(Bitmap bitmap) {
return Util.a(bitmap);
}
static class Key implements Poolable {
private final KeyPool a;
private int b;
private int c;
private Bitmap.Config d;
public Key(KeyPool keyPool) {
this.a = keyPool;
}
public void a(int i, int i2, Bitmap.Config config) {
this.b = i;
this.c = i2;
this.d = config;
}
public boolean equals(Object obj) {
if (!(obj instanceof Key)) {
return false;
}
Key key = (Key) obj;
return this.b == key.b && this.c == key.c && this.d == key.d;
}
public int hashCode() {
int i = ((this.b * 31) + this.c) * 31;
Bitmap.Config config = this.d;
return i + (config != null ? config.hashCode() : 0);
}
public String toString() {
return AttributeStrategy.c(this.b, this.c, this.d);
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.Poolable
public void a() {
this.a.a(this);
}
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.LruPoolStrategy
public Bitmap a(int i, int i2, Bitmap.Config config) {
return this.b.a((GroupedLinkedMap<Key, Bitmap>) this.a.a(i, i2, config));
}
}

View File

@@ -0,0 +1,26 @@
package com.bumptech.glide.load.engine.bitmap_recycle;
import com.bumptech.glide.load.engine.bitmap_recycle.Poolable;
import com.bumptech.glide.util.Util;
import java.util.Queue;
/* loaded from: classes.dex */
abstract class BaseKeyPool<T extends Poolable> {
private final Queue<T> a = Util.a(20);
BaseKeyPool() {
}
abstract T a();
public void a(T t) {
if (this.a.size() < 20) {
this.a.offer(t);
}
}
T b() {
T poll = this.a.poll();
return poll == null ? a() : poll;
}
}

View File

@@ -0,0 +1,16 @@
package com.bumptech.glide.load.engine.bitmap_recycle;
import android.graphics.Bitmap;
/* loaded from: classes.dex */
public interface BitmapPool {
Bitmap a(int i, int i2, Bitmap.Config config);
void a();
void a(int i);
void a(Bitmap bitmap);
Bitmap b(int i, int i2, Bitmap.Config config);
}

View File

@@ -0,0 +1,29 @@
package com.bumptech.glide.load.engine.bitmap_recycle;
import android.graphics.Bitmap;
/* loaded from: classes.dex */
public class BitmapPoolAdapter implements BitmapPool {
@Override // com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
public void a() {
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
public void a(int i) {
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
public void a(Bitmap bitmap) {
bitmap.recycle();
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
public Bitmap b(int i, int i2, Bitmap.Config config) {
return a(i, i2, config);
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
public Bitmap a(int i, int i2, Bitmap.Config config) {
return Bitmap.createBitmap(i, i2, config);
}
}

View File

@@ -0,0 +1,24 @@
package com.bumptech.glide.load.engine.bitmap_recycle;
/* loaded from: classes.dex */
public final class ByteArrayAdapter implements ArrayAdapterInterface<byte[]> {
@Override // com.bumptech.glide.load.engine.bitmap_recycle.ArrayAdapterInterface
public String a() {
return "ByteArrayPool";
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.ArrayAdapterInterface
public int b() {
return 1;
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.ArrayAdapterInterface
public int a(byte[] bArr) {
return bArr.length;
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.ArrayAdapterInterface
public byte[] newArray(int i) {
return new byte[i];
}
}

View File

@@ -0,0 +1,138 @@
package com.bumptech.glide.load.engine.bitmap_recycle;
import com.bumptech.glide.load.engine.bitmap_recycle.Poolable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/* loaded from: classes.dex */
class GroupedLinkedMap<K extends Poolable, V> {
private final LinkedEntry<K, V> a = new LinkedEntry<>();
private final Map<K, LinkedEntry<K, V>> b = new HashMap();
private static class LinkedEntry<K, V> {
final K a;
private List<V> b;
LinkedEntry<K, V> c;
LinkedEntry<K, V> d;
LinkedEntry() {
this(null);
}
public V a() {
int b = b();
if (b > 0) {
return this.b.remove(b - 1);
}
return null;
}
public int b() {
List<V> list = this.b;
if (list != null) {
return list.size();
}
return 0;
}
LinkedEntry(K k) {
this.d = this;
this.c = this;
this.a = k;
}
public void a(V v) {
if (this.b == null) {
this.b = new ArrayList();
}
this.b.add(v);
}
}
GroupedLinkedMap() {
}
private void b(LinkedEntry<K, V> linkedEntry) {
c(linkedEntry);
LinkedEntry<K, V> linkedEntry2 = this.a;
linkedEntry.d = linkedEntry2.d;
linkedEntry.c = linkedEntry2;
d(linkedEntry);
}
private static <K, V> void c(LinkedEntry<K, V> linkedEntry) {
LinkedEntry<K, V> linkedEntry2 = linkedEntry.d;
linkedEntry2.c = linkedEntry.c;
linkedEntry.c.d = linkedEntry2;
}
private static <K, V> void d(LinkedEntry<K, V> linkedEntry) {
linkedEntry.c.d = linkedEntry;
linkedEntry.d.c = linkedEntry;
}
public void a(K k, V v) {
LinkedEntry<K, V> linkedEntry = this.b.get(k);
if (linkedEntry == null) {
linkedEntry = new LinkedEntry<>(k);
b(linkedEntry);
this.b.put(k, linkedEntry);
} else {
k.a();
}
linkedEntry.a(v);
}
public String toString() {
StringBuilder sb = new StringBuilder("GroupedLinkedMap( ");
boolean z = false;
for (LinkedEntry linkedEntry = this.a.c; !linkedEntry.equals(this.a); linkedEntry = linkedEntry.c) {
z = true;
sb.append('{');
sb.append(linkedEntry.a);
sb.append(':');
sb.append(linkedEntry.b());
sb.append("}, ");
}
if (z) {
sb.delete(sb.length() - 2, sb.length());
}
sb.append(" )");
return sb.toString();
}
public V a(K k) {
LinkedEntry<K, V> linkedEntry = this.b.get(k);
if (linkedEntry == null) {
linkedEntry = new LinkedEntry<>(k);
this.b.put(k, linkedEntry);
} else {
k.a();
}
a(linkedEntry);
return linkedEntry.a();
}
public V a() {
for (LinkedEntry linkedEntry = this.a.d; !linkedEntry.equals(this.a); linkedEntry = linkedEntry.d) {
V v = (V) linkedEntry.a();
if (v != null) {
return v;
}
c(linkedEntry);
this.b.remove(linkedEntry.a);
((Poolable) linkedEntry.a).a();
}
return null;
}
private void a(LinkedEntry<K, V> linkedEntry) {
c(linkedEntry);
LinkedEntry<K, V> linkedEntry2 = this.a;
linkedEntry.d = linkedEntry2;
linkedEntry.c = linkedEntry2.c;
d(linkedEntry);
}
}

View File

@@ -0,0 +1,24 @@
package com.bumptech.glide.load.engine.bitmap_recycle;
/* loaded from: classes.dex */
public final class IntegerArrayAdapter implements ArrayAdapterInterface<int[]> {
@Override // com.bumptech.glide.load.engine.bitmap_recycle.ArrayAdapterInterface
public String a() {
return "IntegerArrayPool";
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.ArrayAdapterInterface
public int b() {
return 4;
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.ArrayAdapterInterface
public int a(int[] iArr) {
return iArr.length;
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.ArrayAdapterInterface
public int[] newArray(int i) {
return new int[i];
}
}

View File

@@ -0,0 +1,224 @@
package com.bumptech.glide.load.engine.bitmap_recycle;
import android.util.Log;
import com.bumptech.glide.util.Preconditions;
import java.util.HashMap;
import java.util.Map;
import java.util.NavigableMap;
import java.util.TreeMap;
/* loaded from: classes.dex */
public final class LruArrayPool implements ArrayPool {
private final GroupedLinkedMap<Key, Object> a = new GroupedLinkedMap<>();
private final KeyPool b = new KeyPool();
private final Map<Class<?>, NavigableMap<Integer, Integer>> c = new HashMap();
private final Map<Class<?>, ArrayAdapterInterface<?>> d = new HashMap();
private final int e;
private int f;
private static final class KeyPool extends BaseKeyPool<Key> {
KeyPool() {
}
Key a(int i, Class<?> cls) {
Key b = b();
b.a(i, cls);
return b;
}
/* JADX INFO: Access modifiers changed from: protected */
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.load.engine.bitmap_recycle.BaseKeyPool
public Key a() {
return new Key(this);
}
}
public LruArrayPool(int i) {
this.e = i;
}
private boolean c(int i) {
return i <= this.e / 2;
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool
public synchronized <T> T a(int i, Class<T> cls) {
return (T) a(this.b.a(i, cls), cls);
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool
public synchronized <T> T b(int i, Class<T> cls) {
Integer ceilingKey;
ceilingKey = b((Class<?>) cls).ceilingKey(Integer.valueOf(i));
return (T) a(a(i, ceilingKey) ? this.b.a(ceilingKey.intValue(), cls) : this.b.a(i, cls), cls);
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool
public synchronized <T> void put(T t) {
Class<?> cls = t.getClass();
ArrayAdapterInterface<T> a = a((Class) cls);
int a2 = a.a(t);
int b = a.b() * a2;
if (c(b)) {
Key a3 = this.b.a(a2, cls);
this.a.a(a3, t);
NavigableMap<Integer, Integer> b2 = b(cls);
Integer num = (Integer) b2.get(Integer.valueOf(a3.b));
Integer valueOf = Integer.valueOf(a3.b);
int i = 1;
if (num != null) {
i = 1 + num.intValue();
}
b2.put(valueOf, Integer.valueOf(i));
this.f += b;
b();
}
}
private static final class Key implements Poolable {
private final KeyPool a;
int b;
private Class<?> c;
Key(KeyPool keyPool) {
this.a = keyPool;
}
void a(int i, Class<?> cls) {
this.b = i;
this.c = cls;
}
public boolean equals(Object obj) {
if (!(obj instanceof Key)) {
return false;
}
Key key = (Key) obj;
return this.b == key.b && this.c == key.c;
}
public int hashCode() {
int i = this.b * 31;
Class<?> cls = this.c;
return i + (cls != null ? cls.hashCode() : 0);
}
public String toString() {
return "Key{size=" + this.b + "array=" + this.c + '}';
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.Poolable
public void a() {
this.a.a(this);
}
}
private boolean c() {
int i = this.f;
return i == 0 || this.e / i >= 2;
}
private <T> T a(Key key, Class<T> cls) {
ArrayAdapterInterface<T> a = a((Class) cls);
T t = (T) a(key);
if (t != null) {
this.f -= a.a(t) * a.b();
c(a.a(t), cls);
}
if (t != null) {
return t;
}
if (Log.isLoggable(a.a(), 2)) {
Log.v(a.a(), "Allocated " + key.b + " bytes");
}
return a.newArray(key.b);
}
private void c(int i, Class<?> cls) {
NavigableMap<Integer, Integer> b = b(cls);
Integer num = (Integer) b.get(Integer.valueOf(i));
if (num != null) {
if (num.intValue() == 1) {
b.remove(Integer.valueOf(i));
return;
} else {
b.put(Integer.valueOf(i), Integer.valueOf(num.intValue() - 1));
return;
}
}
throw new NullPointerException("Tried to decrement empty size, size: " + i + ", this: " + this);
}
private void b() {
b(this.e);
}
private void b(int i) {
while (this.f > i) {
Object a = this.a.a();
Preconditions.a(a);
ArrayAdapterInterface a2 = a((LruArrayPool) a);
this.f -= a2.a(a) * a2.b();
c(a2.a(a), a.getClass());
if (Log.isLoggable(a2.a(), 2)) {
Log.v(a2.a(), "evicted: " + a2.a(a));
}
}
}
private <T> T a(Key key) {
return (T) this.a.a((GroupedLinkedMap<Key, Object>) key);
}
private boolean a(int i, Integer num) {
return num != null && (c() || num.intValue() <= i * 8);
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool
public synchronized void a() {
b(0);
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool
public synchronized void a(int i) {
try {
if (i >= 40) {
a();
} else if (i >= 20 || i == 15) {
b(this.e / 2);
}
} catch (Throwable th) {
throw th;
}
}
private NavigableMap<Integer, Integer> b(Class<?> cls) {
NavigableMap<Integer, Integer> navigableMap = this.c.get(cls);
if (navigableMap != null) {
return navigableMap;
}
TreeMap treeMap = new TreeMap();
this.c.put(cls, treeMap);
return treeMap;
}
private <T> ArrayAdapterInterface<T> a(T t) {
return a((Class) t.getClass());
}
private <T> ArrayAdapterInterface<T> a(Class<T> cls) {
ArrayAdapterInterface<T> arrayAdapterInterface = (ArrayAdapterInterface) this.d.get(cls);
if (arrayAdapterInterface == null) {
if (cls.equals(int[].class)) {
arrayAdapterInterface = new IntegerArrayAdapter();
} else if (cls.equals(byte[].class)) {
arrayAdapterInterface = new ByteArrayAdapter();
} else {
throw new IllegalArgumentException("No array pool found for: " + cls.getSimpleName());
}
this.d.put(cls, arrayAdapterInterface);
}
return arrayAdapterInterface;
}
}

View File

@@ -0,0 +1,227 @@
package com.bumptech.glide.load.engine.bitmap_recycle;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.os.Build;
import android.util.Log;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/* loaded from: classes.dex */
public class LruBitmapPool implements BitmapPool {
private static final Bitmap.Config j = Bitmap.Config.ARGB_8888;
private final LruPoolStrategy a;
private final Set<Bitmap.Config> b;
private final BitmapTracker c;
private long d;
private long e;
private int f;
private int g;
private int h;
private int i;
private interface BitmapTracker {
void a(Bitmap bitmap);
void b(Bitmap bitmap);
}
private static final class NullBitmapTracker implements BitmapTracker {
NullBitmapTracker() {
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool.BitmapTracker
public void a(Bitmap bitmap) {
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool.BitmapTracker
public void b(Bitmap bitmap) {
}
}
LruBitmapPool(long j2, LruPoolStrategy lruPoolStrategy, Set<Bitmap.Config> set) {
this.d = j2;
this.a = lruPoolStrategy;
this.b = set;
this.c = new NullBitmapTracker();
}
private static Bitmap c(int i, int i2, Bitmap.Config config) {
if (config == null) {
config = j;
}
return Bitmap.createBitmap(i, i2, config);
}
private synchronized Bitmap d(int i, int i2, Bitmap.Config config) {
Bitmap a;
a(config);
a = this.a.a(i, i2, config != null ? config : j);
if (a == null) {
if (Log.isLoggable("LruBitmapPool", 3)) {
Log.d("LruBitmapPool", "Missing bitmap=" + this.a.b(i, i2, config));
}
this.g++;
} else {
this.f++;
this.e -= this.a.b(a);
this.c.a(a);
c(a);
}
if (Log.isLoggable("LruBitmapPool", 2)) {
Log.v("LruBitmapPool", "Get bitmap=" + this.a.b(i, i2, config));
}
c();
return a;
}
private void e() {
a(this.d);
}
@TargetApi(26)
private static Set<Bitmap.Config> f() {
HashSet hashSet = new HashSet(Arrays.asList(Bitmap.Config.values()));
if (Build.VERSION.SDK_INT >= 19) {
hashSet.add(null);
}
if (Build.VERSION.SDK_INT >= 26) {
hashSet.remove(Bitmap.Config.HARDWARE);
}
return Collections.unmodifiableSet(hashSet);
}
private static LruPoolStrategy g() {
return Build.VERSION.SDK_INT >= 19 ? new SizeConfigStrategy() : new AttributeStrategy();
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
public synchronized void a(Bitmap bitmap) {
try {
if (bitmap == null) {
throw new NullPointerException("Bitmap must not be null");
}
if (bitmap.isRecycled()) {
throw new IllegalStateException("Cannot pool recycled bitmap");
}
if (bitmap.isMutable() && this.a.b(bitmap) <= this.d && this.b.contains(bitmap.getConfig())) {
int b = this.a.b(bitmap);
this.a.a(bitmap);
this.c.b(bitmap);
this.h++;
this.e += b;
if (Log.isLoggable("LruBitmapPool", 2)) {
Log.v("LruBitmapPool", "Put bitmap in pool=" + this.a.c(bitmap));
}
c();
e();
return;
}
if (Log.isLoggable("LruBitmapPool", 2)) {
Log.v("LruBitmapPool", "Reject bitmap from pool, bitmap: " + this.a.c(bitmap) + ", is mutable: " + bitmap.isMutable() + ", is allowed config: " + this.b.contains(bitmap.getConfig()));
}
bitmap.recycle();
} catch (Throwable th) {
throw th;
}
}
public long b() {
return this.d;
}
private static void c(Bitmap bitmap) {
bitmap.setHasAlpha(true);
b(bitmap);
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
public Bitmap b(int i, int i2, Bitmap.Config config) {
Bitmap d = d(i, i2, config);
return d == null ? c(i, i2, config) : d;
}
@TargetApi(19)
private static void b(Bitmap bitmap) {
if (Build.VERSION.SDK_INT >= 19) {
bitmap.setPremultiplied(true);
}
}
private void c() {
if (Log.isLoggable("LruBitmapPool", 2)) {
d();
}
}
public LruBitmapPool(long j2) {
this(j2, g(), f());
}
private void d() {
Log.v("LruBitmapPool", "Hits=" + this.f + ", misses=" + this.g + ", puts=" + this.h + ", evictions=" + this.i + ", currentSize=" + this.e + ", maxSize=" + this.d + "\nStrategy=" + this.a);
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
public Bitmap a(int i, int i2, Bitmap.Config config) {
Bitmap d = d(i, i2, config);
if (d != null) {
d.eraseColor(0);
return d;
}
return c(i, i2, config);
}
@TargetApi(26)
private static void a(Bitmap.Config config) {
if (Build.VERSION.SDK_INT >= 26 && config == Bitmap.Config.HARDWARE) {
throw new IllegalArgumentException("Cannot create a mutable Bitmap with config: " + config + ". Consider setting Downsampler#ALLOW_HARDWARE_CONFIG to false in your RequestOptions and/or in GlideBuilder.setDefaultRequestOptions");
}
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
public void a() {
if (Log.isLoggable("LruBitmapPool", 3)) {
Log.d("LruBitmapPool", "clearMemory");
}
a(0L);
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
@SuppressLint({"InlinedApi"})
public void a(int i) {
if (Log.isLoggable("LruBitmapPool", 3)) {
Log.d("LruBitmapPool", "trimMemory, level=" + i);
}
if (i >= 40) {
a();
} else if (i >= 20 || i == 15) {
a(b() / 2);
}
}
private synchronized void a(long j2) {
while (this.e > j2) {
Bitmap removeLast = this.a.removeLast();
if (removeLast == null) {
if (Log.isLoggable("LruBitmapPool", 5)) {
Log.w("LruBitmapPool", "Size mismatch, resetting");
d();
}
this.e = 0L;
return;
}
this.c.a(removeLast);
this.e -= this.a.b(removeLast);
this.i++;
if (Log.isLoggable("LruBitmapPool", 3)) {
Log.d("LruBitmapPool", "Evicting bitmap=" + this.a.c(removeLast));
}
c();
removeLast.recycle();
}
}
}

View File

@@ -0,0 +1,18 @@
package com.bumptech.glide.load.engine.bitmap_recycle;
import android.graphics.Bitmap;
/* loaded from: classes.dex */
interface LruPoolStrategy {
Bitmap a(int i, int i2, Bitmap.Config config);
void a(Bitmap bitmap);
int b(Bitmap bitmap);
String b(int i, int i2, Bitmap.Config config);
String c(Bitmap bitmap);
Bitmap removeLast();
}

View File

@@ -0,0 +1,6 @@
package com.bumptech.glide.load.engine.bitmap_recycle;
/* loaded from: classes.dex */
interface Poolable {
void a();
}

View File

@@ -0,0 +1,243 @@
package com.bumptech.glide.load.engine.bitmap_recycle;
import android.graphics.Bitmap;
import android.os.Build;
import com.bumptech.glide.util.Util;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.NavigableMap;
import java.util.TreeMap;
/* loaded from: classes.dex */
public class SizeConfigStrategy implements LruPoolStrategy {
private static final Bitmap.Config[] d;
private static final Bitmap.Config[] e;
private static final Bitmap.Config[] f;
private static final Bitmap.Config[] g;
private static final Bitmap.Config[] h;
private final KeyPool a = new KeyPool();
private final GroupedLinkedMap<Key, Bitmap> b = new GroupedLinkedMap<>();
private final Map<Bitmap.Config, NavigableMap<Integer, Integer>> c = new HashMap();
/* renamed from: com.bumptech.glide.load.engine.bitmap_recycle.SizeConfigStrategy$1, reason: invalid class name */
static /* synthetic */ class AnonymousClass1 {
static final /* synthetic */ int[] a = new int[Bitmap.Config.values().length];
static {
try {
a[Bitmap.Config.ARGB_8888.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
a[Bitmap.Config.RGB_565.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
a[Bitmap.Config.ARGB_4444.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
a[Bitmap.Config.ALPHA_8.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
}
}
static class KeyPool extends BaseKeyPool<Key> {
KeyPool() {
}
public Key a(int i, Bitmap.Config config) {
Key b = b();
b.a(i, config);
return b;
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.bumptech.glide.load.engine.bitmap_recycle.BaseKeyPool
public Key a() {
return new Key(this);
}
}
static {
Bitmap.Config[] configArr = {Bitmap.Config.ARGB_8888, null};
if (Build.VERSION.SDK_INT >= 26) {
configArr = (Bitmap.Config[]) Arrays.copyOf(configArr, configArr.length + 1);
configArr[configArr.length - 1] = Bitmap.Config.RGBA_F16;
}
d = configArr;
e = d;
f = new Bitmap.Config[]{Bitmap.Config.RGB_565};
g = new Bitmap.Config[]{Bitmap.Config.ARGB_4444};
h = new Bitmap.Config[]{Bitmap.Config.ALPHA_8};
}
private NavigableMap<Integer, Integer> b(Bitmap.Config config) {
NavigableMap<Integer, Integer> navigableMap = this.c.get(config);
if (navigableMap != null) {
return navigableMap;
}
TreeMap treeMap = new TreeMap();
this.c.put(config, treeMap);
return treeMap;
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.LruPoolStrategy
public void a(Bitmap bitmap) {
Key a = this.a.a(Util.a(bitmap), bitmap.getConfig());
this.b.a(a, bitmap);
NavigableMap<Integer, Integer> b = b(bitmap.getConfig());
Integer num = (Integer) b.get(Integer.valueOf(a.b));
b.put(Integer.valueOf(a.b), Integer.valueOf(num != null ? 1 + num.intValue() : 1));
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.LruPoolStrategy
public String c(Bitmap bitmap) {
return b(Util.a(bitmap), bitmap.getConfig());
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.LruPoolStrategy
public Bitmap removeLast() {
Bitmap a = this.b.a();
if (a != null) {
a(Integer.valueOf(Util.a(a)), a);
}
return a;
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("SizeConfigStrategy{groupedMap=");
sb.append(this.b);
sb.append(", sortedSizes=(");
for (Map.Entry<Bitmap.Config, NavigableMap<Integer, Integer>> entry : this.c.entrySet()) {
sb.append(entry.getKey());
sb.append('[');
sb.append(entry.getValue());
sb.append("], ");
}
if (!this.c.isEmpty()) {
sb.replace(sb.length() - 2, sb.length(), "");
}
sb.append(")}");
return sb.toString();
}
static final class Key implements Poolable {
private final KeyPool a;
int b;
private Bitmap.Config c;
public Key(KeyPool keyPool) {
this.a = keyPool;
}
public void a(int i, Bitmap.Config config) {
this.b = i;
this.c = config;
}
public boolean equals(Object obj) {
if (!(obj instanceof Key)) {
return false;
}
Key key = (Key) obj;
return this.b == key.b && Util.b(this.c, key.c);
}
public int hashCode() {
int i = this.b * 31;
Bitmap.Config config = this.c;
return i + (config != null ? config.hashCode() : 0);
}
public String toString() {
return SizeConfigStrategy.b(this.b, this.c);
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.Poolable
public void a() {
this.a.a(this);
}
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.LruPoolStrategy
public String b(int i, int i2, Bitmap.Config config) {
return b(Util.a(i, i2, config), config);
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.LruPoolStrategy
public int b(Bitmap bitmap) {
return Util.a(bitmap);
}
static String b(int i, Bitmap.Config config) {
return "[" + i + "](" + config + ")";
}
@Override // com.bumptech.glide.load.engine.bitmap_recycle.LruPoolStrategy
public Bitmap a(int i, int i2, Bitmap.Config config) {
Key a = a(Util.a(i, i2, config), config);
Bitmap a2 = this.b.a((GroupedLinkedMap<Key, Bitmap>) a);
if (a2 != null) {
a(Integer.valueOf(a.b), a2);
a2.reconfigure(i, i2, a2.getConfig() != null ? a2.getConfig() : Bitmap.Config.ARGB_8888);
}
return a2;
}
private Key a(int i, Bitmap.Config config) {
Key a = this.a.a(i, config);
for (Bitmap.Config config2 : a(config)) {
Integer ceilingKey = b(config2).ceilingKey(Integer.valueOf(i));
if (ceilingKey != null && ceilingKey.intValue() <= i * 8) {
if (ceilingKey.intValue() == i) {
if (config2 == null) {
if (config == null) {
return a;
}
} else if (config2.equals(config)) {
return a;
}
}
this.a.a(a);
return this.a.a(ceilingKey.intValue(), config2);
}
}
return a;
}
private void a(Integer num, Bitmap bitmap) {
NavigableMap<Integer, Integer> b = b(bitmap.getConfig());
Integer num2 = (Integer) b.get(num);
if (num2 != null) {
if (num2.intValue() == 1) {
b.remove(num);
return;
} else {
b.put(num, Integer.valueOf(num2.intValue() - 1));
return;
}
}
throw new NullPointerException("Tried to decrement empty size, size: " + num + ", removed: " + c(bitmap) + ", this: " + this);
}
private static Bitmap.Config[] a(Bitmap.Config config) {
if (Build.VERSION.SDK_INT >= 26 && Bitmap.Config.RGBA_F16.equals(config)) {
return e;
}
int i = AnonymousClass1.a[config.ordinal()];
if (i == 1) {
return d;
}
if (i == 2) {
return f;
}
if (i != 3) {
return i != 4 ? new Bitmap.Config[]{config} : h;
}
return g;
}
}

View File

@@ -0,0 +1,22 @@
package com.bumptech.glide.load.engine.cache;
import com.bumptech.glide.load.Key;
import java.io.File;
/* loaded from: classes.dex */
public interface DiskCache {
public interface Factory {
DiskCache build();
}
public interface Writer {
boolean a(File file);
}
File a(Key key);
void a(Key key, Writer writer);
void clear();
}

View File

@@ -0,0 +1,21 @@
package com.bumptech.glide.load.engine.cache;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.cache.DiskCache;
import java.io.File;
/* loaded from: classes.dex */
public class DiskCacheAdapter implements DiskCache {
@Override // com.bumptech.glide.load.engine.cache.DiskCache
public File a(Key key) {
return null;
}
@Override // com.bumptech.glide.load.engine.cache.DiskCache
public void a(Key key, DiskCache.Writer writer) {
}
@Override // com.bumptech.glide.load.engine.cache.DiskCache
public void clear() {
}
}

View File

@@ -0,0 +1,83 @@
package com.bumptech.glide.load.engine.cache;
import com.bumptech.glide.util.Preconditions;
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/* loaded from: classes.dex */
final class DiskCacheWriteLocker {
private final Map<String, WriteLock> a = new HashMap();
private final WriteLockPool b = new WriteLockPool();
private static class WriteLock {
final Lock a = new ReentrantLock();
int b;
WriteLock() {
}
}
DiskCacheWriteLocker() {
}
void a(String str) {
WriteLock writeLock;
synchronized (this) {
writeLock = this.a.get(str);
if (writeLock == null) {
writeLock = this.b.a();
this.a.put(str, writeLock);
}
writeLock.b++;
}
writeLock.a.lock();
}
void b(String str) {
WriteLock writeLock;
synchronized (this) {
WriteLock writeLock2 = this.a.get(str);
Preconditions.a(writeLock2);
writeLock = writeLock2;
if (writeLock.b < 1) {
throw new IllegalStateException("Cannot release a lock that is not held, safeKey: " + str + ", interestedThreads: " + writeLock.b);
}
writeLock.b--;
if (writeLock.b == 0) {
WriteLock remove = this.a.remove(str);
if (!remove.equals(writeLock)) {
throw new IllegalStateException("Removed the wrong lock, expected to remove: " + writeLock + ", but actually removed: " + remove + ", safeKey: " + str);
}
this.b.a(remove);
}
}
writeLock.a.unlock();
}
private static class WriteLockPool {
private final Queue<WriteLock> a = new ArrayDeque();
WriteLockPool() {
}
WriteLock a() {
WriteLock poll;
synchronized (this.a) {
poll = this.a.poll();
}
return poll == null ? new WriteLock() : poll;
}
void a(WriteLock writeLock) {
synchronized (this.a) {
if (this.a.size() < 10) {
this.a.offer(writeLock);
}
}
}
}
}

View File

@@ -0,0 +1,31 @@
package com.bumptech.glide.load.engine.cache;
import com.bumptech.glide.load.engine.cache.DiskCache;
import java.io.File;
/* loaded from: classes.dex */
public class DiskLruCacheFactory implements DiskCache.Factory {
private final long a;
private final CacheDirectoryGetter b;
public interface CacheDirectoryGetter {
File a();
}
public DiskLruCacheFactory(CacheDirectoryGetter cacheDirectoryGetter, long j) {
this.a = j;
this.b = cacheDirectoryGetter;
}
@Override // com.bumptech.glide.load.engine.cache.DiskCache.Factory
public DiskCache build() {
File a = this.b.a();
if (a == null) {
return null;
}
if (a.mkdirs() || (a.exists() && a.isDirectory())) {
return DiskLruCacheWrapper.a(a, this.a);
}
return null;
}
}

View File

@@ -0,0 +1,112 @@
package com.bumptech.glide.load.engine.cache;
import android.util.Log;
import com.bumptech.glide.disklrucache.DiskLruCache;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.cache.DiskCache;
import java.io.File;
import java.io.IOException;
/* loaded from: classes.dex */
public class DiskLruCacheWrapper implements DiskCache {
private final File b;
private final long c;
private DiskLruCache e;
private final DiskCacheWriteLocker d = new DiskCacheWriteLocker();
private final SafeKeyGenerator a = new SafeKeyGenerator();
@Deprecated
protected DiskLruCacheWrapper(File file, long j) {
this.b = file;
this.c = j;
}
public static DiskCache a(File file, long j) {
return new DiskLruCacheWrapper(file, j);
}
private synchronized void b() {
this.e = null;
}
@Override // com.bumptech.glide.load.engine.cache.DiskCache
public synchronized void clear() {
try {
try {
a().a();
} catch (IOException e) {
if (Log.isLoggable("DiskLruCacheWrapper", 5)) {
Log.w("DiskLruCacheWrapper", "Unable to clear disk cache or disk cache cleared externally", e);
}
}
} finally {
b();
}
}
private synchronized DiskLruCache a() throws IOException {
if (this.e == null) {
this.e = DiskLruCache.a(this.b, 1, 1, this.c);
}
return this.e;
}
@Override // com.bumptech.glide.load.engine.cache.DiskCache
public File a(Key key) {
String a = this.a.a(key);
if (Log.isLoggable("DiskLruCacheWrapper", 2)) {
Log.v("DiskLruCacheWrapper", "Get: Obtained: " + a + " for for Key: " + key);
}
try {
DiskLruCache.Value b = a().b(a);
if (b != null) {
return b.a(0);
}
return null;
} catch (IOException e) {
if (!Log.isLoggable("DiskLruCacheWrapper", 5)) {
return null;
}
Log.w("DiskLruCacheWrapper", "Unable to get from disk cache", e);
return null;
}
}
@Override // com.bumptech.glide.load.engine.cache.DiskCache
public void a(Key key, DiskCache.Writer writer) {
DiskLruCache a;
String a2 = this.a.a(key);
this.d.a(a2);
try {
if (Log.isLoggable("DiskLruCacheWrapper", 2)) {
Log.v("DiskLruCacheWrapper", "Put: Obtained: " + a2 + " for for Key: " + key);
}
try {
a = a();
} catch (IOException e) {
if (Log.isLoggable("DiskLruCacheWrapper", 5)) {
Log.w("DiskLruCacheWrapper", "Unable to put to disk cache", e);
}
}
if (a.b(a2) != null) {
return;
}
DiskLruCache.Editor a3 = a.a(a2);
if (a3 != null) {
try {
if (writer.a(a3.a(0))) {
a3.c();
}
a3.b();
return;
} catch (Throwable th) {
a3.b();
throw th;
}
}
throw new IllegalStateException("Had two simultaneous puts for: " + a2);
} finally {
this.d.b(a2);
}
}
}

View File

@@ -0,0 +1,36 @@
package com.bumptech.glide.load.engine.cache;
import android.content.Context;
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
import java.io.File;
/* loaded from: classes.dex */
public final class ExternalPreferredCacheDiskCacheFactory extends DiskLruCacheFactory {
public ExternalPreferredCacheDiskCacheFactory(Context context, long j) {
this(context, "image_manager_disk_cache", j);
}
public ExternalPreferredCacheDiskCacheFactory(final Context context, final String str, long j) {
super(new DiskLruCacheFactory.CacheDirectoryGetter() { // from class: com.bumptech.glide.load.engine.cache.ExternalPreferredCacheDiskCacheFactory.1
private File b() {
File cacheDir = context.getCacheDir();
if (cacheDir == null) {
return null;
}
String str2 = str;
return str2 != null ? new File(cacheDir, str2) : cacheDir;
}
@Override // com.bumptech.glide.load.engine.cache.DiskLruCacheFactory.CacheDirectoryGetter
public File a() {
File externalCacheDir;
File b = b();
if ((b != null && b.exists()) || (externalCacheDir = context.getExternalCacheDir()) == null || !externalCacheDir.canWrite()) {
return b;
}
String str2 = str;
return str2 != null ? new File(externalCacheDir, str2) : externalCacheDir;
}
}, j);
}
}

View File

@@ -0,0 +1,30 @@
package com.bumptech.glide.load.engine.cache;
import android.content.Context;
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
import java.io.File;
/* loaded from: classes.dex */
public final class InternalCacheDiskCacheFactory extends DiskLruCacheFactory {
public InternalCacheDiskCacheFactory(Context context) {
this(context, "image_manager_disk_cache", 262144000L);
}
public InternalCacheDiskCacheFactory(Context context, long j) {
this(context, "image_manager_disk_cache", j);
}
public InternalCacheDiskCacheFactory(final Context context, final String str, long j) {
super(new DiskLruCacheFactory.CacheDirectoryGetter() { // from class: com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory.1
@Override // com.bumptech.glide.load.engine.cache.DiskLruCacheFactory.CacheDirectoryGetter
public File a() {
File cacheDir = context.getCacheDir();
if (cacheDir == null) {
return null;
}
String str2 = str;
return str2 != null ? new File(cacheDir, str2) : cacheDir;
}
}, j);
}
}

View File

@@ -0,0 +1,63 @@
package com.bumptech.glide.load.engine.cache;
import android.annotation.SuppressLint;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.cache.MemoryCache;
import com.bumptech.glide.util.LruCache;
/* loaded from: classes.dex */
public class LruResourceCache extends LruCache<Key, Resource<?>> implements MemoryCache {
private MemoryCache.ResourceRemovedListener d;
public LruResourceCache(long j) {
super(j);
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.load.engine.cache.MemoryCache
public /* bridge */ /* synthetic */ Resource a(Key key, Resource resource) {
return (Resource) super.b((LruResourceCache) key, (Key) resource);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.bumptech.glide.util.LruCache
/* renamed from: b, reason: merged with bridge method [inline-methods] */
public void a(Key key, Resource<?> resource) {
MemoryCache.ResourceRemovedListener resourceRemovedListener = this.d;
if (resourceRemovedListener == null || resource == null) {
return;
}
resourceRemovedListener.a(resource);
}
@Override // com.bumptech.glide.load.engine.cache.MemoryCache
public /* bridge */ /* synthetic */ Resource a(Key key) {
return (Resource) super.c(key);
}
@Override // com.bumptech.glide.load.engine.cache.MemoryCache
public void a(MemoryCache.ResourceRemovedListener resourceRemovedListener) {
this.d = resourceRemovedListener;
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // com.bumptech.glide.util.LruCache
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public int b(Resource<?> resource) {
if (resource == null) {
return super.b(null);
}
return resource.getSize();
}
@Override // com.bumptech.glide.load.engine.cache.MemoryCache
@SuppressLint({"InlinedApi"})
public void a(int i) {
if (i >= 40) {
a();
} else if (i >= 20 || i == 15) {
a(b() / 2);
}
}
}

View File

@@ -0,0 +1,22 @@
package com.bumptech.glide.load.engine.cache;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.engine.Resource;
/* loaded from: classes.dex */
public interface MemoryCache {
public interface ResourceRemovedListener {
void a(Resource<?> resource);
}
Resource<?> a(Key key);
Resource<?> a(Key key, Resource<?> resource);
void a();
void a(int i);
void a(ResourceRemovedListener resourceRemovedListener);
}

View File

@@ -0,0 +1,145 @@
package com.bumptech.glide.load.engine.cache;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.content.Context;
import android.os.Build;
import android.text.format.Formatter;
import android.util.DisplayMetrics;
import android.util.Log;
import com.ijm.dataencryption.de.DataDecryptTool;
/* loaded from: classes.dex */
public final class MemorySizeCalculator {
private final int a;
private final int b;
private final Context c;
private final int d;
public static final class Builder {
static final int i;
final Context a;
ActivityManager b;
ScreenDimensions c;
float e;
float d = 2.0f;
float f = 0.4f;
float g = 0.33f;
int h = 4194304;
static {
i = Build.VERSION.SDK_INT < 26 ? 4 : 1;
}
public Builder(Context context) {
this.e = i;
this.a = context;
this.b = (ActivityManager) context.getSystemService("activity");
this.c = new DisplayMetricsScreenDimensions(context.getResources().getDisplayMetrics());
if (Build.VERSION.SDK_INT < 26 || !MemorySizeCalculator.a(this.b)) {
return;
}
this.e = 0.0f;
}
public MemorySizeCalculator a() {
return new MemorySizeCalculator(this);
}
}
private static final class DisplayMetricsScreenDimensions implements ScreenDimensions {
private final DisplayMetrics a;
DisplayMetricsScreenDimensions(DisplayMetrics displayMetrics) {
this.a = displayMetrics;
}
@Override // com.bumptech.glide.load.engine.cache.MemorySizeCalculator.ScreenDimensions
public int a() {
return this.a.heightPixels;
}
@Override // com.bumptech.glide.load.engine.cache.MemorySizeCalculator.ScreenDimensions
public int b() {
return this.a.widthPixels;
}
}
interface ScreenDimensions {
int a();
int b();
}
MemorySizeCalculator(Builder builder) {
this.c = builder.a;
this.d = a(builder.b) ? builder.h / 2 : builder.h;
int a = a(builder.b, builder.f, builder.g);
float b = builder.c.b() * builder.c.a() * 4;
int round = Math.round(builder.e * b);
int round2 = Math.round(b * builder.d);
int i = a - this.d;
int i2 = round2 + round;
if (i2 <= i) {
this.b = round2;
this.a = round;
} else {
float f = i;
float f2 = builder.e;
float f3 = builder.d;
float f4 = f / (f2 + f3);
this.b = Math.round(f3 * f4);
this.a = Math.round(f4 * builder.e);
}
if (Log.isLoggable("MemorySizeCalculator", 3)) {
StringBuilder sb = new StringBuilder();
sb.append("Calculation complete, Calculated memory cache size: ");
sb.append(a(this.b));
sb.append(", pool size: ");
sb.append(a(this.a));
sb.append(", byte array size: ");
sb.append(a(this.d));
sb.append(", memory class limited? ");
sb.append(i2 > a);
sb.append(", max size: ");
sb.append(a(a));
sb.append(", memoryClass: ");
sb.append(builder.b.getMemoryClass());
sb.append(", isLowMemoryDevice: ");
sb.append(a(builder.b));
Log.d("MemorySizeCalculator", sb.toString());
}
}
public int a() {
return this.d;
}
public int b() {
return this.a;
}
public int c() {
return this.b;
}
private static int a(ActivityManager activityManager, float f, float f2) {
float memoryClass = activityManager.getMemoryClass() * DataDecryptTool.DECRYPT_SP_FILE * DataDecryptTool.DECRYPT_SP_FILE;
if (a(activityManager)) {
f = f2;
}
return Math.round(memoryClass * f);
}
private String a(int i) {
return Formatter.formatFileSize(this.c, i);
}
@TargetApi(19)
static boolean a(ActivityManager activityManager) {
if (Build.VERSION.SDK_INT >= 19) {
return activityManager.isLowRamDevice();
}
return true;
}
}

View File

@@ -0,0 +1,67 @@
package com.bumptech.glide.load.engine.cache;
import androidx.core.util.Pools$Pool;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.util.LruCache;
import com.bumptech.glide.util.Preconditions;
import com.bumptech.glide.util.Util;
import com.bumptech.glide.util.pool.FactoryPools;
import com.bumptech.glide.util.pool.StateVerifier;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/* loaded from: classes.dex */
public class SafeKeyGenerator {
private final LruCache<Key, String> a = new LruCache<>(1000);
private final Pools$Pool<PoolableDigestContainer> b = FactoryPools.b(10, new FactoryPools.Factory<PoolableDigestContainer>(this) { // from class: com.bumptech.glide.load.engine.cache.SafeKeyGenerator.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.util.pool.FactoryPools.Factory
public PoolableDigestContainer a() {
try {
return new PoolableDigestContainer(MessageDigest.getInstance("SHA-256"));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
});
private static final class PoolableDigestContainer implements FactoryPools.Poolable {
final MessageDigest a;
private final StateVerifier b = StateVerifier.b();
PoolableDigestContainer(MessageDigest messageDigest) {
this.a = messageDigest;
}
@Override // com.bumptech.glide.util.pool.FactoryPools.Poolable
public StateVerifier c() {
return this.b;
}
}
private String b(Key key) {
PoolableDigestContainer a = this.b.a();
Preconditions.a(a);
PoolableDigestContainer poolableDigestContainer = a;
try {
key.a(poolableDigestContainer.a);
return Util.a(poolableDigestContainer.a.digest());
} finally {
this.b.a(poolableDigestContainer);
}
}
public String a(Key key) {
String a;
synchronized (this.a) {
a = this.a.a((LruCache<Key, String>) key);
}
if (a == null) {
a = b(key);
}
synchronized (this.a) {
this.a.b(key, a);
}
return a;
}
}

View File

@@ -0,0 +1,200 @@
package com.bumptech.glide.load.engine.executor;
import android.os.Process;
import android.os.StrictMode;
import android.util.Log;
import com.tencent.open.SocialConstants;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/* loaded from: classes.dex */
public final class GlideExecutor implements ExecutorService {
private static final long b = TimeUnit.SECONDS.toMillis(10);
private static volatile int c;
private final ExecutorService a;
private static final class DefaultThreadFactory implements ThreadFactory {
private final String a;
final UncaughtThrowableStrategy b;
final boolean c;
private int d;
DefaultThreadFactory(String str, UncaughtThrowableStrategy uncaughtThrowableStrategy, boolean z) {
this.a = str;
this.b = uncaughtThrowableStrategy;
this.c = z;
}
@Override // java.util.concurrent.ThreadFactory
public synchronized Thread newThread(Runnable runnable) {
Thread thread;
thread = new Thread(runnable, "glide-" + this.a + "-thread-" + this.d) { // from class: com.bumptech.glide.load.engine.executor.GlideExecutor.DefaultThreadFactory.1
@Override // java.lang.Thread, java.lang.Runnable
public void run() {
Process.setThreadPriority(9);
if (DefaultThreadFactory.this.c) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectNetwork().penaltyDeath().build());
}
try {
super.run();
} catch (Throwable th) {
DefaultThreadFactory.this.b.a(th);
}
}
};
this.d = this.d + 1;
return thread;
}
}
public interface UncaughtThrowableStrategy {
public static final UncaughtThrowableStrategy a;
public static final UncaughtThrowableStrategy b;
static {
new UncaughtThrowableStrategy() { // from class: com.bumptech.glide.load.engine.executor.GlideExecutor.UncaughtThrowableStrategy.1
@Override // com.bumptech.glide.load.engine.executor.GlideExecutor.UncaughtThrowableStrategy
public void a(Throwable th) {
}
};
a = new UncaughtThrowableStrategy() { // from class: com.bumptech.glide.load.engine.executor.GlideExecutor.UncaughtThrowableStrategy.2
@Override // com.bumptech.glide.load.engine.executor.GlideExecutor.UncaughtThrowableStrategy
public void a(Throwable th) {
if (th == null || !Log.isLoggable("GlideExecutor", 6)) {
return;
}
Log.e("GlideExecutor", "Request threw uncaught throwable", th);
}
};
new UncaughtThrowableStrategy() { // from class: com.bumptech.glide.load.engine.executor.GlideExecutor.UncaughtThrowableStrategy.3
@Override // com.bumptech.glide.load.engine.executor.GlideExecutor.UncaughtThrowableStrategy
public void a(Throwable th) {
if (th != null) {
throw new RuntimeException("Request threw uncaught throwable", th);
}
}
};
b = a;
}
void a(Throwable th);
}
GlideExecutor(ExecutorService executorService) {
this.a = executorService;
}
public static GlideExecutor a(int i, String str, UncaughtThrowableStrategy uncaughtThrowableStrategy) {
return new GlideExecutor(new ThreadPoolExecutor(i, i, 0L, TimeUnit.MILLISECONDS, new PriorityBlockingQueue(), new DefaultThreadFactory(str, uncaughtThrowableStrategy, true)));
}
public static GlideExecutor b(int i, String str, UncaughtThrowableStrategy uncaughtThrowableStrategy) {
return new GlideExecutor(new ThreadPoolExecutor(i, i, 0L, TimeUnit.MILLISECONDS, new PriorityBlockingQueue(), new DefaultThreadFactory(str, uncaughtThrowableStrategy, false)));
}
public static GlideExecutor c() {
return a(1, "disk-cache", UncaughtThrowableStrategy.b);
}
public static GlideExecutor d() {
return b(a(), SocialConstants.PARAM_SOURCE, UncaughtThrowableStrategy.b);
}
public static GlideExecutor e() {
return new GlideExecutor(new ThreadPoolExecutor(0, Integer.MAX_VALUE, b, TimeUnit.MILLISECONDS, new SynchronousQueue(), new DefaultThreadFactory("source-unlimited", UncaughtThrowableStrategy.b, false)));
}
@Override // java.util.concurrent.ExecutorService
public boolean awaitTermination(long j, TimeUnit timeUnit) throws InterruptedException {
return this.a.awaitTermination(j, timeUnit);
}
@Override // java.util.concurrent.Executor
public void execute(Runnable runnable) {
this.a.execute(runnable);
}
@Override // java.util.concurrent.ExecutorService
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> collection) throws InterruptedException {
return this.a.invokeAll(collection);
}
@Override // java.util.concurrent.ExecutorService
public <T> T invokeAny(Collection<? extends Callable<T>> collection) throws InterruptedException, ExecutionException {
return (T) this.a.invokeAny(collection);
}
@Override // java.util.concurrent.ExecutorService
public boolean isShutdown() {
return this.a.isShutdown();
}
@Override // java.util.concurrent.ExecutorService
public boolean isTerminated() {
return this.a.isTerminated();
}
@Override // java.util.concurrent.ExecutorService
public void shutdown() {
this.a.shutdown();
}
@Override // java.util.concurrent.ExecutorService
public List<Runnable> shutdownNow() {
return this.a.shutdownNow();
}
@Override // java.util.concurrent.ExecutorService
public Future<?> submit(Runnable runnable) {
return this.a.submit(runnable);
}
public String toString() {
return this.a.toString();
}
public static GlideExecutor a(int i, UncaughtThrowableStrategy uncaughtThrowableStrategy) {
return new GlideExecutor(new ThreadPoolExecutor(0, i, b, TimeUnit.MILLISECONDS, new PriorityBlockingQueue(), new DefaultThreadFactory("animation", uncaughtThrowableStrategy, true)));
}
public static GlideExecutor b() {
return a(a() >= 4 ? 2 : 1, UncaughtThrowableStrategy.b);
}
@Override // java.util.concurrent.ExecutorService
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> collection, long j, TimeUnit timeUnit) throws InterruptedException {
return this.a.invokeAll(collection, j, timeUnit);
}
@Override // java.util.concurrent.ExecutorService
public <T> T invokeAny(Collection<? extends Callable<T>> collection, long j, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException {
return (T) this.a.invokeAny(collection, j, timeUnit);
}
@Override // java.util.concurrent.ExecutorService
public <T> Future<T> submit(Runnable runnable, T t) {
return this.a.submit(runnable, t);
}
public static int a() {
if (c == 0) {
c = Math.min(4, RuntimeCompat.a());
}
return c;
}
@Override // java.util.concurrent.ExecutorService
public <T> Future<T> submit(Callable<T> callable) {
return this.a.submit(callable);
}
}

View File

@@ -0,0 +1,42 @@
package com.bumptech.glide.load.engine.executor;
import android.os.Build;
import android.os.StrictMode;
import android.util.Log;
import java.io.File;
import java.io.FilenameFilter;
import java.util.regex.Pattern;
/* loaded from: classes.dex */
final class RuntimeCompat {
static int a() {
int availableProcessors = Runtime.getRuntime().availableProcessors();
return Build.VERSION.SDK_INT < 17 ? Math.max(b(), availableProcessors) : availableProcessors;
}
private static int b() {
File[] fileArr;
StrictMode.ThreadPolicy allowThreadDiskReads = StrictMode.allowThreadDiskReads();
try {
File file = new File("/sys/devices/system/cpu/");
final Pattern compile = Pattern.compile("cpu[0-9]+");
fileArr = file.listFiles(new FilenameFilter() { // from class: com.bumptech.glide.load.engine.executor.RuntimeCompat.1
@Override // java.io.FilenameFilter
public boolean accept(File file2, String str) {
return compile.matcher(str).matches();
}
});
} catch (Throwable th) {
try {
if (Log.isLoggable("GlideRuntimeCompat", 6)) {
Log.e("GlideRuntimeCompat", "Failed to calculate accurate cpu count", th);
}
StrictMode.setThreadPolicy(allowThreadDiskReads);
fileArr = null;
} finally {
StrictMode.setThreadPolicy(allowThreadDiskReads);
}
}
return Math.max(1, fileArr != null ? fileArr.length : 0);
}
}

View File

@@ -0,0 +1,14 @@
package com.bumptech.glide.load.engine.prefill;
import android.os.Handler;
import android.os.Looper;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.engine.cache.MemoryCache;
/* loaded from: classes.dex */
public final class BitmapPreFiller {
public BitmapPreFiller(MemoryCache memoryCache, BitmapPool bitmapPool, DecodeFormat decodeFormat) {
new Handler(Looper.getMainLooper());
}
}

View File

@@ -0,0 +1,82 @@
package com.bumptech.glide.load.model;
import android.content.res.AssetManager;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.data.FileDescriptorAssetPathFetcher;
import com.bumptech.glide.load.data.StreamAssetPathFetcher;
import com.bumptech.glide.load.model.ModelLoader;
import com.bumptech.glide.signature.ObjectKey;
import java.io.InputStream;
/* loaded from: classes.dex */
public class AssetUriLoader<Data> implements ModelLoader<Uri, Data> {
private static final int c = 22;
private final AssetManager a;
private final AssetFetcherFactory<Data> b;
public interface AssetFetcherFactory<Data> {
DataFetcher<Data> a(AssetManager assetManager, String str);
}
public static class FileDescriptorFactory implements ModelLoaderFactory<Uri, ParcelFileDescriptor>, AssetFetcherFactory<ParcelFileDescriptor> {
private final AssetManager a;
public FileDescriptorFactory(AssetManager assetManager) {
this.a = assetManager;
}
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
public ModelLoader<Uri, ParcelFileDescriptor> a(MultiModelLoaderFactory multiModelLoaderFactory) {
return new AssetUriLoader(this.a, this);
}
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
public void a() {
}
@Override // com.bumptech.glide.load.model.AssetUriLoader.AssetFetcherFactory
public DataFetcher<ParcelFileDescriptor> a(AssetManager assetManager, String str) {
return new FileDescriptorAssetPathFetcher(assetManager, str);
}
}
public static class StreamFactory implements ModelLoaderFactory<Uri, InputStream>, AssetFetcherFactory<InputStream> {
private final AssetManager a;
public StreamFactory(AssetManager assetManager) {
this.a = assetManager;
}
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
public ModelLoader<Uri, InputStream> a(MultiModelLoaderFactory multiModelLoaderFactory) {
return new AssetUriLoader(this.a, this);
}
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
public void a() {
}
@Override // com.bumptech.glide.load.model.AssetUriLoader.AssetFetcherFactory
public DataFetcher<InputStream> a(AssetManager assetManager, String str) {
return new StreamAssetPathFetcher(assetManager, str);
}
}
public AssetUriLoader(AssetManager assetManager, AssetFetcherFactory<Data> assetFetcherFactory) {
this.a = assetManager;
this.b = assetFetcherFactory;
}
@Override // com.bumptech.glide.load.model.ModelLoader
public ModelLoader.LoadData<Data> a(Uri uri, int i, int i2, Options options) {
return new ModelLoader.LoadData<>(new ObjectKey(uri), this.b.a(this.a, uri.toString().substring(c)));
}
@Override // com.bumptech.glide.load.model.ModelLoader
public boolean a(Uri uri) {
return "file".equals(uri.getScheme()) && !uri.getPathSegments().isEmpty() && "android_asset".equals(uri.getPathSegments().get(0));
}
}

View File

@@ -0,0 +1,112 @@
package com.bumptech.glide.load.model;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.model.ModelLoader;
import com.bumptech.glide.signature.ObjectKey;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.ByteBuffer;
/* loaded from: classes.dex */
public class ByteArrayLoader<Data> implements ModelLoader<byte[], Data> {
private final Converter<Data> a;
public static class ByteBufferFactory implements ModelLoaderFactory<byte[], ByteBuffer> {
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
public ModelLoader<byte[], ByteBuffer> a(MultiModelLoaderFactory multiModelLoaderFactory) {
return new ByteArrayLoader(new Converter<ByteBuffer>(this) { // from class: com.bumptech.glide.load.model.ByteArrayLoader.ByteBufferFactory.1
@Override // com.bumptech.glide.load.model.ByteArrayLoader.Converter
public ByteBuffer a(byte[] bArr) {
return ByteBuffer.wrap(bArr);
}
@Override // com.bumptech.glide.load.model.ByteArrayLoader.Converter
public Class<ByteBuffer> a() {
return ByteBuffer.class;
}
});
}
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
public void a() {
}
}
public interface Converter<Data> {
Class<Data> a();
Data a(byte[] bArr);
}
public static class StreamFactory implements ModelLoaderFactory<byte[], InputStream> {
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
public ModelLoader<byte[], InputStream> a(MultiModelLoaderFactory multiModelLoaderFactory) {
return new ByteArrayLoader(new Converter<InputStream>(this) { // from class: com.bumptech.glide.load.model.ByteArrayLoader.StreamFactory.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.load.model.ByteArrayLoader.Converter
public InputStream a(byte[] bArr) {
return new ByteArrayInputStream(bArr);
}
@Override // com.bumptech.glide.load.model.ByteArrayLoader.Converter
public Class<InputStream> a() {
return InputStream.class;
}
});
}
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
public void a() {
}
}
public ByteArrayLoader(Converter<Data> converter) {
this.a = converter;
}
@Override // com.bumptech.glide.load.model.ModelLoader
public boolean a(byte[] bArr) {
return true;
}
private static class Fetcher<Data> implements DataFetcher<Data> {
private final byte[] a;
private final Converter<Data> b;
Fetcher(byte[] bArr, Converter<Data> converter) {
this.a = bArr;
this.b = converter;
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void a(Priority priority, DataFetcher.DataCallback<? super Data> dataCallback) {
dataCallback.a((DataFetcher.DataCallback<? super Data>) this.b.a(this.a));
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void b() {
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void cancel() {
}
@Override // com.bumptech.glide.load.data.DataFetcher
public DataSource getDataSource() {
return DataSource.LOCAL;
}
@Override // com.bumptech.glide.load.data.DataFetcher
public Class<Data> a() {
return this.b.a();
}
}
@Override // com.bumptech.glide.load.model.ModelLoader
public ModelLoader.LoadData<Data> a(byte[] bArr, int i, int i2, Options options) {
return new ModelLoader.LoadData<>(new ObjectKey(bArr), new Fetcher(bArr, this.a));
}
}

View File

@@ -0,0 +1,25 @@
package com.bumptech.glide.load.model;
import android.util.Log;
import com.bumptech.glide.load.Encoder;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.util.ByteBufferUtil;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
/* loaded from: classes.dex */
public class ByteBufferEncoder implements Encoder<ByteBuffer> {
@Override // com.bumptech.glide.load.Encoder
public boolean a(ByteBuffer byteBuffer, File file, Options options) {
try {
ByteBufferUtil.a(byteBuffer, file);
return true;
} catch (IOException e) {
if (Log.isLoggable("ByteBufferEncoder", 3)) {
Log.d("ByteBufferEncoder", "Failed to write data", e);
}
return false;
}
}
}

View File

@@ -0,0 +1,76 @@
package com.bumptech.glide.load.model;
import android.util.Log;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.model.ModelLoader;
import com.bumptech.glide.signature.ObjectKey;
import com.bumptech.glide.util.ByteBufferUtil;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
/* loaded from: classes.dex */
public class ByteBufferFileLoader implements ModelLoader<File, ByteBuffer> {
public static class Factory implements ModelLoaderFactory<File, ByteBuffer> {
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
public ModelLoader<File, ByteBuffer> a(MultiModelLoaderFactory multiModelLoaderFactory) {
return new ByteBufferFileLoader();
}
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
public void a() {
}
}
@Override // com.bumptech.glide.load.model.ModelLoader
public boolean a(File file) {
return true;
}
@Override // com.bumptech.glide.load.model.ModelLoader
public ModelLoader.LoadData<ByteBuffer> a(File file, int i, int i2, Options options) {
return new ModelLoader.LoadData<>(new ObjectKey(file), new ByteBufferFetcher(file));
}
private static final class ByteBufferFetcher implements DataFetcher<ByteBuffer> {
private final File a;
ByteBufferFetcher(File file) {
this.a = file;
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void a(Priority priority, DataFetcher.DataCallback<? super ByteBuffer> dataCallback) {
try {
dataCallback.a((DataFetcher.DataCallback<? super ByteBuffer>) ByteBufferUtil.a(this.a));
} catch (IOException e) {
if (Log.isLoggable("ByteBufferFileLoader", 3)) {
Log.d("ByteBufferFileLoader", "Failed to obtain ByteBuffer for file", e);
}
dataCallback.a((Exception) e);
}
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void b() {
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void cancel() {
}
@Override // com.bumptech.glide.load.data.DataFetcher
public DataSource getDataSource() {
return DataSource.LOCAL;
}
@Override // com.bumptech.glide.load.data.DataFetcher
public Class<ByteBuffer> a() {
return ByteBuffer.class;
}
}
}

View File

@@ -0,0 +1,121 @@
package com.bumptech.glide.load.model;
import android.util.Base64;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.model.ModelLoader;
import com.bumptech.glide.signature.ObjectKey;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
/* loaded from: classes.dex */
public final class DataUrlLoader<Model, Data> implements ModelLoader<Model, Data> {
private final DataDecoder<Data> a;
public interface DataDecoder<Data> {
Class<Data> a();
void a(Data data) throws IOException;
Data decode(String str) throws IllegalArgumentException;
}
public static final class StreamFactory<Model> implements ModelLoaderFactory<Model, InputStream> {
private final DataDecoder<InputStream> a = new DataDecoder<InputStream>(this) { // from class: com.bumptech.glide.load.model.DataUrlLoader.StreamFactory.1
@Override // com.bumptech.glide.load.model.DataUrlLoader.DataDecoder
public void a(InputStream inputStream) throws IOException {
inputStream.close();
}
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.load.model.DataUrlLoader.DataDecoder
public InputStream decode(String str) {
if (!str.startsWith("data:image")) {
throw new IllegalArgumentException("Not a valid image data URL.");
}
int indexOf = str.indexOf(44);
if (indexOf == -1) {
throw new IllegalArgumentException("Missing comma in data URL.");
}
if (str.substring(0, indexOf).endsWith(";base64")) {
return new ByteArrayInputStream(Base64.decode(str.substring(indexOf + 1), 0));
}
throw new IllegalArgumentException("Not a base64 image data URL.");
}
@Override // com.bumptech.glide.load.model.DataUrlLoader.DataDecoder
public Class<InputStream> a() {
return InputStream.class;
}
};
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
public ModelLoader<Model, InputStream> a(MultiModelLoaderFactory multiModelLoaderFactory) {
return new DataUrlLoader(this.a);
}
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
public void a() {
}
}
public DataUrlLoader(DataDecoder<Data> dataDecoder) {
this.a = dataDecoder;
}
@Override // com.bumptech.glide.load.model.ModelLoader
public ModelLoader.LoadData<Data> a(Model model, int i, int i2, Options options) {
return new ModelLoader.LoadData<>(new ObjectKey(model), new DataUriFetcher(model.toString(), this.a));
}
private static final class DataUriFetcher<Data> implements DataFetcher<Data> {
private final String a;
private final DataDecoder<Data> b;
private Data c;
DataUriFetcher(String str, DataDecoder<Data> dataDecoder) {
this.a = str;
this.b = dataDecoder;
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void a(Priority priority, DataFetcher.DataCallback<? super Data> dataCallback) {
try {
this.c = this.b.decode(this.a);
dataCallback.a((DataFetcher.DataCallback<? super Data>) this.c);
} catch (IllegalArgumentException e) {
dataCallback.a((Exception) e);
}
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void b() {
try {
this.b.a(this.c);
} catch (IOException unused) {
}
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void cancel() {
}
@Override // com.bumptech.glide.load.data.DataFetcher
public DataSource getDataSource() {
return DataSource.LOCAL;
}
@Override // com.bumptech.glide.load.data.DataFetcher
public Class<Data> a() {
return this.b.a();
}
}
@Override // com.bumptech.glide.load.model.ModelLoader
public boolean a(Model model) {
return model.toString().startsWith("data:image");
}
}

View File

@@ -0,0 +1,152 @@
package com.bumptech.glide.load.model;
import android.os.ParcelFileDescriptor;
import android.util.Log;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.model.ModelLoader;
import com.bumptech.glide.signature.ObjectKey;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
/* loaded from: classes.dex */
public class FileLoader<Data> implements ModelLoader<File, Data> {
private final FileOpener<Data> a;
public static class Factory<Data> implements ModelLoaderFactory<File, Data> {
private final FileOpener<Data> a;
public Factory(FileOpener<Data> fileOpener) {
this.a = fileOpener;
}
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
public final ModelLoader<File, Data> a(MultiModelLoaderFactory multiModelLoaderFactory) {
return new FileLoader(this.a);
}
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
public final void a() {
}
}
public static class FileDescriptorFactory extends Factory<ParcelFileDescriptor> {
public FileDescriptorFactory() {
super(new FileOpener<ParcelFileDescriptor>() { // from class: com.bumptech.glide.load.model.FileLoader.FileDescriptorFactory.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.load.model.FileLoader.FileOpener
public ParcelFileDescriptor a(File file) throws FileNotFoundException {
return ParcelFileDescriptor.open(file, 268435456);
}
@Override // com.bumptech.glide.load.model.FileLoader.FileOpener
public void a(ParcelFileDescriptor parcelFileDescriptor) throws IOException {
parcelFileDescriptor.close();
}
@Override // com.bumptech.glide.load.model.FileLoader.FileOpener
public Class<ParcelFileDescriptor> a() {
return ParcelFileDescriptor.class;
}
});
}
}
public interface FileOpener<Data> {
Class<Data> a();
Data a(File file) throws FileNotFoundException;
void a(Data data) throws IOException;
}
public static class StreamFactory extends Factory<InputStream> {
public StreamFactory() {
super(new FileOpener<InputStream>() { // from class: com.bumptech.glide.load.model.FileLoader.StreamFactory.1
/* JADX WARN: Can't rename method to resolve collision */
@Override // com.bumptech.glide.load.model.FileLoader.FileOpener
public InputStream a(File file) throws FileNotFoundException {
return new FileInputStream(file);
}
@Override // com.bumptech.glide.load.model.FileLoader.FileOpener
public void a(InputStream inputStream) throws IOException {
inputStream.close();
}
@Override // com.bumptech.glide.load.model.FileLoader.FileOpener
public Class<InputStream> a() {
return InputStream.class;
}
});
}
}
public FileLoader(FileOpener<Data> fileOpener) {
this.a = fileOpener;
}
@Override // com.bumptech.glide.load.model.ModelLoader
public boolean a(File file) {
return true;
}
@Override // com.bumptech.glide.load.model.ModelLoader
public ModelLoader.LoadData<Data> a(File file, int i, int i2, Options options) {
return new ModelLoader.LoadData<>(new ObjectKey(file), new FileFetcher(file, this.a));
}
private static final class FileFetcher<Data> implements DataFetcher<Data> {
private final File a;
private final FileOpener<Data> b;
private Data c;
FileFetcher(File file, FileOpener<Data> fileOpener) {
this.a = file;
this.b = fileOpener;
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void a(Priority priority, DataFetcher.DataCallback<? super Data> dataCallback) {
try {
this.c = this.b.a(this.a);
dataCallback.a((DataFetcher.DataCallback<? super Data>) this.c);
} catch (FileNotFoundException e) {
if (Log.isLoggable("FileLoader", 3)) {
Log.d("FileLoader", "Failed to open file", e);
}
dataCallback.a((Exception) e);
}
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void b() {
Data data = this.c;
if (data != null) {
try {
this.b.a((FileOpener<Data>) data);
} catch (IOException unused) {
}
}
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void cancel() {
}
@Override // com.bumptech.glide.load.data.DataFetcher
public DataSource getDataSource() {
return DataSource.LOCAL;
}
@Override // com.bumptech.glide.load.data.DataFetcher
public Class<Data> a() {
return this.b.a();
}
}
}

View File

@@ -0,0 +1,121 @@
package com.bumptech.glide.load.model;
import android.net.Uri;
import android.text.TextUtils;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.util.Preconditions;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.MessageDigest;
import java.util.Map;
/* loaded from: classes.dex */
public class GlideUrl implements Key {
private final Headers b;
private final URL c;
private final String d;
private String e;
private URL f;
private volatile byte[] g;
private int h;
public GlideUrl(URL url) {
this(url, Headers.a);
}
private byte[] e() {
if (this.g == null) {
this.g = a().getBytes(Key.a);
}
return this.g;
}
private String f() {
if (TextUtils.isEmpty(this.e)) {
String str = this.d;
if (TextUtils.isEmpty(str)) {
URL url = this.c;
Preconditions.a(url);
str = url.toString();
}
this.e = Uri.encode(str, "@#&=*+-_.,:!?()/~'%;$");
}
return this.e;
}
private URL g() throws MalformedURLException {
if (this.f == null) {
this.f = new URL(f());
}
return this.f;
}
public String a() {
String str = this.d;
if (str != null) {
return str;
}
URL url = this.c;
Preconditions.a(url);
return url.toString();
}
public Map<String, String> b() {
return this.b.a();
}
public String c() {
return f();
}
public URL d() throws MalformedURLException {
return g();
}
@Override // com.bumptech.glide.load.Key
public boolean equals(Object obj) {
if (!(obj instanceof GlideUrl)) {
return false;
}
GlideUrl glideUrl = (GlideUrl) obj;
return a().equals(glideUrl.a()) && this.b.equals(glideUrl.b);
}
@Override // com.bumptech.glide.load.Key
public int hashCode() {
if (this.h == 0) {
this.h = a().hashCode();
this.h = (this.h * 31) + this.b.hashCode();
}
return this.h;
}
public String toString() {
return a();
}
public GlideUrl(String str) {
this(str, Headers.a);
}
@Override // com.bumptech.glide.load.Key
public void a(MessageDigest messageDigest) {
messageDigest.update(e());
}
public GlideUrl(URL url, Headers headers) {
Preconditions.a(url);
this.c = url;
this.d = null;
Preconditions.a(headers);
this.b = headers;
}
public GlideUrl(String str, Headers headers) {
this.c = null;
Preconditions.a(str);
this.d = str;
Preconditions.a(headers);
this.b = headers;
}
}

View File

@@ -0,0 +1,22 @@
package com.bumptech.glide.load.model;
import com.bumptech.glide.load.model.LazyHeaders;
import java.util.Collections;
import java.util.Map;
/* loaded from: classes.dex */
public interface Headers {
public static final Headers a;
static {
new Headers() { // from class: com.bumptech.glide.load.model.Headers.1
@Override // com.bumptech.glide.load.model.Headers
public Map<String, String> a() {
return Collections.emptyMap();
}
};
a = new LazyHeaders.Builder().a();
}
Map<String, String> a();
}

View File

@@ -0,0 +1,6 @@
package com.bumptech.glide.load.model;
/* loaded from: classes.dex */
public interface LazyHeaderFactory {
String a();
}

View File

@@ -0,0 +1,134 @@
package com.bumptech.glide.load.model;
import android.text.TextUtils;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/* loaded from: classes.dex */
public final class LazyHeaders implements Headers {
private final Map<String, List<LazyHeaderFactory>> b;
private volatile Map<String, String> c;
public static final class Builder {
private static final String b = b();
private static final Map<String, List<LazyHeaderFactory>> c;
private Map<String, List<LazyHeaderFactory>> a = c;
static {
HashMap hashMap = new HashMap(2);
if (!TextUtils.isEmpty(b)) {
hashMap.put("User-Agent", Collections.singletonList(new StringHeaderFactory(b)));
}
c = Collections.unmodifiableMap(hashMap);
}
static String b() {
String property = System.getProperty("http.agent");
if (TextUtils.isEmpty(property)) {
return property;
}
int length = property.length();
StringBuilder sb = new StringBuilder(property.length());
for (int i = 0; i < length; i++) {
char charAt = property.charAt(i);
if ((charAt > 31 || charAt == '\t') && charAt < 127) {
sb.append(charAt);
} else {
sb.append('?');
}
}
return sb.toString();
}
public LazyHeaders a() {
return new LazyHeaders(this.a);
}
}
static final class StringHeaderFactory implements LazyHeaderFactory {
private final String a;
StringHeaderFactory(String str) {
this.a = str;
}
@Override // com.bumptech.glide.load.model.LazyHeaderFactory
public String a() {
return this.a;
}
public boolean equals(Object obj) {
if (obj instanceof StringHeaderFactory) {
return this.a.equals(((StringHeaderFactory) obj).a);
}
return false;
}
public int hashCode() {
return this.a.hashCode();
}
public String toString() {
return "StringHeaderFactory{value='" + this.a + "'}";
}
}
LazyHeaders(Map<String, List<LazyHeaderFactory>> map) {
this.b = Collections.unmodifiableMap(map);
}
private Map<String, String> b() {
HashMap hashMap = new HashMap();
for (Map.Entry<String, List<LazyHeaderFactory>> entry : this.b.entrySet()) {
String a = a(entry.getValue());
if (!TextUtils.isEmpty(a)) {
hashMap.put(entry.getKey(), a);
}
}
return hashMap;
}
@Override // com.bumptech.glide.load.model.Headers
public Map<String, String> a() {
if (this.c == null) {
synchronized (this) {
if (this.c == null) {
this.c = Collections.unmodifiableMap(b());
}
}
}
return this.c;
}
public boolean equals(Object obj) {
if (obj instanceof LazyHeaders) {
return this.b.equals(((LazyHeaders) obj).b);
}
return false;
}
public int hashCode() {
return this.b.hashCode();
}
public String toString() {
return "LazyHeaders{headers=" + this.b + '}';
}
private String a(List<LazyHeaderFactory> list) {
StringBuilder sb = new StringBuilder();
int size = list.size();
for (int i = 0; i < size; i++) {
String a = list.get(i).a();
if (!TextUtils.isEmpty(a)) {
sb.append(a);
if (i != list.size() - 1) {
sb.append(',');
}
}
}
return sb.toString();
}
}

View File

@@ -0,0 +1,97 @@
package com.bumptech.glide.load.model;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.text.TextUtils;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.data.mediastore.MediaStoreUtil;
import com.bumptech.glide.load.model.ModelLoader;
import com.bumptech.glide.signature.ObjectKey;
import java.io.File;
import java.io.FileNotFoundException;
/* loaded from: classes.dex */
public final class MediaStoreFileLoader implements ModelLoader<Uri, File> {
private final Context a;
public static final class Factory implements ModelLoaderFactory<Uri, File> {
private final Context a;
public Factory(Context context) {
this.a = context;
}
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
public ModelLoader<Uri, File> a(MultiModelLoaderFactory multiModelLoaderFactory) {
return new MediaStoreFileLoader(this.a);
}
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
public void a() {
}
}
public MediaStoreFileLoader(Context context) {
this.a = context;
}
@Override // com.bumptech.glide.load.model.ModelLoader
public ModelLoader.LoadData<File> a(Uri uri, int i, int i2, Options options) {
return new ModelLoader.LoadData<>(new ObjectKey(uri), new FilePathFetcher(this.a, uri));
}
@Override // com.bumptech.glide.load.model.ModelLoader
public boolean a(Uri uri) {
return MediaStoreUtil.b(uri);
}
private static class FilePathFetcher implements DataFetcher<File> {
private static final String[] c = {"_data"};
private final Context a;
private final Uri b;
FilePathFetcher(Context context, Uri uri) {
this.a = context;
this.b = uri;
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void a(Priority priority, DataFetcher.DataCallback<? super File> dataCallback) {
Cursor query = this.a.getContentResolver().query(this.b, c, null, null, null);
if (query != null) {
try {
r0 = query.moveToFirst() ? query.getString(query.getColumnIndexOrThrow("_data")) : null;
} finally {
query.close();
}
}
if (!TextUtils.isEmpty(r0)) {
dataCallback.a((DataFetcher.DataCallback<? super File>) new File(r0));
return;
}
dataCallback.a((Exception) new FileNotFoundException("Failed to find file path for: " + this.b));
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void b() {
}
@Override // com.bumptech.glide.load.data.DataFetcher
public void cancel() {
}
@Override // com.bumptech.glide.load.data.DataFetcher
public DataSource getDataSource() {
return DataSource.LOCAL;
}
@Override // com.bumptech.glide.load.data.DataFetcher
public Class<File> a() {
return File.class;
}
}
}

View File

@@ -0,0 +1,6 @@
package com.bumptech.glide.load.model;
/* loaded from: classes.dex */
public interface Model {
boolean a(Object obj);
}

View File

@@ -0,0 +1,80 @@
package com.bumptech.glide.load.model;
import com.bumptech.glide.util.LruCache;
import com.bumptech.glide.util.Util;
import java.util.Queue;
/* loaded from: classes.dex */
public class ModelCache<A, B> {
private final LruCache<ModelKey<A>, B> a;
public ModelCache(long j) {
this.a = new LruCache<ModelKey<A>, B>(this, j) { // from class: com.bumptech.glide.load.model.ModelCache.1
@Override // com.bumptech.glide.util.LruCache
protected /* bridge */ /* synthetic */ void a(Object obj, Object obj2) {
a((ModelKey) obj, (ModelKey<A>) obj2);
}
protected void a(ModelKey<A> modelKey, B b) {
modelKey.a();
}
};
}
public B a(A a, int i, int i2) {
ModelKey<A> a2 = ModelKey.a(a, i, i2);
B a3 = this.a.a((LruCache<ModelKey<A>, B>) a2);
a2.a();
return a3;
}
public void a(A a, int i, int i2, B b) {
this.a.b(ModelKey.a(a, i, i2), b);
}
static final class ModelKey<A> {
private static final Queue<ModelKey<?>> d = Util.a(0);
private int a;
private int b;
private A c;
private ModelKey() {
}
static <A> ModelKey<A> a(A a, int i, int i2) {
ModelKey<A> modelKey;
synchronized (d) {
modelKey = (ModelKey) d.poll();
}
if (modelKey == null) {
modelKey = new ModelKey<>();
}
modelKey.b(a, i, i2);
return modelKey;
}
private void b(A a, int i, int i2) {
this.c = a;
this.b = i;
this.a = i2;
}
public boolean equals(Object obj) {
if (!(obj instanceof ModelKey)) {
return false;
}
ModelKey modelKey = (ModelKey) obj;
return this.b == modelKey.b && this.a == modelKey.a && this.c.equals(modelKey.c);
}
public int hashCode() {
return (((this.a * 31) + this.b) * 31) + this.c.hashCode();
}
public void a() {
synchronized (d) {
d.offer(this);
}
}
}
}

View File

@@ -0,0 +1,35 @@
package com.bumptech.glide.load.model;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.util.Preconditions;
import java.util.Collections;
import java.util.List;
/* loaded from: classes.dex */
public interface ModelLoader<Model, Data> {
public static class LoadData<Data> {
public final Key a;
public final List<Key> b;
public final DataFetcher<Data> c;
public LoadData(Key key, DataFetcher<Data> dataFetcher) {
this(key, Collections.emptyList(), dataFetcher);
}
public LoadData(Key key, List<Key> list, DataFetcher<Data> dataFetcher) {
Preconditions.a(key);
this.a = key;
Preconditions.a(list);
this.b = list;
Preconditions.a(dataFetcher);
this.c = dataFetcher;
}
}
LoadData<Data> a(Model model, int i, int i2, Options options);
boolean a(Model model);
}

View File

@@ -0,0 +1,8 @@
package com.bumptech.glide.load.model;
/* loaded from: classes.dex */
public interface ModelLoaderFactory<T, Y> {
ModelLoader<T, Y> a(MultiModelLoaderFactory multiModelLoaderFactory);
void a();
}

Some files were not shown because too many files have changed in this diff Show More