Initial commit
This commit is contained in:
165
sources/com/ubt/jimu/update/DownLoadDialog.java
Normal file
165
sources/com/ubt/jimu/update/DownLoadDialog.java
Normal file
@@ -0,0 +1,165 @@
|
||||
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);
|
||||
}
|
||||
}
|
58
sources/com/ubt/jimu/update/DownloadAgainDialog.java
Normal file
58
sources/com/ubt/jimu/update/DownloadAgainDialog.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package com.ubt.jimu.update;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.community.view.popwindow.BaseDialog;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class DownloadAgainDialog extends BaseDialog {
|
||||
private boolean a;
|
||||
private TextView b;
|
||||
private TextView c;
|
||||
|
||||
public DownloadAgainDialog(Context context, boolean z) {
|
||||
super(context);
|
||||
this.a = false;
|
||||
this.a = z;
|
||||
}
|
||||
|
||||
public /* synthetic */ void a(View view) {
|
||||
UpdateManager.c().a(getContext());
|
||||
dismiss();
|
||||
}
|
||||
|
||||
public /* synthetic */ void b(View view) {
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.community.view.popwindow.BaseDialog
|
||||
public void initData() {
|
||||
this.c = (TextView) findViewById(R.id.tv_update_cancel);
|
||||
this.b = (TextView) findViewById(R.id.tv_update_sure);
|
||||
setCancel(!this.a);
|
||||
if (this.a) {
|
||||
this.c.setVisibility(8);
|
||||
} else {
|
||||
this.c.setVisibility(0);
|
||||
}
|
||||
this.b.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.update.c
|
||||
@Override // android.view.View.OnClickListener
|
||||
public final void onClick(View view) {
|
||||
DownloadAgainDialog.this.a(view);
|
||||
}
|
||||
});
|
||||
this.c.setOnClickListener(new View.OnClickListener() { // from class: com.ubt.jimu.update.b
|
||||
@Override // android.view.View.OnClickListener
|
||||
public final void onClick(View view) {
|
||||
DownloadAgainDialog.this.b(view);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.community.view.popwindow.BaseDialog
|
||||
public int layoutId() {
|
||||
return R.layout.dialog_again_download;
|
||||
}
|
||||
}
|
170
sources/com/ubt/jimu/update/UpdateManager.java
Normal file
170
sources/com/ubt/jimu/update/UpdateManager.java
Normal file
@@ -0,0 +1,170 @@
|
||||
package com.ubt.jimu.update;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import com.safelib.TryCatchAspect;
|
||||
import com.ubt.jimu.base.dialog.JimuSimpleDialog;
|
||||
import com.ubt.jimu.base.entities.UpdateApkEntities;
|
||||
import com.ubt.jimu.base.http.ApiObserver;
|
||||
import com.ubt.jimu.base.http.manager.CommunityManager;
|
||||
import com.ubtech.handler.HandlerHub;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import java.util.Iterator;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.runtime.internal.AroundClosure;
|
||||
import org.aspectj.runtime.reflect.Factory;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class UpdateManager {
|
||||
private static UpdateManager d;
|
||||
private static final /* synthetic */ JoinPoint.StaticPart e = null;
|
||||
CompositeDisposable a;
|
||||
private String b = "http://10.10.1.12:8081/version/appVersion/Jimu/jimu-fir_test-2.2.6.11.apk";
|
||||
private boolean c = false;
|
||||
|
||||
public class AjcClosure3 extends AroundClosure {
|
||||
public AjcClosure3(Object[] objArr) {
|
||||
super(objArr);
|
||||
}
|
||||
|
||||
@Override // org.aspectj.runtime.internal.AroundClosure
|
||||
public Object run(Object[] objArr) {
|
||||
Object[] objArr2 = this.state;
|
||||
UpdateManager.a((UpdateManager) objArr2[0], (Context) objArr2[1], (JoinPoint) objArr2[2]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public interface UpdateCallback {
|
||||
void a(UpdateApkEntities updateApkEntities);
|
||||
}
|
||||
|
||||
static {
|
||||
b();
|
||||
}
|
||||
|
||||
private UpdateManager() {
|
||||
}
|
||||
|
||||
static /* synthetic */ void a(DialogInterface dialogInterface, int i) {
|
||||
}
|
||||
|
||||
private static /* synthetic */ void b() {
|
||||
Factory factory = new Factory("UpdateManager.java", UpdateManager.class);
|
||||
factory.a("method-execution", factory.a("1", "checkUpdate", "com.ubt.jimu.update.UpdateManager", "android.app.Activity", "activity", "", "void"), 49);
|
||||
e = factory.a("method-execution", factory.a("1", "startDownLoad", "com.ubt.jimu.update.UpdateManager", "android.content.Context", "context", "", "void"), 113);
|
||||
}
|
||||
|
||||
public static synchronized UpdateManager c() {
|
||||
UpdateManager updateManager;
|
||||
synchronized (UpdateManager.class) {
|
||||
if (d == null) {
|
||||
d = new UpdateManager();
|
||||
}
|
||||
updateManager = d;
|
||||
}
|
||||
return updateManager;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void b(final UpdateApkEntities updateApkEntities, final Activity activity) {
|
||||
HandlerHub.a().post(new Runnable() { // from class: com.ubt.jimu.update.d
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
UpdateManager.this.a(updateApkEntities, activity);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void a(final Activity activity, final UpdateCallback updateCallback, final boolean z) {
|
||||
if (this.a == null) {
|
||||
this.a = new CompositeDisposable();
|
||||
}
|
||||
CommunityManager.create().updateApp(new ApiObserver<UpdateApkEntities>(null) { // from class: com.ubt.jimu.update.UpdateManager.1
|
||||
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public void onNext(UpdateApkEntities updateApkEntities) {
|
||||
UpdateCallback updateCallback2 = updateCallback;
|
||||
if (updateCallback2 != null) {
|
||||
updateCallback2.a(updateApkEntities);
|
||||
}
|
||||
if (!z || updateApkEntities.getModels() == null) {
|
||||
return;
|
||||
}
|
||||
UpdateManager.this.b(updateApkEntities, activity);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.http.ApiObserver, io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
super.onSubscribe(disposable);
|
||||
UpdateManager.this.a.b(disposable);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void b(Context context) {
|
||||
DownLoadDialog downLoadDialog = new DownLoadDialog(context, this.c, this.b);
|
||||
downLoadDialog.show();
|
||||
downLoadDialog.a();
|
||||
}
|
||||
|
||||
public /* synthetic */ void a(UpdateApkEntities updateApkEntities, Activity activity) {
|
||||
if (updateApkEntities.getModels().isIsNeed()) {
|
||||
this.c = updateApkEntities.getModels().isIsForce();
|
||||
this.b = updateApkEntities.getModels().getPath();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Iterator<String> it = updateApkEntities.getModels().getContent().iterator();
|
||||
while (it.hasNext()) {
|
||||
sb.append(it.next());
|
||||
sb.append("\n");
|
||||
}
|
||||
if (activity == null) {
|
||||
return;
|
||||
}
|
||||
Dialog versionUpdateDialog = JimuSimpleDialog.versionUpdateDialog(activity, updateApkEntities.getModels().isIsForce(), sb.toString());
|
||||
if (activity.isFinishing() || activity.isDestroyed() || versionUpdateDialog.isShowing()) {
|
||||
return;
|
||||
}
|
||||
versionUpdateDialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
public void a(Context context) {
|
||||
TryCatchAspect.b().a(new AjcClosure3(new Object[]{this, context, Factory.a(e, this, this, context)}).linkClosureAndJoinPoint(69648));
|
||||
}
|
||||
|
||||
static final /* synthetic */ void a(final UpdateManager updateManager, final Context context, JoinPoint joinPoint) {
|
||||
if (!updateManager.c) {
|
||||
JimuSimpleDialog.showWifiOnlyDialog(context, new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.update.e
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
UpdateManager.a(dialogInterface, i);
|
||||
}
|
||||
}, new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.update.f
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public final void onClick(DialogInterface dialogInterface, int i) {
|
||||
UpdateManager.this.a(context, dialogInterface, i);
|
||||
}
|
||||
}, false);
|
||||
} else {
|
||||
updateManager.b(context);
|
||||
}
|
||||
}
|
||||
|
||||
public /* synthetic */ void a(Context context, DialogInterface dialogInterface, int i) {
|
||||
b(context);
|
||||
}
|
||||
|
||||
public void a() {
|
||||
CompositeDisposable compositeDisposable = this.a;
|
||||
if (compositeDisposable == null) {
|
||||
return;
|
||||
}
|
||||
compositeDisposable.dispose();
|
||||
this.a.a();
|
||||
this.a = null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user