- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
102 lines
4.1 KiB
Java
102 lines
4.1 KiB
Java
package com.vungle.ads.internal.util;
|
|
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.BitmapFactory;
|
|
import android.util.LruCache;
|
|
import com.vungle.ads.internal.util.Logger;
|
|
import java.util.concurrent.Executor;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.text.StringsKt__StringsJVMKt;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public final class ImageLoader {
|
|
private static final String FILE_SCHEME = "file://";
|
|
private Executor ioExecutor;
|
|
private final LruCache<String, Bitmap> lruCache = new LruCache<String, Bitmap>(((int) (Runtime.getRuntime().maxMemory() / 1024)) / 8) { // from class: com.vungle.ads.internal.util.ImageLoader.1
|
|
@Override // android.util.LruCache
|
|
public int sizeOf(String str, Bitmap value) {
|
|
Intrinsics.checkNotNullParameter(value, "value");
|
|
return value.getByteCount() / 1024;
|
|
}
|
|
};
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final String TAG = ImageLoader.class.getSimpleName();
|
|
private static final ImageLoader instance = new ImageLoader();
|
|
|
|
public final void init(Executor ioExecutor) {
|
|
Intrinsics.checkNotNullParameter(ioExecutor, "ioExecutor");
|
|
this.ioExecutor = ioExecutor;
|
|
}
|
|
|
|
private ImageLoader() {
|
|
}
|
|
|
|
public final void displayImage(final String str, final Function1 onImageLoaded) {
|
|
Intrinsics.checkNotNullParameter(onImageLoaded, "onImageLoaded");
|
|
if (this.ioExecutor == null) {
|
|
Logger.Companion companion = Logger.Companion;
|
|
String TAG2 = TAG;
|
|
Intrinsics.checkNotNullExpressionValue(TAG2, "TAG");
|
|
companion.w(TAG2, "ImageLoader not initialized.");
|
|
return;
|
|
}
|
|
if (str == null || str.length() == 0) {
|
|
Logger.Companion companion2 = Logger.Companion;
|
|
String TAG3 = TAG;
|
|
Intrinsics.checkNotNullExpressionValue(TAG3, "TAG");
|
|
companion2.w(TAG3, "the uri is required.");
|
|
return;
|
|
}
|
|
Executor executor = this.ioExecutor;
|
|
if (executor != null) {
|
|
executor.execute(new Runnable() { // from class: com.vungle.ads.internal.util.ImageLoader$$ExternalSyntheticLambda0
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
ImageLoader.m3991displayImage$lambda0(str, this, onImageLoaded);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* renamed from: displayImage$lambda-0, reason: not valid java name */
|
|
public static final void m3991displayImage$lambda0(String str, ImageLoader this$0, Function1 onImageLoaded) {
|
|
Intrinsics.checkNotNullParameter(this$0, "this$0");
|
|
Intrinsics.checkNotNullParameter(onImageLoaded, "$onImageLoaded");
|
|
if (StringsKt__StringsJVMKt.startsWith$default(str, "file://", false, 2, null)) {
|
|
Bitmap bitmap = this$0.lruCache.get(str);
|
|
if (bitmap != null && !bitmap.isRecycled()) {
|
|
onImageLoaded.invoke(bitmap);
|
|
return;
|
|
}
|
|
String substring = str.substring(7);
|
|
Intrinsics.checkNotNullExpressionValue(substring, "this as java.lang.String).substring(startIndex)");
|
|
Bitmap decodeFile = BitmapFactory.decodeFile(substring);
|
|
if (decodeFile != null) {
|
|
this$0.lruCache.put(str, decodeFile);
|
|
onImageLoaded.invoke(decodeFile);
|
|
} else {
|
|
Logger.Companion companion = Logger.Companion;
|
|
String TAG2 = TAG;
|
|
Intrinsics.checkNotNullExpressionValue(TAG2, "TAG");
|
|
companion.w(TAG2, "decode bitmap failed.");
|
|
}
|
|
}
|
|
}
|
|
|
|
public static final class Companion {
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
private Companion() {
|
|
}
|
|
|
|
public final ImageLoader getInstance() {
|
|
return ImageLoader.instance;
|
|
}
|
|
}
|
|
}
|