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,215 @@
package com.bumptech.glide.util;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.util.concurrent.atomic.AtomicReference;
/* loaded from: classes.dex */
public final class ByteBufferUtil {
static final class SafeArray {
final int a;
final int b;
final byte[] c;
SafeArray(byte[] bArr, int i, int i2) {
this.c = bArr;
this.a = i;
this.b = i2;
}
}
static {
new AtomicReference();
}
public static ByteBuffer a(File file) throws IOException {
RandomAccessFile randomAccessFile;
FileChannel channel;
FileChannel fileChannel = null;
try {
long length = file.length();
if (length > 2147483647L) {
throw new IOException("File too large to map into memory");
}
if (length == 0) {
throw new IOException("File unsuitable for memory mapping");
}
randomAccessFile = new RandomAccessFile(file, "r");
try {
channel = randomAccessFile.getChannel();
} catch (Throwable th) {
th = th;
}
try {
MappedByteBuffer load = channel.map(FileChannel.MapMode.READ_ONLY, 0L, length).load();
if (channel != null) {
try {
channel.close();
} catch (IOException unused) {
}
}
try {
randomAccessFile.close();
} catch (IOException unused2) {
}
return load;
} catch (Throwable th2) {
fileChannel = channel;
th = th2;
if (fileChannel != null) {
try {
fileChannel.close();
} catch (IOException unused3) {
}
}
if (randomAccessFile == null) {
throw th;
}
try {
randomAccessFile.close();
throw th;
} catch (IOException unused4) {
throw th;
}
}
} catch (Throwable th3) {
th = th3;
randomAccessFile = null;
}
}
public static byte[] b(ByteBuffer byteBuffer) {
SafeArray a = a(byteBuffer);
if (a != null && a.a == 0 && a.b == a.c.length) {
return byteBuffer.array();
}
ByteBuffer asReadOnlyBuffer = byteBuffer.asReadOnlyBuffer();
byte[] bArr = new byte[asReadOnlyBuffer.limit()];
asReadOnlyBuffer.position(0);
asReadOnlyBuffer.get(bArr);
return bArr;
}
public static InputStream c(ByteBuffer byteBuffer) {
return new ByteBufferStream(byteBuffer);
}
private static class ByteBufferStream extends InputStream {
private final ByteBuffer a;
private int b = -1;
ByteBufferStream(ByteBuffer byteBuffer) {
this.a = byteBuffer;
}
@Override // java.io.InputStream
public int available() {
return this.a.remaining();
}
@Override // java.io.InputStream
public synchronized void mark(int i) {
this.b = this.a.position();
}
@Override // java.io.InputStream
public boolean markSupported() {
return true;
}
@Override // java.io.InputStream
public int read() {
if (this.a.hasRemaining()) {
return this.a.get();
}
return -1;
}
@Override // java.io.InputStream
public synchronized void reset() throws IOException {
if (this.b == -1) {
throw new IOException("Cannot reset to unset mark position");
}
this.a.position(this.b);
}
@Override // java.io.InputStream
public long skip(long j) throws IOException {
if (!this.a.hasRemaining()) {
return -1L;
}
long min = Math.min(j, available());
this.a.position((int) (r0.position() + min));
return min;
}
@Override // java.io.InputStream
public int read(byte[] bArr, int i, int i2) throws IOException {
if (!this.a.hasRemaining()) {
return -1;
}
int min = Math.min(i2, available());
this.a.get(bArr, i, min);
return min;
}
}
public static void a(ByteBuffer byteBuffer, File file) throws IOException {
RandomAccessFile randomAccessFile;
byteBuffer.position(0);
FileChannel fileChannel = null;
try {
randomAccessFile = new RandomAccessFile(file, "rw");
} catch (Throwable th) {
th = th;
randomAccessFile = null;
}
try {
fileChannel = randomAccessFile.getChannel();
fileChannel.write(byteBuffer);
fileChannel.force(false);
fileChannel.close();
randomAccessFile.close();
if (fileChannel != null) {
try {
fileChannel.close();
} catch (IOException unused) {
}
}
try {
randomAccessFile.close();
} catch (IOException unused2) {
}
} catch (Throwable th2) {
th = th2;
if (fileChannel != null) {
try {
fileChannel.close();
} catch (IOException unused3) {
}
}
if (randomAccessFile != null) {
try {
randomAccessFile.close();
throw th;
} catch (IOException unused4) {
throw th;
}
}
throw th;
}
}
private static SafeArray a(ByteBuffer byteBuffer) {
if (byteBuffer.isReadOnly() || !byteBuffer.hasArray()) {
return null;
}
return new SafeArray(byteBuffer.array(), byteBuffer.arrayOffset(), byteBuffer.limit());
}
}

View File

@@ -0,0 +1,47 @@
package com.bumptech.glide.util;
import androidx.collection.ArrayMap;
import androidx.collection.SimpleArrayMap;
/* loaded from: classes.dex */
public final class CachedHashCodeArrayMap<K, V> extends ArrayMap<K, V> {
private int i;
@Override // androidx.collection.SimpleArrayMap
public V a(int i, V v) {
this.i = 0;
return (V) super.a(i, (int) v);
}
@Override // androidx.collection.SimpleArrayMap
public V c(int i) {
this.i = 0;
return (V) super.c(i);
}
@Override // androidx.collection.SimpleArrayMap, java.util.Map
public void clear() {
this.i = 0;
super.clear();
}
@Override // androidx.collection.SimpleArrayMap, java.util.Map
public int hashCode() {
if (this.i == 0) {
this.i = super.hashCode();
}
return this.i;
}
@Override // androidx.collection.SimpleArrayMap, java.util.Map
public V put(K k, V v) {
this.i = 0;
return (V) super.put(k, v);
}
@Override // androidx.collection.SimpleArrayMap
public void a(SimpleArrayMap<? extends K, ? extends V> simpleArrayMap) {
this.i = 0;
super.a((SimpleArrayMap) simpleArrayMap);
}
}

View File

@@ -0,0 +1,55 @@
package com.bumptech.glide.util;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
/* loaded from: classes.dex */
public final class ContentLengthInputStream extends FilterInputStream {
private final long a;
private int b;
private ContentLengthInputStream(InputStream inputStream, long j) {
super(inputStream);
this.a = j;
}
public static InputStream a(InputStream inputStream, long j) {
return new ContentLengthInputStream(inputStream, j);
}
@Override // java.io.FilterInputStream, java.io.InputStream
public synchronized int available() throws IOException {
return (int) Math.max(this.a - this.b, ((FilterInputStream) this).in.available());
}
@Override // java.io.FilterInputStream, java.io.InputStream
public synchronized int read() throws IOException {
int read;
read = super.read();
a(read >= 0 ? 1 : -1);
return read;
}
private int a(int i) throws IOException {
if (i >= 0) {
this.b += i;
} else if (this.a - this.b > 0) {
throw new IOException("Failed to read all expected data, expected: " + this.a + ", but read: " + this.b);
}
return i;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public int read(byte[] bArr) throws IOException {
return read(bArr, 0, bArr.length);
}
@Override // java.io.FilterInputStream, java.io.InputStream
public synchronized int read(byte[] bArr, int i, int i2) throws IOException {
int read;
read = super.read(bArr, i, i2);
a(read);
return read;
}
}

View File

@@ -0,0 +1,108 @@
package com.bumptech.glide.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Queue;
/* loaded from: classes.dex */
public class ExceptionCatchingInputStream extends InputStream {
private static final Queue<ExceptionCatchingInputStream> c = Util.a(0);
private InputStream a;
private IOException b;
ExceptionCatchingInputStream() {
}
public static ExceptionCatchingInputStream b(InputStream inputStream) {
ExceptionCatchingInputStream poll;
synchronized (c) {
poll = c.poll();
}
if (poll == null) {
poll = new ExceptionCatchingInputStream();
}
poll.a(inputStream);
return poll;
}
void a(InputStream inputStream) {
this.a = inputStream;
}
@Override // java.io.InputStream
public int available() throws IOException {
return this.a.available();
}
@Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
public void close() throws IOException {
this.a.close();
}
@Override // java.io.InputStream
public void mark(int i) {
this.a.mark(i);
}
@Override // java.io.InputStream
public boolean markSupported() {
return this.a.markSupported();
}
@Override // java.io.InputStream
public int read(byte[] bArr) {
try {
return this.a.read(bArr);
} catch (IOException e) {
this.b = e;
return -1;
}
}
@Override // java.io.InputStream
public synchronized void reset() throws IOException {
this.a.reset();
}
@Override // java.io.InputStream
public long skip(long j) {
try {
return this.a.skip(j);
} catch (IOException e) {
this.b = e;
return 0L;
}
}
public IOException a() {
return this.b;
}
@Override // java.io.InputStream
public int read(byte[] bArr, int i, int i2) {
try {
return this.a.read(bArr, i, i2);
} catch (IOException e) {
this.b = e;
return -1;
}
}
@Override // java.io.InputStream
public int read() {
try {
return this.a.read();
} catch (IOException e) {
this.b = e;
return -1;
}
}
public void b() {
this.b = null;
this.a = null;
synchronized (c) {
c.offer(this);
}
}
}

View File

@@ -0,0 +1,23 @@
package com.bumptech.glide.util;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.SystemClock;
/* loaded from: classes.dex */
public final class LogTime {
private static final double a;
static {
a = Build.VERSION.SDK_INT >= 17 ? 1.0d / Math.pow(10.0d, 6.0d) : 1.0d;
}
@TargetApi(17)
public static long a() {
return Build.VERSION.SDK_INT >= 17 ? SystemClock.elapsedRealtimeNanos() : SystemClock.uptimeMillis();
}
public static double a(long j) {
return (a() - j) * a;
}
}

View File

@@ -0,0 +1,80 @@
package com.bumptech.glide.util;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
/* loaded from: classes.dex */
public class LruCache<T, Y> {
private final Map<T, Y> a = new LinkedHashMap(100, 0.75f, true);
private long b;
private long c;
public LruCache(long j) {
this.b = j;
}
public synchronized Y a(T t) {
return this.a.get(t);
}
protected void a(T t, Y y) {
}
protected int b(Y y) {
return 1;
}
public synchronized long b() {
return this.b;
}
public synchronized Y c(T t) {
Y remove;
remove = this.a.remove(t);
if (remove != null) {
this.c -= b(remove);
}
return remove;
}
public void a() {
a(0L);
}
public synchronized Y b(T t, Y y) {
long b = b(y);
if (b >= this.b) {
a(t, y);
return null;
}
if (y != null) {
this.c += b;
}
Y put = this.a.put(t, y);
if (put != null) {
this.c -= b(put);
if (!put.equals(y)) {
a(t, put);
}
}
c();
return put;
}
protected synchronized void a(long j) {
while (this.c > j) {
Iterator<Map.Entry<T, Y>> it = this.a.entrySet().iterator();
Map.Entry<T, Y> next = it.next();
Y value = next.getValue();
this.c -= b(value);
T key = next.getKey();
it.remove();
a(key, value);
}
}
private void c() {
a(this.b);
}
}

View File

@@ -0,0 +1,81 @@
package com.bumptech.glide.util;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
/* loaded from: classes.dex */
public class MarkEnforcingInputStream extends FilterInputStream {
private int a;
public MarkEnforcingInputStream(InputStream inputStream) {
super(inputStream);
this.a = Integer.MIN_VALUE;
}
private long a(long j) {
int i = this.a;
if (i == 0) {
return -1L;
}
return (i == Integer.MIN_VALUE || j <= ((long) i)) ? j : i;
}
private void b(long j) {
int i = this.a;
if (i == Integer.MIN_VALUE || j == -1) {
return;
}
this.a = (int) (i - j);
}
@Override // java.io.FilterInputStream, java.io.InputStream
public int available() throws IOException {
int i = this.a;
return i == Integer.MIN_VALUE ? super.available() : Math.min(i, super.available());
}
@Override // java.io.FilterInputStream, java.io.InputStream
public synchronized void mark(int i) {
super.mark(i);
this.a = i;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public int read() throws IOException {
if (a(1L) == -1) {
return -1;
}
int read = super.read();
b(1L);
return read;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public synchronized void reset() throws IOException {
super.reset();
this.a = Integer.MIN_VALUE;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public long skip(long j) throws IOException {
long a = a(j);
if (a == -1) {
return 0L;
}
long skip = super.skip(a);
b(skip);
return skip;
}
@Override // java.io.FilterInputStream, java.io.InputStream
public int read(byte[] bArr, int i, int i2) throws IOException {
int a = (int) a(i2);
if (a == -1) {
return -1;
}
int read = super.read(bArr, i, a);
b(read);
return read;
}
}

View File

@@ -0,0 +1,50 @@
package com.bumptech.glide.util;
/* loaded from: classes.dex */
public class MultiClassKey {
private Class<?> a;
private Class<?> b;
private Class<?> c;
public MultiClassKey() {
}
public void a(Class<?> cls, Class<?> cls2) {
a(cls, cls2, null);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || MultiClassKey.class != obj.getClass()) {
return false;
}
MultiClassKey multiClassKey = (MultiClassKey) obj;
return this.a.equals(multiClassKey.a) && this.b.equals(multiClassKey.b) && Util.b(this.c, multiClassKey.c);
}
public int hashCode() {
int hashCode = ((this.a.hashCode() * 31) + this.b.hashCode()) * 31;
Class<?> cls = this.c;
return hashCode + (cls != null ? cls.hashCode() : 0);
}
public String toString() {
return "MultiClassKey{first=" + this.a + ", second=" + this.b + '}';
}
public MultiClassKey(Class<?> cls, Class<?> cls2) {
a(cls, cls2);
}
public void a(Class<?> cls, Class<?> cls2, Class<?> cls3) {
this.a = cls;
this.b = cls2;
this.c = cls3;
}
public MultiClassKey(Class<?> cls, Class<?> cls2, Class<?> cls3) {
a(cls, cls2, cls3);
}
}

View File

@@ -0,0 +1,39 @@
package com.bumptech.glide.util;
import android.text.TextUtils;
import java.util.Collection;
/* loaded from: classes.dex */
public final class Preconditions {
public static void a(boolean z, String str) {
if (!z) {
throw new IllegalArgumentException(str);
}
}
public static <T> T a(T t) {
a(t, "Argument must not be null");
return t;
}
public static <T> T a(T t, String str) {
if (t != null) {
return t;
}
throw new NullPointerException(str);
}
public static String a(String str) {
if (TextUtils.isEmpty(str)) {
throw new IllegalArgumentException("Must not be null or empty");
}
return str;
}
public static <T extends Collection<Y>, Y> T a(T t) {
if (t.isEmpty()) {
throw new IllegalArgumentException("Must not be empty.");
}
return t;
}
}

View File

@@ -0,0 +1,180 @@
package com.bumptech.glide.util;
import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Looper;
import com.bumptech.glide.load.model.Model;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Queue;
/* loaded from: classes.dex */
public final class Util {
private static final char[] a = "0123456789abcdef".toCharArray();
private static final char[] b = new char[64];
/* renamed from: com.bumptech.glide.util.Util$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.ALPHA_8.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.RGBA_F16.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
a[Bitmap.Config.ARGB_8888.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
}
}
public static int a(int i, int i2) {
return (i2 * 31) + i;
}
public static String a(byte[] bArr) {
String a2;
synchronized (b) {
a2 = a(bArr, b);
}
return a2;
}
public static boolean b(int i, int i2) {
return c(i) && c(i2);
}
public static boolean c() {
return !d();
}
private static boolean c(int i) {
return i > 0 || i == Integer.MIN_VALUE;
}
public static boolean d() {
return Looper.myLooper() == Looper.getMainLooper();
}
public static void b() {
if (!d()) {
throw new IllegalArgumentException("You must call this method on the main thread");
}
}
private static String a(byte[] bArr, char[] cArr) {
for (int i = 0; i < bArr.length; i++) {
int i2 = bArr[i] & 255;
int i3 = i * 2;
char[] cArr2 = a;
cArr[i3] = cArr2[i2 >>> 4];
cArr[i3 + 1] = cArr2[i2 & 15];
}
return new String(cArr);
}
public static boolean b(Object obj, Object obj2) {
if (obj == null) {
return obj2 == null;
}
return obj.equals(obj2);
}
public static int b(int i) {
return a(i, 17);
}
@TargetApi(19)
public static int a(Bitmap bitmap) {
if (!bitmap.isRecycled()) {
if (Build.VERSION.SDK_INT >= 19) {
try {
return bitmap.getAllocationByteCount();
} catch (NullPointerException unused) {
}
}
return bitmap.getHeight() * bitmap.getRowBytes();
}
throw new IllegalStateException("Cannot obtain size for recycled Bitmap: " + bitmap + "[" + bitmap.getWidth() + "x" + bitmap.getHeight() + "] " + bitmap.getConfig());
}
public static int a(int i, int i2, Bitmap.Config config) {
return i * i2 * a(config);
}
private static int a(Bitmap.Config config) {
if (config == null) {
config = Bitmap.Config.ARGB_8888;
}
int i = AnonymousClass1.a[config.ordinal()];
if (i == 1) {
return 1;
}
if (i == 2 || i == 3) {
return 2;
}
return i != 4 ? 4 : 8;
}
public static void a() {
if (!c()) {
throw new IllegalArgumentException("You must call this method on a background thread");
}
}
public static <T> Queue<T> a(int i) {
return new ArrayDeque(i);
}
public static <T> List<T> a(Collection<T> collection) {
ArrayList arrayList = new ArrayList(collection.size());
for (T t : collection) {
if (t != null) {
arrayList.add(t);
}
}
return arrayList;
}
public static boolean a(Object obj, Object obj2) {
if (obj == null) {
return obj2 == null;
}
if (obj instanceof Model) {
return ((Model) obj).a(obj2);
}
return obj.equals(obj2);
}
public static int a(float f) {
return a(f, 17);
}
public static int a(float f, int i) {
return a(Float.floatToIntBits(f), i);
}
public static int a(Object obj, int i) {
return a(obj == null ? 0 : obj.hashCode(), i);
}
public static int a(boolean z, int i) {
return a(z ? 1 : 0, i);
}
}

View File

@@ -0,0 +1,103 @@
package com.bumptech.glide.util.pool;
import android.util.Log;
import androidx.core.util.Pools$Pool;
import androidx.core.util.Pools$SimplePool;
import androidx.core.util.Pools$SynchronizedPool;
import java.util.ArrayList;
import java.util.List;
/* loaded from: classes.dex */
public final class FactoryPools {
private static final Resetter<Object> a = new Resetter<Object>() { // from class: com.bumptech.glide.util.pool.FactoryPools.1
@Override // com.bumptech.glide.util.pool.FactoryPools.Resetter
public void a(Object obj) {
}
};
public interface Factory<T> {
T a();
}
public interface Poolable {
StateVerifier c();
}
public interface Resetter<T> {
void a(T t);
}
public static <T extends Poolable> Pools$Pool<T> a(int i, Factory<T> factory) {
return a(new Pools$SimplePool(i), factory);
}
public static <T extends Poolable> Pools$Pool<T> b(int i, Factory<T> factory) {
return a(new Pools$SynchronizedPool(i), factory);
}
public static <T> Pools$Pool<List<T>> a(int i) {
return a(new Pools$SynchronizedPool(i), new Factory<List<T>>() { // from class: com.bumptech.glide.util.pool.FactoryPools.2
@Override // com.bumptech.glide.util.pool.FactoryPools.Factory
public List<T> a() {
return new ArrayList();
}
}, new Resetter<List<T>>() { // from class: com.bumptech.glide.util.pool.FactoryPools.3
@Override // com.bumptech.glide.util.pool.FactoryPools.Resetter
public void a(List<T> list) {
list.clear();
}
});
}
public static <T> Pools$Pool<List<T>> b() {
return a(20);
}
private static <T extends Poolable> Pools$Pool<T> a(Pools$Pool<T> pools$Pool, Factory<T> factory) {
return a(pools$Pool, factory, a());
}
private static <T> Pools$Pool<T> a(Pools$Pool<T> pools$Pool, Factory<T> factory, Resetter<T> resetter) {
return new FactoryPool(pools$Pool, factory, resetter);
}
private static <T> Resetter<T> a() {
return (Resetter<T>) a;
}
private static final class FactoryPool<T> implements Pools$Pool<T> {
private final Factory<T> a;
private final Resetter<T> b;
private final Pools$Pool<T> c;
FactoryPool(Pools$Pool<T> pools$Pool, Factory<T> factory, Resetter<T> resetter) {
this.c = pools$Pool;
this.a = factory;
this.b = resetter;
}
@Override // androidx.core.util.Pools$Pool
public T a() {
T a = this.c.a();
if (a == null) {
a = this.a.a();
if (Log.isLoggable("FactoryPools", 2)) {
Log.v("FactoryPools", "Created new " + a.getClass());
}
}
if (a instanceof Poolable) {
a.c().a(false);
}
return (T) a;
}
@Override // androidx.core.util.Pools$Pool
public boolean a(T t) {
if (t instanceof Poolable) {
((Poolable) t).c().a(true);
}
this.b.a(t);
return this.c.a(t);
}
}
}

View File

@@ -0,0 +1,16 @@
package com.bumptech.glide.util.pool;
/* loaded from: classes.dex */
public final class GlideTrace {
public static void a() {
}
public static void a(String str) {
}
public static void a(String str, Object obj) {
}
public static void a(String str, Object obj, Object obj2, Object obj3) {
}
}

View File

@@ -0,0 +1,35 @@
package com.bumptech.glide.util.pool;
/* loaded from: classes.dex */
public abstract class StateVerifier {
public static StateVerifier b() {
return new DefaultStateVerifier();
}
public abstract void a();
abstract void a(boolean z);
private static class DefaultStateVerifier extends StateVerifier {
private volatile boolean a;
DefaultStateVerifier() {
super();
}
@Override // com.bumptech.glide.util.pool.StateVerifier
public void a() {
if (this.a) {
throw new IllegalStateException("Already released");
}
}
@Override // com.bumptech.glide.util.pool.StateVerifier
public void a(boolean z) {
this.a = z;
}
}
private StateVerifier() {
}
}