- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
275 lines
11 KiB
Java
275 lines
11 KiB
Java
package com.mbridge.msdk.foundation.same.c;
|
|
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.BitmapFactory;
|
|
import android.os.Handler;
|
|
import android.os.Looper;
|
|
import android.text.TextUtils;
|
|
import com.mbridge.msdk.MBridgeConstans;
|
|
import com.mbridge.msdk.foundation.download.DownloadError;
|
|
import com.mbridge.msdk.foundation.download.DownloadMessage;
|
|
import com.mbridge.msdk.foundation.download.DownloadPriority;
|
|
import com.mbridge.msdk.foundation.download.DownloadResourceType;
|
|
import com.mbridge.msdk.foundation.download.MBDownloadManager;
|
|
import com.mbridge.msdk.foundation.download.OnDownloadStateListener;
|
|
import com.mbridge.msdk.foundation.download.core.DownloadRequest;
|
|
import com.mbridge.msdk.foundation.tools.ad;
|
|
import com.mbridge.msdk.foundation.tools.af;
|
|
import com.mbridge.msdk.playercommon.exoplayer2.source.chunk.ChunkedTrackBlacklistUtil;
|
|
import java.io.File;
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public final class d {
|
|
private final ThreadPoolExecutor a;
|
|
private final Handler b;
|
|
private final String c;
|
|
|
|
public static final class a {
|
|
private static final d a = new d();
|
|
}
|
|
|
|
private d() {
|
|
this.b = new Handler(Looper.getMainLooper());
|
|
this.c = com.mbridge.msdk.foundation.same.b.e.a(com.mbridge.msdk.foundation.same.b.c.MBRIDGE_700_IMG) + File.separator;
|
|
this.a = f.a();
|
|
}
|
|
|
|
public final Bitmap a(String str) {
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.a("CommonImageLoaderRefactor", "getImageBitmapByUrl imageUrl = " + str);
|
|
}
|
|
if (TextUtils.isEmpty(str)) {
|
|
return null;
|
|
}
|
|
String str2 = this.c + ad.c(str);
|
|
File file = new File(str2);
|
|
if (file.isFile() && file.exists()) {
|
|
try {
|
|
return d(str2);
|
|
} catch (Exception e) {
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.b("CommonImageLoaderRefactor", "getImageBitmapByUrl error", e);
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static Bitmap d(String str) {
|
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
|
options.inJustDecodeBounds = true;
|
|
BitmapFactory.decodeFile(str, options);
|
|
options.inJustDecodeBounds = false;
|
|
options.inPurgeable = true;
|
|
options.inInputShareable = true;
|
|
options.inDither = true;
|
|
return BitmapFactory.decodeFile(str, options);
|
|
}
|
|
|
|
public final boolean b(String str) {
|
|
File file;
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.a("CommonImageLoaderRefactor", "isImageFileExists imageUrl = " + str);
|
|
}
|
|
if (TextUtils.isEmpty(str)) {
|
|
return false;
|
|
}
|
|
try {
|
|
try {
|
|
file = new File(this.c + ad.c(str));
|
|
} catch (Exception e) {
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.b("CommonImageLoaderRefactor", "isImageFileExists error", e);
|
|
}
|
|
file = null;
|
|
}
|
|
if (file == null || !file.isFile()) {
|
|
return false;
|
|
}
|
|
return file.exists();
|
|
} catch (Exception e2) {
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.b("CommonImageLoaderRefactor", "isImageFileExists error", e2);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public DownloadRequest<?> a(String str, String str2, g gVar, c cVar) {
|
|
try {
|
|
return MBDownloadManager.getInstance().download(new DownloadMessage<>(new Object(), str2, str, 100, DownloadResourceType.DOWNLOAD_RESOURCE_TYPE_IMAGE)).withReadTimeout(com.mbridge.msdk.foundation.same.a.u).withConnectTimeout(com.mbridge.msdk.foundation.same.a.t).withWriteTimeout(com.mbridge.msdk.foundation.same.a.s).withDownloadPriority(DownloadPriority.LOW).withHttpRetryCounter(1).withDirectoryPathInternal(this.c).withDownloadStateListener(new b(this.b, this.a, str2, this.c, str, gVar, cVar)).with("download_scene", "download_image").withProgressStateListener(null).withTimeout(ChunkedTrackBlacklistUtil.DEFAULT_TRACK_BLACKLIST_MS).with("do_us_fi_re", Boolean.FALSE.toString()).build();
|
|
} catch (Exception e) {
|
|
if (!MBridgeConstans.DEBUG) {
|
|
return null;
|
|
}
|
|
af.b("CommonImageLoaderRefactor", "createDownloadRequest error", e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static final class b implements OnDownloadStateListener<Object> {
|
|
private final ThreadPoolExecutor a;
|
|
private final Handler b;
|
|
private final String c;
|
|
private final String d;
|
|
private final g e;
|
|
private final String f;
|
|
private final c g;
|
|
|
|
@Override // com.mbridge.msdk.foundation.download.OnDownloadStateListener
|
|
public final void onCancelDownload(DownloadMessage<Object> downloadMessage) {
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.foundation.download.OnDownloadStateListener
|
|
public final void onDownloadStart(DownloadMessage<Object> downloadMessage) {
|
|
}
|
|
|
|
public b(Handler handler, ThreadPoolExecutor threadPoolExecutor, String str, String str2, String str3, g gVar, c cVar) {
|
|
this.b = handler;
|
|
this.a = threadPoolExecutor;
|
|
this.f = str;
|
|
this.c = str2;
|
|
this.d = str3;
|
|
this.e = gVar;
|
|
this.g = cVar;
|
|
}
|
|
|
|
private void a(final String str) {
|
|
if (this.g == null) {
|
|
return;
|
|
}
|
|
this.b.post(new Runnable() { // from class: com.mbridge.msdk.foundation.same.c.d.b.2
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
try {
|
|
b.this.g.onFailedLoad(b.this.f, str);
|
|
} catch (Exception e) {
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.b("CommonImageLoaderRefactor", "callbackForFailed error", e);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
private Bitmap a(Bitmap bitmap, g gVar) {
|
|
if (gVar == null) {
|
|
return bitmap;
|
|
}
|
|
try {
|
|
return gVar.a(bitmap);
|
|
} catch (Exception e) {
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.b("CommonImageLoaderRefactor", "handlerImageTransformation error", e);
|
|
}
|
|
return bitmap;
|
|
}
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.foundation.download.OnDownloadStateListener
|
|
public final void onDownloadError(DownloadMessage<Object> downloadMessage, DownloadError downloadError) {
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.a("CommonImageLoaderRefactor", "onDownloadError imageUrl = " + downloadError.getException().getLocalizedMessage());
|
|
}
|
|
a(downloadError.getException().getLocalizedMessage());
|
|
}
|
|
|
|
@Override // com.mbridge.msdk.foundation.download.OnDownloadStateListener
|
|
public final void onDownloadComplete(DownloadMessage<Object> downloadMessage) {
|
|
File file;
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.a("CommonImageLoaderRefactor", "onDownloadComplete imageUrl = " + this.f + " imagePath = " + this.c + this.d);
|
|
try {
|
|
file = new File(this.c + this.d);
|
|
} catch (Exception e) {
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.b("CommonImageLoaderRefactor", "onDownloadComplete error", e);
|
|
}
|
|
file = null;
|
|
}
|
|
if (file != null && file.isFile() && file.exists()) {
|
|
af.a("CommonImageLoaderRefactor", "onDownloadComplete file size = " + file.length());
|
|
} else {
|
|
af.b("CommonImageLoaderRefactor", "onDownloadComplete file not exist");
|
|
}
|
|
}
|
|
this.a.execute(new Runnable() { // from class: com.mbridge.msdk.foundation.same.c.d.b.1
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
b.a(b.this);
|
|
}
|
|
});
|
|
}
|
|
|
|
public static /* synthetic */ void a(b bVar) {
|
|
if (bVar.g == null) {
|
|
return;
|
|
}
|
|
try {
|
|
Bitmap d = d.d(bVar.c + bVar.d);
|
|
if (d == null) {
|
|
bVar.a("bitmap decode failed");
|
|
} else {
|
|
final Bitmap a = bVar.a(d, bVar.e);
|
|
if (a == null) {
|
|
bVar.a("bitmap transformation failed");
|
|
} else if (bVar.g != null) {
|
|
bVar.b.post(new Runnable() { // from class: com.mbridge.msdk.foundation.same.c.d.b.3
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
try {
|
|
b.this.g.onSuccessLoad(a, b.this.f);
|
|
} catch (Exception e) {
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.b("CommonImageLoaderRefactor", "callbackForSuccess error", e);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.a("CommonImageLoaderRefactor", "onDownloadComplete decodeBitmap error = " + e.getLocalizedMessage());
|
|
}
|
|
bVar.a("bitmap decode failed");
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void a(final String str, final g gVar, final c cVar) {
|
|
try {
|
|
this.a.execute(new Runnable() { // from class: com.mbridge.msdk.foundation.same.c.d.1
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
DownloadRequest a2 = d.this.a(ad.c(str), str, gVar, cVar);
|
|
if (a2 == null) {
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.b("CommonImageLoaderRefactor", "createDownloadRequest error");
|
|
}
|
|
if (cVar == null) {
|
|
return;
|
|
}
|
|
d.this.b.post(new Runnable() { // from class: com.mbridge.msdk.foundation.same.c.d.1.1
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
AnonymousClass1 anonymousClass1 = AnonymousClass1.this;
|
|
cVar.onFailedLoad("create download request error", str);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
a2.start();
|
|
}
|
|
});
|
|
} catch (Exception e) {
|
|
if (MBridgeConstans.DEBUG) {
|
|
af.b("CommonImageLoaderRefactor", "loadImage error", e);
|
|
}
|
|
}
|
|
}
|
|
}
|