2021-06-27 20:44:35 +00:00
|
|
|
package com.discord.utilities.images;
|
|
|
|
|
|
|
|
import android.app.ActivityManager;
|
|
|
|
import android.app.Application;
|
|
|
|
import android.content.Context;
|
|
|
|
import c.f.d.d.k;
|
|
|
|
import c.f.d.e.a;
|
|
|
|
import c.f.g.a.a.e;
|
|
|
|
import c.f.j.e.g;
|
|
|
|
import c.f.j.e.h;
|
|
|
|
import c.f.j.e.j;
|
|
|
|
import c.f.j.e.k;
|
|
|
|
import c.f.j.e.l;
|
|
|
|
import c.f.j.r.b;
|
|
|
|
import c.f.m.n.c;
|
|
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
|
|
import com.facebook.cache.disk.DiskCacheConfig;
|
|
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
|
|
import com.facebook.imagepipeline.cache.DefaultBitmapMemoryCacheParamsSupplier;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
|
import java.util.Objects;
|
|
|
|
/* compiled from: MGImagesConfig.kt */
|
|
|
|
public final class MGImagesConfig {
|
|
|
|
private static final String CACHE_DIR = "app_images_cache";
|
|
|
|
private static final String CACHE_DIR_SMALL = "app_images_cache_small";
|
|
|
|
public static final MGImagesConfig INSTANCE = new MGImagesConfig();
|
|
|
|
private static final int MAX_BITMAP_MEM_CACHE_SIZE_RATIO = 3;
|
|
|
|
private static final long MAX_DISK_CACHE_SIZE = 41943040;
|
|
|
|
|
|
|
|
private MGImagesConfig() {
|
|
|
|
}
|
|
|
|
|
|
|
|
private final DefaultBitmapMemoryCacheParamsSupplier getAppBitmapMemoryCacheParamsSupplier(Context context) {
|
|
|
|
Object systemService = context.getSystemService("activity");
|
|
|
|
Objects.requireNonNull(systemService, "null cannot be cast to non-null type android.app.ActivityManager");
|
|
|
|
ActivityManager activityManager = (ActivityManager) systemService;
|
|
|
|
return new MGImagesConfig$getAppBitmapMemoryCacheParamsSupplier$1(activityManager, activityManager);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final DiskCacheConfig newDiskCacheConfig(Context context, String str) {
|
|
|
|
DiskCacheConfig.b bVar = new DiskCacheConfig.b(context, null);
|
|
|
|
bVar.b = new k(context.getCacheDir());
|
|
|
|
bVar.a = str;
|
2021-07-03 23:36:06 +00:00
|
|
|
bVar.f2163c = 41943040;
|
2021-06-27 20:44:35 +00:00
|
|
|
DiskCacheConfig diskCacheConfig = new DiskCacheConfig(bVar);
|
|
|
|
m.checkNotNullExpressionValue(diskCacheConfig, "DiskCacheConfig\n …HE_SIZE)\n .build()");
|
|
|
|
return diskCacheConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void init(Application application) {
|
|
|
|
m.checkNotNullParameter(application, "context");
|
|
|
|
j.a aVar = new j.a(application, null);
|
|
|
|
aVar.f434c = true;
|
|
|
|
aVar.d = newDiskCacheConfig(application, "app_images_cache");
|
|
|
|
aVar.e = newDiskCacheConfig(application, "app_images_cache_small");
|
|
|
|
DefaultBitmapMemoryCacheParamsSupplier appBitmapMemoryCacheParamsSupplier = getAppBitmapMemoryCacheParamsSupplier(application);
|
|
|
|
Objects.requireNonNull(appBitmapMemoryCacheParamsSupplier);
|
|
|
|
aVar.a = appBitmapMemoryCacheParamsSupplier;
|
|
|
|
k.b bVar = aVar.f;
|
|
|
|
bVar.b = true;
|
|
|
|
j.a aVar2 = bVar.a;
|
|
|
|
Objects.requireNonNull(aVar2);
|
|
|
|
j jVar = new j(aVar2, null);
|
|
|
|
b.b();
|
|
|
|
if (c.f.g.a.a.b.b) {
|
|
|
|
a.k(c.f.g.a.a.b.class, "Fresco has already been initialized! `Fresco.initialize(...)` should only be called 1 single time to avoid memory leaks!");
|
|
|
|
} else {
|
|
|
|
c.f.g.a.a.b.b = true;
|
|
|
|
}
|
|
|
|
c.f.j.e.m.a = true;
|
|
|
|
if (!c.f.m.n.a.b()) {
|
|
|
|
b.b();
|
|
|
|
try {
|
|
|
|
Class.forName("com.facebook.imagepipeline.nativecode.NativeCodeInitializer").getMethod("init", Context.class).invoke(null, application);
|
|
|
|
} catch (ClassNotFoundException unused) {
|
|
|
|
c.f.m.n.a.a(new c());
|
|
|
|
} catch (IllegalAccessException unused2) {
|
|
|
|
c.f.m.n.a.a(new c());
|
|
|
|
} catch (InvocationTargetException unused3) {
|
|
|
|
c.f.m.n.a.a(new c());
|
|
|
|
} catch (NoSuchMethodException unused4) {
|
|
|
|
c.f.m.n.a.a(new c());
|
|
|
|
} catch (Throwable th) {
|
|
|
|
b.b();
|
|
|
|
throw th;
|
|
|
|
}
|
|
|
|
b.b();
|
|
|
|
}
|
|
|
|
Context applicationContext = application.getApplicationContext();
|
|
|
|
l.j(jVar);
|
|
|
|
b.b();
|
|
|
|
e eVar = new e(applicationContext);
|
|
|
|
c.f.g.a.a.b.a = eVar;
|
|
|
|
SimpleDraweeView.initialize(eVar);
|
|
|
|
b.b();
|
|
|
|
b.b();
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void onTrimMemory(int i) {
|
|
|
|
if (i == 5 || i == 10 || i == 15 || i == 40 || i == 60 || i == 80) {
|
|
|
|
l lVar = l.a;
|
|
|
|
AnimatableValueParser.y(lVar, "ImagePipelineFactory was not initialized!");
|
|
|
|
if (lVar.l == null) {
|
|
|
|
lVar.l = lVar.a();
|
|
|
|
}
|
|
|
|
h hVar = lVar.l;
|
|
|
|
g gVar = new g(hVar);
|
|
|
|
hVar.e.d(gVar);
|
|
|
|
hVar.f.d(gVar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|