jimu-decompiled/sources/com/ubt/jimu/update/DownLoadDialog.java
2025-05-13 19:24:51 +02:00

166 lines
6.6 KiB
Java

package com.ubt.jimu.update;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.core.content.FileProvider;
import com.liulishuo.filedownloader.BaseDownloadTask;
import com.liulishuo.filedownloader.FileDownloadLargeFileListener;
import com.liulishuo.filedownloader.FileDownloader;
import com.safelib.TryCatchAspect;
import com.ubt.jimu.R;
import com.ubt.jimu.community.view.popwindow.BaseDialog;
import com.ubt.jimu.utils.ExternalOverFroyoUtils;
import java.io.File;
import java.util.List;
import org.aspectj.lang.JoinPoint;
import org.aspectj.runtime.internal.AroundClosure;
import org.aspectj.runtime.reflect.Factory;
/* loaded from: classes2.dex */
public class DownLoadDialog extends BaseDialog {
private static final /* synthetic */ JoinPoint.StaticPart h = null;
private ProgressBar a;
private TextView b;
private boolean c;
private FileDownloader d;
private String e;
private BaseDownloadTask f;
private DownloadAgainDialog g;
public class AjcClosure1 extends AroundClosure {
public AjcClosure1(Object[] objArr) {
super(objArr);
}
@Override // org.aspectj.runtime.internal.AroundClosure
public Object run(Object[] objArr) {
Object[] objArr2 = this.state;
DownLoadDialog.a((DownLoadDialog) objArr2[0], (JoinPoint) objArr2[1]);
return null;
}
}
static {
b();
}
public DownLoadDialog(Context context, boolean z, String str) {
super(context);
this.c = z;
this.e = str;
}
private static /* synthetic */ void b() {
Factory factory = new Factory("DownLoadDialog.java", DownLoadDialog.class);
h = factory.a("method-execution", factory.a("1", "startDownLoad", "com.ubt.jimu.update.DownLoadDialog", "", "", "", "void"), 66);
}
@Override // com.ubt.jimu.community.view.popwindow.BaseDialog
public void initData() {
this.a = (ProgressBar) findViewById(R.id.update_progress);
this.b = (TextView) findViewById(R.id.tv_process);
setCancel(!this.c);
this.d = FileDownloader.e();
setOnDismissListener(new DialogInterface.OnDismissListener() { // from class: com.ubt.jimu.update.a
@Override // android.content.DialogInterface.OnDismissListener
public final void onDismiss(DialogInterface dialogInterface) {
DownLoadDialog.this.a(dialogInterface);
}
});
}
@Override // com.ubt.jimu.community.view.popwindow.BaseDialog
public int layoutId() {
return R.layout.dialog_download_process;
}
public /* synthetic */ void a(DialogInterface dialogInterface) {
BaseDownloadTask baseDownloadTask = this.f;
if (baseDownloadTask != null) {
baseDownloadTask.pause();
}
}
public void a() {
TryCatchAspect.b().a(new AjcClosure1(new Object[]{this, Factory.a(h, this, this)}).linkClosureAndJoinPoint(69648));
}
static final /* synthetic */ void a(DownLoadDialog downLoadDialog, JoinPoint joinPoint) {
downLoadDialog.f = downLoadDialog.d.a(downLoadDialog.e);
StringBuilder sb = new StringBuilder();
sb.append(ExternalOverFroyoUtils.a(downLoadDialog.getContext()));
sb.append(File.separator);
String str = downLoadDialog.e;
sb.append(str.substring(str.lastIndexOf("/"), downLoadDialog.e.length()));
final String sb2 = sb.toString();
downLoadDialog.f.b(sb2);
BaseDownloadTask baseDownloadTask = downLoadDialog.f;
baseDownloadTask.b(new FileDownloadLargeFileListener() { // from class: com.ubt.jimu.update.DownLoadDialog.1
@Override // com.liulishuo.filedownloader.FileDownloadLargeFileListener
protected void a(BaseDownloadTask baseDownloadTask2, long j, long j2) {
}
@Override // com.liulishuo.filedownloader.FileDownloadLargeFileListener
protected void b(BaseDownloadTask baseDownloadTask2, long j, long j2) {
}
@Override // com.liulishuo.filedownloader.FileDownloadLargeFileListener
protected void c(BaseDownloadTask baseDownloadTask2, long j, long j2) {
int i = (int) ((j * 100) / j2);
DownLoadDialog.this.a.setProgress(i);
DownLoadDialog.this.b.setText(String.format(((BaseDialog) DownLoadDialog.this).mContext.getResources().getString(R.string.update_process), String.valueOf(i + "%")));
}
@Override // com.liulishuo.filedownloader.FileDownloadListener
protected void completed(BaseDownloadTask baseDownloadTask2) {
DownLoadDialog.a(DownLoadDialog.this.getContext(), new File(sb2));
DownLoadDialog.this.dismiss();
}
@Override // com.liulishuo.filedownloader.FileDownloadListener
protected void error(BaseDownloadTask baseDownloadTask2, Throwable th) {
if (DownLoadDialog.this.g == null) {
DownLoadDialog downLoadDialog2 = DownLoadDialog.this;
downLoadDialog2.g = new DownloadAgainDialog(downLoadDialog2.getContext(), DownLoadDialog.this.c);
}
DownLoadDialog.this.dismiss();
DownLoadDialog.this.g.show();
}
@Override // com.liulishuo.filedownloader.FileDownloadListener
protected void warn(BaseDownloadTask baseDownloadTask2) {
}
});
baseDownloadTask.start();
}
public static void a(Context context, File file) {
Uri fromFile;
List<ResolveInfo> queryIntentActivities;
if (file == null || !file.exists()) {
return;
}
Intent intent = new Intent("android.intent.action.VIEW");
if (Build.VERSION.SDK_INT >= 24) {
intent.setFlags(1);
fromFile = FileProvider.getUriForFile(context, context.getString(R.string.file_provider_authorities), file);
} else {
fromFile = Uri.fromFile(file);
intent.setFlags(268435456);
}
intent.setDataAndType(fromFile, "application/vnd.android.package-archive");
PackageManager packageManager = context.getPackageManager();
if (packageManager == null || (queryIntentActivities = packageManager.queryIntentActivities(intent, 0)) == null || queryIntentActivities.size() <= 0) {
return;
}
context.startActivity(intent);
}
}