正在查看: 万能钥匙 v1.1.23 应用的 ImageLoader.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 万能钥匙 v1.1.23 应用的 ImageLoader.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.finogeeks.lib.applet.modules.request;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.util.LruCache;
import android.webkit.URLUtil;
import com.facebook.fbreact.specs.NativeImageLoaderAndroidSpec;
import com.finogeeks.lib.applet.client.FinAppClient;
import com.finogeeks.lib.applet.client.FinAppConfig;
import com.finogeeks.lib.applet.client.FinAppInfo;
import com.finogeeks.lib.applet.f.c.a0;
import com.finogeeks.lib.applet.f.c.e;
import com.finogeeks.lib.applet.f.c.f;
import com.finogeeks.lib.applet.f.c.x;
import com.finogeeks.lib.applet.main.FinAppEnv;
import com.finogeeks.lib.applet.modules.callback.FinSimpleCallback;
import com.finogeeks.lib.applet.modules.ext.r;
import com.finogeeks.lib.applet.modules.ext.s;
import com.finogeeks.lib.applet.modules.log.FLog;
import com.finogeeks.lib.applet.modules.log.FLogCommonTag;
import com.finogeeks.lib.applet.rest.request.FinRequestManager;
import com.finogeeks.lib.applet.rest.request.a;
import com.finogeeks.lib.applet.utils.RefererUtil;
import com.finogeeks.lib.applet.utils.j;
import hh0.l;
import java.io.File;
import java.io.IOException;
import kotlin.Metadata;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.g0;
import kotlin.jvm.internal.n;
import kotlin.jvm.internal.y;
import lg0.e0;
import lg0.h;
import lg0.i;
import tj0.t;
import tj0.u;
@Metadata(d1 = {"\u0000n\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u000e\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u000b\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\b\n\u0002\b\u0005\u0018\u0000 E2\u00020\u0001:\u0001EB\u0011\b\u0002\u0012\u0006\u0010\u0003\u001a\u00020\u0002¢\u0006\u0004\b\u0004\u0010\u0005J\u0017\u0010\b\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\u0006H\u0002¢\u0006\u0004\b\b\u0010\tJ\u0011\u0010\u000b\u001a\u0004\u0018\u00010\nH\u0002¢\u0006\u0004\b\u000b\u0010\fJ3\u0010\u0014\u001a\u00020\u00132\b\u0010\u0007\u001a\u0004\u0018\u00010\u00062\u0006\u0010\u000e\u001a\u00020\r2\b\u0010\u0010\u001a\u0004\u0018\u00010\u000f2\u0006\u0010\u0012\u001a\u00020\u0011H\u0002¢\u0006\u0004\b\u0014\u0010\u0015J3\u0010\u0017\u001a\u00020\u00132\b\u0010\u0007\u001a\u0004\u0018\u00010\u00062\u0006\u0010\u000e\u001a\u00020\r2\b\u0010\u0010\u001a\u0004\u0018\u00010\u000f2\u0006\u0010\u0012\u001a\u00020\u0016H\u0002¢\u0006\u0004\b\u0017\u0010\u0018J1\u0010\u0019\u001a\u00020\u00132\u0006\u0010\u0007\u001a\u00020\u00062\u0006\u0010\u000e\u001a\u00020\r2\b\u0010\u0010\u001a\u0004\u0018\u00010\u000f2\u0006\u0010\u0012\u001a\u00020\u0011H\u0002¢\u0006\u0004\b\u0019\u0010\u0015J\u001f\u0010\u001a\u001a\u00020\u00132\u0006\u0010\u0007\u001a\u00020\u00062\u0006\u0010\u0012\u001a\u00020\u0011H\u0003¢\u0006\u0004\b\u001a\u0010\u001bJ\u000f\u0010\u001c\u001a\u00020\u0013H\u0002¢\u0006\u0004\b\u001c\u0010\u001dJ\u0017\u0010\u001e\u001a\u00020\r2\u0006\u0010\u0007\u001a\u00020\u0006H\u0002¢\u0006\u0004\b\u001e\u0010\u001fJ\u0017\u0010 \u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\u0006H\u0002¢\u0006\u0004\b \u0010\tJ\u001f\u0010!\u001a\u00020\u00132\b\u0010\u0007\u001a\u0004\u0018\u00010\u00062\u0006\u0010\u0012\u001a\u00020\u0011¢\u0006\u0004\b!\u0010\u001bJ)\u0010\u000e\u001a\u00020\u00132\b\u0010\u0007\u001a\u0004\u0018\u00010\u00062\b\u0010\u0010\u001a\u0004\u0018\u00010\u000f2\u0006\u0010\u0012\u001a\u00020\u0011¢\u0006\u0004\b\u000e\u0010\"J\u001f\u0010!\u001a\u00020\u00132\b\u0010\u0007\u001a\u0004\u0018\u00010\u00062\u0006\u0010\u0012\u001a\u00020\u0016¢\u0006\u0004\b!\u0010#J)\u0010\u000e\u001a\u00020\u00132\b\u0010\u0007\u001a\u0004\u0018\u00010\u00062\b\u0010\u0010\u001a\u0004\u0018\u00010\u000f2\u0006\u0010\u0012\u001a\u00020\u0016¢\u0006\u0004\b\u000e\u0010$J\u0015\u0010&\u001a\u00020%2\u0006\u0010\u0007\u001a\u00020\u0006¢\u0006\u0004\b&\u0010'J\u0015\u0010(\u001a\u00020\u00132\u0006\u0010\u0007\u001a\u00020\u0006¢\u0006\u0004\b(\u0010)J\u001d\u0010\u0019\u001a\u00020\u00132\f\u0010+\u001a\b\u0012\u0004\u0012\u00020%0*H\u0002¢\u0006\u0004\b\u0019\u0010,R#\u0010\u0003\u001a\n -*\u0004\u0018\u00010\u00020\u00028BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b.\u0010/\u001a\u0004\b0\u00101R#\u00105\u001a\n -*\u0004\u0018\u00010\u00060\u00068BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b2\u0010/\u001a\u0004\b3\u00104R'\u0010;\u001a\u000e\u0012\u0004\u0012\u00020\u0006\u0012\u0004\u0012\u000207068BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b8\u0010/\u001a\u0004\b9\u0010:R#\u0010@\u001a\n -*\u0004\u0018\u00010<0<8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b=\u0010/\u001a\u0004\b>\u0010?R\u0014\u0010D\u001a\u00020A8BX\u0082\u0004¢\u0006\u0006\u001a\u0004\bB\u0010C¨\u0006F"}, d2 = {"Lcom/finogeeks/lib/applet/modules/imageloader/ImageLoader;", "", "Landroid/content/Context;", "context", "<init>", "(Landroid/content/Context;)V", "", "url", "generateCacheKey", "(Ljava/lang/String;)Ljava/lang/String;", "Lcom/finogeeks/lib/applet/client/FinAppConfig;", "getFinAppConfig", "()Lcom/finogeeks/lib/applet/client/FinAppConfig;", "", "loadWithReferer", "Lcom/finogeeks/lib/applet/client/FinAppInfo;", "finAppInfo", "Lcom/finogeeks/lib/applet/modules/imageloader/FileCallback;", "callback", "Llg0/e0;", "loadFile", "(Ljava/lang/String;ZLcom/finogeeks/lib/applet/client/FinAppInfo;Lcom/finogeeks/lib/applet/modules/imageloader/FileCallback;)V", "Lcom/finogeeks/lib/applet/modules/imageloader/BitmapCallback;", "loadBitmap", "(Ljava/lang/String;ZLcom/finogeeks/lib/applet/client/FinAppInfo;Lcom/finogeeks/lib/applet/modules/imageloader/BitmapCallback;)V", FLogCommonTag.DOWNLOAD, "base64ToFile", "(Ljava/lang/String;Lcom/finogeeks/lib/applet/modules/imageloader/FileCallback;)V", "checkDiskCacheDir", "()V", "isDiskCached", "(Ljava/lang/String;)Z", "getDiskCacheFileName", "load", "(Ljava/lang/String;Lcom/finogeeks/lib/applet/client/FinAppInfo;Lcom/finogeeks/lib/applet/modules/imageloader/FileCallback;)V", "(Ljava/lang/String;Lcom/finogeeks/lib/applet/modules/imageloader/BitmapCallback;)V", "(Ljava/lang/String;Lcom/finogeeks/lib/applet/client/FinAppInfo;Lcom/finogeeks/lib/applet/modules/imageloader/BitmapCallback;)V", "Ljava/io/File;", "getDiskCacheFile", "(Ljava/lang/String;)Ljava/io/File;", "removeMemoryCache", "(Ljava/lang/String;)V", "Lcom/finogeeks/lib/applet/rest/request/FinRequest;", "finRequest", "(Lcom/finogeeks/lib/applet/rest/request/FinRequest;)V", "kotlin.jvm.PlatformType", "context$delegate", "Llg0/h;", "getContext", "()Landroid/content/Context;", "diskCacheDirPath$delegate", "getDiskCacheDirPath", "()Ljava/lang/String;", "diskCacheDirPath", "Landroid/util/LruCache;", "Landroid/graphics/Bitmap;", "memoryCache$delegate", "getMemoryCache", "()Landroid/util/LruCache;", "memoryCache", "Lcom/finogeeks/lib/applet/externallib/okhttp3/OkHttpClient;", "client$delegate", "getClient", "()Lcom/finogeeks/lib/applet/externallib/okhttp3/OkHttpClient;", "client", "", "getMemoryCacheMaxSize", "()I", "memoryCacheMaxSize", "Companion", "finapplet_release"}, k = 1, mv = {1, 4, 0})
public final class ImageLoader {
private static volatile ImageLoader INSTANCE = null;
private static final String TAG = "ImageLoader";
private final h client;
private final h context;
private final h diskCacheDirPath;
private final h memoryCache;
static final l[] $$delegatedProperties = {g0.j(new y(g0.b(ImageLoader.class), "context", "getContext()Landroid/content/Context;")), g0.j(new y(g0.b(ImageLoader.class), "diskCacheDirPath", "getDiskCacheDirPath()Ljava/lang/String;")), g0.j(new y(g0.b(ImageLoader.class), "memoryCache", "getMemoryCache()Landroid/util/LruCache;")), g0.j(new y(g0.b(ImageLoader.class), "client", "getClient()Lcom/finogeeks/lib/applet/externallib/okhttp3/OkHttpClient;"))};
public static final Companion INSTANCE = new Companion(null);
private static final Object lock = new Object();
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u000e\u0010\b\u001a\u00020\u00042\u0006\u0010\t\u001a\u00020\nR\u000e\u0010\u0003\u001a\u00020\u0004X\u0082.¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\u0001X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u000b"}, d2 = {"Lcom/finogeeks/lib/applet/modules/imageloader/ImageLoader$Companion;", "", "()V", "INSTANCE", "Lcom/finogeeks/lib/applet/modules/imageloader/ImageLoader;", "TAG", "", "lock", "get", "context", "Landroid/content/Context;", "finapplet_release"}, k = 1, mv = {1, 1, 16})
public static final class Companion {
private Companion() {
}
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static final ImageLoader access$getINSTANCE$li(Companion companion) {
return ImageLoader.INSTANCE;
}
public final ImageLoader get(Context context) {
n.j(context, "context");
if (access$getINSTANCE$li(this) == null) {
synchronized (ImageLoader.lock) {
try {
if (access$getINSTANCE$li(ImageLoader.INSTANCE) == null) {
ImageLoader.INSTANCE = new ImageLoader(context, null);
}
e0 e0Var = e0.a;
} catch (Throwable th2) {
throw th2;
}
}
}
ImageLoader imageLoader = ImageLoader.INSTANCE;
if (imageLoader == null) {
n.z("INSTANCE");
}
return imageLoader;
}
}
private ImageLoader(Context context) {
this.context = i.a(new ImageLoader$context$2(context));
this.diskCacheDirPath = i.a(new ImageLoader$diskCacheDirPath$2(this));
this.memoryCache = i.a(new ImageLoader$memoryCache$2(this));
this.client = i.a(new ImageLoader$client$2(this));
}
public ImageLoader(Context context, DefaultConstructorMarker defaultConstructorMarker) {
this(context);
}
@SuppressLint({"StaticFieldLeak"})
public final void base64ToFile(final String url, final FileCallback callback) {
new AsyncTask<Object, Object, File>() {
@Override
public File doInBackground(Object... params) {
String diskCacheDirPath;
String diskCacheFileName;
n.j(params, "params");
ImageLoader.this.checkDiskCacheDir();
String str = url;
StringBuilder sb = new StringBuilder();
diskCacheDirPath = ImageLoader.this.getDiskCacheDirPath();
sb.append(diskCacheDirPath);
diskCacheFileName = ImageLoader.this.getDiskCacheFileName(url);
sb.append(diskCacheFileName);
return j.a(str, sb.toString());
}
@Override
public void onPostExecute(File file) {
if (file != null) {
callback.onLoadSuccess(file);
} else {
FLog.w$default(NativeImageLoaderAndroidSpec.NAME, "base64ToFile file is null", null, 4, null);
callback.onLoadFailure();
}
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Object[0]);
}
public final void checkDiskCacheDir() {
File file = new File(getDiskCacheDirPath());
if (file.exists()) {
return;
}
try {
file.mkdirs();
} catch (Exception e) {
e.printStackTrace();
}
}
public final void download(a<File> aVar) {
final String b = aVar.b();
FLog.d$default("ImageLoader", "download url:" + b, null, 4, null);
final ImageLoader$download$3 imageLoader$download$3 = new ImageLoader$download$3(aVar);
final ImageLoader$download$4 imageLoader$download$4 = new ImageLoader$download$4(this, aVar);
getClient().a(aVar.c()).a(new f() {
@Override
public void onFailure(e eVar, IOException iOException) {
n.j(eVar, "call");
n.j(iOException, "e");
FLog.w(NativeImageLoaderAndroidSpec.NAME, "download onFailure", iOException);
imageLoader$download$4.invoke(-1, s.g(iOException.getLocalizedMessage()));
}
@Override
public void onResponse(com.finogeeks.lib.applet.f.c.e r11, com.finogeeks.lib.applet.f.c.c0 r12) {
throw new UnsupportedOperationException("Method not decompiled: com.finogeeks.lib.applet.modules.request.ImageLoader$download$5.onResponse(com.finogeeks.lib.applet.f.c.e, com.finogeeks.lib.applet.f.c.c0):void");
}
});
}
public final void download(String url, boolean loadWithReferer, FinAppInfo finAppInfo, final FileCallback callback) {
try {
a0.a b = new a0.a().b(url);
if (loadWithReferer) {
if (finAppInfo != null) {
String a = RefererUtil.a(finAppInfo);
n.e(b, "builder");
r.a(b, "Referer", a);
}
if (u.Q(url, "wx_fmt=jpeg", false, 2, (Object) null)) {
b.a("Referer", "https://servicewechat.com");
}
}
a0 a2 = b.a();
n.e(a2, FLogCommonTag.REQUEST);
a<?> aVar = new a<>(url, a2, new FinSimpleCallback<File>() {
@Override
public void onError(int code, String error) {
FileCallback.this.onLoadFailure();
}
@Override
public void onSuccess(File result) {
n.j(result, "result");
FileCallback.this.onLoadSuccess(result);
}
});
FinRequestManager.c.a(aVar, new ImageLoader$download$2(this, aVar));
} catch (Exception e) {
FLog.w("ImageLoader", "download error", e);
callback.onLoadFailure();
}
}
public final String generateCacheKey(String url) {
try {
if (!URLUtil.isNetworkUrl(url) && !j.a(url)) {
FLog.d$default("ImageLoader", "need generateCacheKey:" + url, null, 4, null);
File file = new File(url);
if (file.exists()) {
return url + file.lastModified();
}
}
} catch (Exception e) {
FLog.e("ImageLoader", "generateCacheKey error", e);
}
return url;
}
private final x getClient() {
h hVar = this.client;
l lVar = $$delegatedProperties[3];
return (x) hVar.getValue();
}
public final Context getContext() {
h hVar = this.context;
l lVar = $$delegatedProperties[0];
return (Context) hVar.getValue();
}
public final String getDiskCacheDirPath() {
h hVar = this.diskCacheDirPath;
l lVar = $$delegatedProperties[1];
return (String) hVar.getValue();
}
public final String getDiskCacheFileName(String url) {
String a = com.finogeeks.lib.applet.utils.a0.a(url);
n.e(a, "MD5Utils.getMD5String(url)");
return a;
}
public final FinAppConfig getFinAppConfig() {
FinAppEnv finAppEnv = FinAppEnv.INSTANCE;
return finAppEnv.isAppletProcess() ? finAppEnv.getFinAppConfig() : FinAppClient.INSTANCE.getFinAppConfig();
}
public final LruCache<String, Bitmap> getMemoryCache() {
h hVar = this.memoryCache;
l lVar = $$delegatedProperties[2];
return (LruCache) hVar.getValue();
}
public final int getMemoryCacheMaxSize() {
return ((int) Runtime.getRuntime().maxMemory()) / 8;
}
private final boolean isDiskCached(String url) {
return getDiskCacheFile(url).exists();
}
private final void loadBitmap(String url, boolean loadWithReferer, FinAppInfo finAppInfo, BitmapCallback callback) {
if (url == null || t.y(url)) {
callback.onLoadFailure();
return;
}
ImageLoader$loadBitmap$1 imageLoader$loadBitmap$1 = new ImageLoader$loadBitmap$1(this);
Bitmap invoke = imageLoader$loadBitmap$1.invoke(url);
if (invoke != null) {
callback.onLoadSuccess(invoke);
return;
}
ImageLoader$loadBitmap$2 imageLoader$loadBitmap$2 = new ImageLoader$loadBitmap$2(this, imageLoader$loadBitmap$1, url, callback);
if (URLUtil.isNetworkUrl(url)) {
imageLoader$loadBitmap$2.invoke(getDiskCacheDirPath() + getDiskCacheFileName(url), false, (ah0.a<e0>) new ImageLoader$loadBitmap$3(this, url, loadWithReferer, finAppInfo, imageLoader$loadBitmap$2, callback));
return;
}
if (!j.a(url)) {
imageLoader$loadBitmap$2.invoke(url, false, (ah0.a<e0>) new ImageLoader$loadBitmap$5(callback));
return;
}
imageLoader$loadBitmap$2.invoke(getDiskCacheDirPath() + getDiskCacheFileName(url), false, (ah0.a<e0>) new ImageLoader$loadBitmap$4(this, url, imageLoader$loadBitmap$2, callback));
}
private final void loadFile(String url, boolean loadWithReferer, FinAppInfo finAppInfo, FileCallback callback) {
if (url == null || t.y(url)) {
callback.onLoadFailure();
return;
}
ImageLoader$loadFile$1 imageLoader$loadFile$1 = new ImageLoader$loadFile$1(callback);
if (URLUtil.isNetworkUrl(url)) {
imageLoader$loadFile$1.invoke(getDiskCacheDirPath() + getDiskCacheFileName(url), (ah0.a<e0>) new ImageLoader$loadFile$2(this, url, loadWithReferer, finAppInfo, callback));
return;
}
if (!j.a(url)) {
imageLoader$loadFile$1.invoke(url, (ah0.a<e0>) new ImageLoader$loadFile$4(callback));
return;
}
imageLoader$loadFile$1.invoke(getDiskCacheDirPath() + getDiskCacheFileName(url), (ah0.a<e0>) new ImageLoader$loadFile$3(this, url, callback));
}
public final File getDiskCacheFile(String url) {
n.j(url, "url");
return new File(getDiskCacheDirPath() + com.finogeeks.lib.applet.utils.a0.a(url));
}
public final void load(String url, BitmapCallback callback) {
n.j(callback, "callback");
loadBitmap(url, false, null, callback);
}
public final void load(String url, FileCallback callback) {
n.j(callback, "callback");
loadFile(url, false, null, callback);
}
public final void loadWithReferer(String url, FinAppInfo finAppInfo, BitmapCallback callback) {
n.j(callback, "callback");
loadBitmap(url, true, finAppInfo, callback);
}
public final void loadWithReferer(String url, FinAppInfo finAppInfo, FileCallback callback) {
n.j(callback, "callback");
loadFile(url, true, finAppInfo, callback);
}
public final void removeMemoryCache(String url) {
n.j(url, "url");
getMemoryCache().remove(generateCacheKey(url));
}
}