随身WiFi小助手 v1.1.1版本的 MD5 值为:b7707ff0ac20cdf6109b08a72f633bc9
以下内容为反编译后的 Drawables.java 源代码,内容仅作参考
package com.stardust.autojs.core.ui.inflater.util;
import a.e;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Looper;
import android.util.Base64;
import android.view.View;
import android.widget.ImageView;
import androidx.core.app.NotificationCompat;
import com.bumptech.glide.i;
import com.stardust.autojs.core.intent.ScriptIntents;
import com.stardust.autojs.core.ui.inflater.ImageLoader;
import com.stardust.pio.PFiles;
import d4.f;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import k.b;
import l4.j;
import m4.k0;
import m4.t0;
import org.mozilla.javascript.ES6Iterator;
import y0.d;
public class Drawables {
public static final Companion Companion = new Companion(null);
private static final Pattern DATA_PATTERN = Pattern.compile("data:(\\w+/\\w+);base64,(.+)");
private static ImageLoader defaultImageLoader = new DefaultImageLoader();
private ImageLoader imageLoader = defaultImageLoader;
private String workingDirectory;
public static final class Companion {
private Companion() {
}
public Companion(f fVar) {
this();
}
public final ImageLoader getDefaultImageLoader() {
return Drawables.defaultImageLoader;
}
public final Bitmap loadBase64Data(String str) {
b.n(str, "data");
Matcher matcher = Drawables.DATA_PATTERN.matcher(str);
if (matcher.matches() && matcher.groupCount() == 2) {
str = matcher.group(2);
b.m(str, "{\n matcher.group(2)\n }");
}
byte[] decode = Base64.decode(str, 0);
Bitmap decodeByteArray = BitmapFactory.decodeByteArray(decode, 0, decode.length);
b.m(decodeByteArray, "decodeByteArray(bytes, 0, bytes.size)");
return decodeByteArray;
}
public final void setDefaultImageLoader(ImageLoader imageLoader) {
b.n(imageLoader, "<set-?>");
Drawables.defaultImageLoader = imageLoader;
}
}
private final void loadDataInto(ImageView imageView, String str) {
imageView.setImageBitmap(Companion.loadBase64Data(str));
}
public Drawable decodeImage(Resources resources, String str) {
b.n(resources, "resources");
b.n(str, ScriptIntents.EXTRA_KEY_PATH);
String str2 = this.workingDirectory;
if (str2 != null) {
str = PFiles.join(str2, str);
}
return new BitmapDrawable(resources, BitmapFactory.decodeFile(str));
}
public final ImageLoader getImageLoader() {
return this.imageLoader;
}
public final String getWorkingDirectory() {
return this.workingDirectory;
}
public final Drawable loadAttrResources(Context context, String str) {
b.n(context, "context");
b.n(str, ES6Iterator.VALUE_PROPERTY);
Resources resources = context.getResources();
String substring = str.substring(1);
b.m(substring, "this as java.lang.String).substring(startIndex)");
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(new int[]{resources.getIdentifier(substring, "attr", context.getPackageName())});
b.m(obtainStyledAttributes, "context.obtainStyledAttributes(attr)");
Drawable drawable = obtainStyledAttributes.getDrawable(0);
obtainStyledAttributes.recycle();
return drawable;
}
public final Drawable loadDrawableResources(Context context, String str) {
b.n(context, "context");
b.n(str, ES6Iterator.VALUE_PROPERTY);
int identifier = context.getResources().getIdentifier(str, "drawable", context.getPackageName());
if (identifier != 0) {
Drawable drawable = context.getResources().getDrawable(identifier);
b.m(drawable, "context.resources.getDrawable(resId)");
return drawable;
}
throw new Resources.NotFoundException(e.b("drawable not found: ", str));
}
public final void loadInto(ImageView imageView, Uri uri) {
b.n(imageView, "view");
b.n(uri, NotificationCompat.MessagingStyle.Message.KEY_DATA_URI);
this.imageLoader.loadInto(imageView, uri);
}
public final void loadIntoBackground(View view, Uri uri) {
b.n(view, "view");
b.n(uri, NotificationCompat.MessagingStyle.Message.KEY_DATA_URI);
this.imageLoader.loadIntoBackground(view, uri);
}
public final Drawable parse(Context context, String str) {
b.n(context, "context");
b.n(str, ES6Iterator.VALUE_PROPERTY);
context.getResources();
if (j.r(str, "@color/") || j.r(str, "@android:color/") || j.r(str, "#")) {
return new ColorDrawable(Colors.parse(context, str));
}
if (j.r(str, "?")) {
return loadAttrResources(context, str);
}
if (j.r(str, "file://")) {
Resources resources = context.getResources();
b.m(resources, "context.resources");
String substring = str.substring(7);
b.m(substring, "this as java.lang.String).substring(startIndex)");
return decodeImage(resources, substring);
}
return loadDrawableResources(context, str);
}
public final Drawable parse(View view, String str) {
b.n(view, "view");
b.n(str, "name");
Context context = view.getContext();
b.m(context, "view.context");
return parse(context, str);
}
public final void setImageLoader(ImageLoader imageLoader) {
b.n(imageLoader, "<set-?>");
this.imageLoader = imageLoader;
}
public final void setWorkingDirectory(String str) {
this.workingDirectory = str;
}
public final <V extends ImageView> void setupWithImage(V v7, String str) {
b.n(v7, "view");
b.n(str, ES6Iterator.VALUE_PROPERTY);
if (j.r(str, "http://") || j.r(str, "https://")) {
Uri parse = Uri.parse(str);
b.m(parse, "parse(value)");
loadInto(v7, parse);
} else if (j.r(str, "data:")) {
loadDataInto(v7, str);
} else {
v7.setImageDrawable(parse(v7, str));
}
}
public final void setupWithViewBackground(View view, String str) {
b.n(view, "view");
b.n(str, ES6Iterator.VALUE_PROPERTY);
if (!j.r(str, "http://") && !j.r(str, "https://")) {
view.setBackground(parse(view, str));
return;
}
Uri parse = Uri.parse(str);
b.m(parse, "parse(value)");
loadIntoBackground(view, parse);
}
public static final class DefaultImageLoader implements ImageLoader {
@Override
public void clearDiskCache(Context context) {
b.n(context, "context");
if (b.h(Looper.myLooper(), Looper.getMainLooper())) {
b.H(t0.f4414e, k0.f4383c, 0, new Drawables$DefaultImageLoader$clearDiskCache$1(context, null), 2);
} else {
com.bumptech.glide.b.d(context).b();
}
}
@Override
public void clearMemory(Context context) {
b.n(context, "context");
com.bumptech.glide.b.d(context).c();
}
@Override
public Drawable load(View view, Uri uri) {
b.n(view, "view");
b.n(uri, NotificationCompat.MessagingStyle.Message.KEY_DATA_URI);
throw new UnsupportedOperationException();
}
@Override
public void load(final View view, Uri uri, final ImageLoader.BitmapCallback bitmapCallback) {
b.n(view, "view");
b.n(uri, NotificationCompat.MessagingStyle.Message.KEY_DATA_URI);
b.n(bitmapCallback, "bitmapCallback");
i<Bitmap> w4 = com.bumptech.glide.b.g(view.getContext().getApplicationContext()).a().w(uri);
w4.u(new d<View, Bitmap>(view) {
@Override
public void onLoadFailed(Drawable drawable) {
}
@Override
public void onResourceCleared(Drawable drawable) {
}
public void onResourceReady(Bitmap bitmap, z0.b<? super Bitmap> bVar) {
b.n(bitmap, "resource");
bitmapCallback.onLoaded(bitmap);
}
@Override
public void onResourceReady(Object obj, z0.b bVar) {
onResourceReady((Bitmap) obj, (z0.b<? super Bitmap>) bVar);
}
}, w4);
}
@Override
public void loadInto(ImageView imageView, Uri uri) {
b.n(imageView, "imageView");
b.n(uri, NotificationCompat.MessagingStyle.Message.KEY_DATA_URI);
com.bumptech.glide.b.g(imageView.getContext().getApplicationContext()).d(uri).v(imageView);
}
@Override
public void loadIntoBackground(final View view, Uri uri) {
b.n(view, "view");
b.n(uri, NotificationCompat.MessagingStyle.Message.KEY_DATA_URI);
i<Drawable> d8 = com.bumptech.glide.b.g(view.getContext().getApplicationContext()).d(uri);
d8.u(new d<View, Drawable>(view) {
public final View $view;
{
super(view);
this.$view = view;
}
@Override
public void onLoadFailed(Drawable drawable) {
}
@Override
public void onResourceCleared(Drawable drawable) {
}
public void onResourceReady(Drawable drawable, z0.b<? super Drawable> bVar) {
b.n(drawable, "resource");
this.$view.setBackground(drawable);
}
@Override
public void onResourceReady(Object obj, z0.b bVar) {
onResourceReady((Drawable) obj, (z0.b<? super Drawable>) bVar);
}
}, d8);
}
@Override
public void load(final View view, Uri uri, final ImageLoader.DrawableCallback drawableCallback) {
b.n(view, "view");
b.n(uri, NotificationCompat.MessagingStyle.Message.KEY_DATA_URI);
b.n(drawableCallback, "drawableCallback");
i<Drawable> d8 = com.bumptech.glide.b.g(view.getContext().getApplicationContext()).d(uri);
d8.u(new d<View, Drawable>(view) {
@Override
public void onLoadFailed(Drawable drawable) {
}
@Override
public void onResourceCleared(Drawable drawable) {
}
public void onResourceReady(Drawable drawable, z0.b<? super Drawable> bVar) {
b.n(drawable, "resource");
drawableCallback.onLoaded(drawable);
}
@Override
public void onResourceReady(Object obj, z0.b bVar) {
onResourceReady((Drawable) obj, (z0.b<? super Drawable>) bVar);
}
}, d8);
}
}
}