正在查看: 六分钟步行测试管理软件 v1.1.0.2112120029 应用的 DownloadingActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 六分钟步行测试管理软件 v1.1.0.2112120029 应用的 DownloadingActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.allenliu.versionchecklib.v2.ui;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import com.allenliu.versionchecklib.R;
import com.allenliu.versionchecklib.core.http.AllenHttp;
import com.allenliu.versionchecklib.utils.ALog;
import com.allenliu.versionchecklib.v2.builder.BuilderManager;
import com.allenliu.versionchecklib.v2.builder.DownloadBuilder;
import com.allenliu.versionchecklib.v2.callback.CustomDownloadingDialogListener;
import com.allenliu.versionchecklib.v2.eventbus.CommonEvent;
import java.util.Arrays;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.StringCompanionObject;
import org.greenrobot.eventbus.EventBus;
@Metadata(d1 = {"\u0000D\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0006\u0018\u0000 !2\u00020\u00012\u00020\u0002:\u0001!B\u0005¢\u0006\u0002\u0010\u0003J\b\u0010\r\u001a\u00020\u000eH\u0002J\b\u0010\u000f\u001a\u00020\u000eH\u0002J\u0010\u0010\u0010\u001a\u00020\u000e2\u0006\u0010\u0011\u001a\u00020\u0012H\u0016J\u000e\u0010\u0010\u001a\u00020\u000e2\u0006\u0010\u0013\u001a\u00020\tJ\u0012\u0010\u0014\u001a\u00020\u000e2\b\u0010\u0015\u001a\u0004\u0018\u00010\u0016H\u0014J\b\u0010\u0017\u001a\u00020\u000eH\u0014J\b\u0010\u0018\u001a\u00020\u000eH\u0014J\b\u0010\u0019\u001a\u00020\u000eH\u0014J\u0014\u0010\u001a\u001a\u00020\u000e2\n\u0010\u001b\u001a\u0006\u0012\u0002\b\u00030\u001cH\u0016J\b\u0010\u001d\u001a\u00020\u000eH\u0016J\b\u0010\u001e\u001a\u00020\u000eH\u0016J\b\u0010\u001f\u001a\u00020\u000eH\u0002J\b\u0010 \u001a\u00020\u000eH\u0002R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0006\u001a\u0004\u0018\u00010\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010\b\u001a\u00020\tX\u0084\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\b\u0010\n\"\u0004\b\u000b\u0010\f¨\u0006\""}, d2 = {"Lcom/allenliu/versionchecklib/v2/ui/DownloadingActivity;", "Lcom/allenliu/versionchecklib/v2/ui/AllenBaseActivity;", "Landroid/content/DialogInterface$OnCancelListener;", "()V", "currentProgress", "", "downloadingDialog", "Landroid/app/Dialog;", "isDestroy", "", "()Z", "setDestroy", "(Z)V", "destroy", "", "destroyWithOutDismiss", "onCancel", "dialog", "Landroid/content/DialogInterface;", "isDownloadCompleted", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onPause", "onResume", "onStop", "receiveEvent", "commonEvent", "Lcom/allenliu/versionchecklib/v2/eventbus/CommonEvent;", "showCustomDialog", "showDefaultDialog", "showLoadingDialog", "updateProgress", "Companion", "library_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class DownloadingActivity extends AllenBaseActivity implements DialogInterface.OnCancelListener {
public static final String PROGRESS = "progress";
private int currentProgress;
private Dialog downloadingDialog;
private boolean isDestroy;
protected final boolean getIsDestroy() {
return this.isDestroy;
}
protected final void setDestroy(boolean z) {
this.isDestroy = z;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ALog.e("loading activity create");
showLoadingDialog();
}
public final void onCancel(boolean isDownloadCompleted) {
if (!isDownloadCompleted) {
BuilderManager.doWhenNotNull$default(BuilderManager.INSTANCE, null, new Function1<DownloadBuilder, Unit>() {
public final Unit invoke(DownloadBuilder downloadBuilder) {
Intrinsics.checkNotNullParameter(downloadBuilder, "$this$doWhenNotNull");
if (downloadBuilder.getForceUpdateListener() == null) {
return null;
}
AllenHttp.getHttpClient().dispatcher().cancelAll();
return Unit.INSTANCE;
}
}, 1, null);
cancelHandler();
checkForceUpdate();
}
finish();
}
@Override
public void onCancel(DialogInterface dialog) {
Intrinsics.checkNotNullParameter(dialog, "dialog");
onCancel(false);
}
@Override
public void receiveEvent(CommonEvent<?> commonEvent) {
Intrinsics.checkNotNullParameter(commonEvent, "commonEvent");
super.receiveEvent(commonEvent);
switch (commonEvent.getEventType()) {
case 100:
Object data = commonEvent.getData();
Intrinsics.checkNotNull(data, "null cannot be cast to non-null type kotlin.Int");
this.currentProgress = ((Integer) data).intValue();
updateProgress();
break;
case 101:
onCancel(true);
break;
case 102:
destroy();
EventBus.getDefault().removeStickyEvent(commonEvent);
break;
}
}
@Override
public void showDefaultDialog() {
DownloadingActivity downloadingActivity = this;
final View inflate = LayoutInflater.from(downloadingActivity).inflate(R.layout.downloading_layout, (ViewGroup) null);
final AlertDialog create = new AlertDialog.Builder(downloadingActivity).setTitle("").setView(inflate).create();
BuilderManager.doWhenNotNull$default(BuilderManager.INSTANCE, null, new Function1<DownloadBuilder, Unit>() {
{
super(1);
}
public Object invoke(Object obj) {
invoke((DownloadBuilder) obj);
return Unit.INSTANCE;
}
public final void invoke(DownloadBuilder downloadBuilder) {
int i;
int i2;
Intrinsics.checkNotNullParameter(downloadBuilder, "$this$doWhenNotNull");
if (downloadBuilder.getForceUpdateListener() != null) {
AlertDialog.this.setCancelable(false);
} else {
AlertDialog.this.setCancelable(true);
}
AlertDialog.this.setCanceledOnTouchOutside(false);
ProgressBar progressBar = (ProgressBar) inflate.findViewById(R.id.pb);
TextView textView = (TextView) inflate.findViewById(R.id.tv_progress);
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String string = this.getString(R.string.versionchecklib_progress);
Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.versionchecklib_progress)");
i = this.currentProgress;
String format = String.format(string, Arrays.copyOf(new Object[]{Integer.valueOf(i)}, 1));
Intrinsics.checkNotNullExpressionValue(format, "format(format, *args)");
textView.setText(format);
i2 = this.currentProgress;
progressBar.setProgress(i2);
AlertDialog.this.show();
}
}, 1, null);
this.downloadingDialog = create;
}
@Override
public void showCustomDialog() {
BuilderManager.doWhenNotNull$default(BuilderManager.INSTANCE, null, new DownloadingActivity$showCustomDialog$1(this), 1, null);
}
@Override
protected void onStop() {
super.onStop();
destroyWithOutDismiss();
this.isDestroy = true;
}
@Override
protected void onPause() {
super.onPause();
}
@Override
protected void onResume() {
super.onResume();
this.isDestroy = false;
Dialog dialog = this.downloadingDialog;
if (dialog == null || dialog.isShowing()) {
return;
}
dialog.show();
}
private final void destroyWithOutDismiss() {
Dialog dialog = this.downloadingDialog;
if (dialog == null || !dialog.isShowing()) {
return;
}
dialog.dismiss();
}
private final void destroy() {
ALog.e("loading activity destroy");
destroyWithOutDismiss();
finish();
}
private final void updateProgress() {
if (this.isDestroy) {
return;
}
BuilderManager.doWhenNotNull$default(BuilderManager.INSTANCE, null, new Function1<DownloadBuilder, Unit>() {
{
super(1);
}
public final Unit invoke(DownloadBuilder downloadBuilder) {
Dialog dialog;
Dialog dialog2;
Dialog dialog3;
int i;
int i2;
Dialog dialog4;
int i3;
Intrinsics.checkNotNullParameter(downloadBuilder, "$this$doWhenNotNull");
if (downloadBuilder.getCustomDownloadingDialogListener() == null) {
dialog = DownloadingActivity.this.downloadingDialog;
ProgressBar progressBar = dialog != null ? (ProgressBar) dialog.findViewById(R.id.pb) : null;
if (progressBar != null) {
i2 = DownloadingActivity.this.currentProgress;
progressBar.setProgress(i2);
}
dialog2 = DownloadingActivity.this.downloadingDialog;
TextView textView = dialog2 != null ? (TextView) dialog2.findViewById(R.id.tv_progress) : null;
if (textView != null) {
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String string = DownloadingActivity.this.getString(R.string.versionchecklib_progress);
Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.versionchecklib_progress)");
i = DownloadingActivity.this.currentProgress;
String format = String.format(string, Arrays.copyOf(new Object[]{Integer.valueOf(i)}, 1));
Intrinsics.checkNotNullExpressionValue(format, "format(format, *args)");
textView.setText(format);
}
dialog3 = DownloadingActivity.this.downloadingDialog;
if (dialog3 == null) {
return null;
}
dialog3.show();
return Unit.INSTANCE;
}
CustomDownloadingDialogListener customDownloadingDialogListener = downloadBuilder.getCustomDownloadingDialogListener();
dialog4 = DownloadingActivity.this.downloadingDialog;
i3 = DownloadingActivity.this.currentProgress;
customDownloadingDialogListener.updateUI(dialog4, i3, downloadBuilder.getVersionBundle());
return Unit.INSTANCE;
}
}, 1, null);
}
private final void showLoadingDialog() {
ALog.e("show loading");
if (this.isDestroy) {
return;
}
BuilderManager.doWhenNotNull$default(BuilderManager.INSTANCE, null, new Function1<DownloadBuilder, Unit>() {
{
super(1);
}
public Object invoke(Object obj) {
invoke((DownloadBuilder) obj);
return Unit.INSTANCE;
}
public final void invoke(DownloadBuilder downloadBuilder) {
Intrinsics.checkNotNullParameter(downloadBuilder, "$this$doWhenNotNull");
if (downloadBuilder.getCustomDownloadingDialogListener() != null) {
DownloadingActivity.this.showCustomDialog();
} else {
DownloadingActivity.this.showDefaultDialog();
}
}
}, 1, null);
Dialog dialog = this.downloadingDialog;
if (dialog != null) {
dialog.setOnCancelListener(this);
}
}
}