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,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());
}
}