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,53 @@
package com.bumptech.glide.load.resource.drawable;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.view.ContextThemeWrapper;
import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat;
/* loaded from: classes.dex */
public final class DrawableDecoderCompat {
private static volatile boolean a = true;
public static Drawable a(Context context, Context context2, int i) {
return a(context, context2, i, null);
}
private static Drawable b(Context context, int i, Resources.Theme theme) {
return ResourcesCompat.a(context.getResources(), i, theme);
}
private static Drawable c(Context context, int i, Resources.Theme theme) {
if (theme != null) {
context = new ContextThemeWrapper(context, theme);
}
return AppCompatResources.c(context, i);
}
public static Drawable a(Context context, int i, Resources.Theme theme) {
return a(context, context, i, theme);
}
private static Drawable a(Context context, Context context2, int i, Resources.Theme theme) {
try {
if (a) {
return c(context2, i, theme);
}
} catch (Resources.NotFoundException unused) {
} catch (IllegalStateException e) {
if (!context.getPackageName().equals(context2.getPackageName())) {
return ContextCompat.c(context2, i);
}
throw e;
} catch (NoClassDefFoundError unused2) {
a = false;
}
if (theme == null) {
theme = context2.getTheme();
}
return b(context2, i, theme);
}
}

View File

@@ -0,0 +1,34 @@
package com.bumptech.glide.load.resource.drawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import com.bumptech.glide.load.engine.Initializable;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.resource.gif.GifDrawable;
import com.bumptech.glide.util.Preconditions;
/* loaded from: classes.dex */
public abstract class DrawableResource<T extends Drawable> implements Resource<T>, Initializable {
protected final T a;
public DrawableResource(T t) {
Preconditions.a(t);
this.a = t;
}
@Override // com.bumptech.glide.load.engine.Initializable
public void c() {
T t = this.a;
if (t instanceof BitmapDrawable) {
((BitmapDrawable) t).getBitmap().prepareToDraw();
} else if (t instanceof GifDrawable) {
((GifDrawable) t).c().prepareToDraw();
}
}
@Override // com.bumptech.glide.load.engine.Resource
public final T get() {
Drawable.ConstantState constantState = this.a.getConstantState();
return constantState == null ? this.a : (T) constantState.newDrawable();
}
}

View File

@@ -0,0 +1,32 @@
package com.bumptech.glide.load.resource.drawable;
import android.graphics.drawable.Drawable;
import com.bumptech.glide.load.engine.Resource;
/* loaded from: classes.dex */
final class NonOwnedDrawableResource extends DrawableResource<Drawable> {
private NonOwnedDrawableResource(Drawable drawable) {
super(drawable);
}
static Resource<Drawable> a(Drawable drawable) {
if (drawable != null) {
return new NonOwnedDrawableResource(drawable);
}
return null;
}
@Override // com.bumptech.glide.load.engine.Resource
public void a() {
}
@Override // com.bumptech.glide.load.engine.Resource
public Class<Drawable> b() {
return this.a.getClass();
}
@Override // com.bumptech.glide.load.engine.Resource
public int getSize() {
return Math.max(1, this.a.getIntrinsicWidth() * this.a.getIntrinsicHeight() * 4);
}
}

View File

@@ -0,0 +1,63 @@
package com.bumptech.glide.load.resource.drawable;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.Resource;
import java.util.List;
/* loaded from: classes.dex */
public class ResourceDrawableDecoder implements ResourceDecoder<Uri, Drawable> {
private final Context a;
public ResourceDrawableDecoder(Context context) {
this.a = context.getApplicationContext();
}
@Override // com.bumptech.glide.load.ResourceDecoder
public boolean a(Uri uri, Options options) {
return uri.getScheme().equals("android.resource");
}
@Override // com.bumptech.glide.load.ResourceDecoder
public Resource<Drawable> a(Uri uri, int i, int i2, Options options) {
int a = a(uri);
String authority = uri.getAuthority();
return NonOwnedDrawableResource.a(DrawableDecoderCompat.a(this.a, authority.equals(this.a.getPackageName()) ? this.a : a(uri, authority), a));
}
private Context a(Uri uri, String str) {
try {
return this.a.createPackageContext(str, 0);
} catch (PackageManager.NameNotFoundException e) {
throw new IllegalArgumentException("Failed to obtain context or unrecognized Uri format for: " + uri, e);
}
}
private int a(Uri uri) {
Integer valueOf;
List<String> pathSegments = uri.getPathSegments();
if (pathSegments.size() == 2) {
String authority = uri.getAuthority();
valueOf = Integer.valueOf(this.a.getResources().getIdentifier(pathSegments.get(1), pathSegments.get(0), authority));
} else {
if (pathSegments.size() == 1) {
try {
valueOf = Integer.valueOf(pathSegments.get(0));
} catch (NumberFormatException unused) {
}
}
valueOf = null;
}
if (valueOf != null) {
if (valueOf.intValue() != 0) {
return valueOf.intValue();
}
throw new IllegalArgumentException("Failed to obtain resource id for: " + uri);
}
throw new IllegalArgumentException("Unrecognized Uri format: " + uri);
}
}

View File

@@ -0,0 +1,19 @@
package com.bumptech.glide.load.resource.drawable;
import android.graphics.drawable.Drawable;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.Resource;
/* loaded from: classes.dex */
public class UnitDrawableDecoder implements ResourceDecoder<Drawable, Drawable> {
@Override // com.bumptech.glide.load.ResourceDecoder
public boolean a(Drawable drawable, Options options) {
return true;
}
@Override // com.bumptech.glide.load.ResourceDecoder
public Resource<Drawable> a(Drawable drawable, int i, int i2, Options options) {
return NonOwnedDrawableResource.a(drawable);
}
}