导航菜单

页面标题

页面副标题

六分钟步行测试管理软件 v1.1.0.2112120029 - UIActivity.java 源代码

正在查看: 六分钟步行测试管理软件 v1.1.0.2112120029 应用的 UIActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.allenliu.versionchecklib.v2.ui;

import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import androidx.appcompat.app.AlertDialog;
import com.allenliu.versionchecklib.R;
import com.allenliu.versionchecklib.utils.ALog;
import com.allenliu.versionchecklib.utils.AllenEventBusUtil;
import com.allenliu.versionchecklib.utils.AppUtils;
import com.allenliu.versionchecklib.v2.AllenVersionChecker;
import com.allenliu.versionchecklib.v2.builder.BuilderManager;
import com.allenliu.versionchecklib.v2.builder.DownloadBuilder;
import com.allenliu.versionchecklib.v2.builder.UIData;
import java.io.File;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;

@Metadata(d1 = {"\u00004\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\b\u0018\u00002\u00020\u00012\u00020\u0002B\u0005¢\u0006\u0002\u0010\u0003J\b\u0010\b\u001a\u00020\tH\u0002J\u0010\u0010\n\u001a\u00020\t2\u0006\u0010\u000b\u001a\u00020\fH\u0016J\u0012\u0010\r\u001a\u00020\t2\b\u0010\u000e\u001a\u0004\u0018\u00010\u000fH\u0014J\b\u0010\u0010\u001a\u00020\tH\u0014J\b\u0010\u0011\u001a\u00020\tH\u0014J\b\u0010\u0012\u001a\u00020\tH\u0014J\b\u0010\u0013\u001a\u00020\tH\u0014J\b\u0010\u0014\u001a\u00020\tH\u0016J\b\u0010\u0015\u001a\u00020\tH\u0016J\b\u0010\u0016\u001a\u00020\tH\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\u0000¨\u0006\u0017"}, d2 = {"Lcom/allenliu/versionchecklib/v2/ui/UIActivity;", "Lcom/allenliu/versionchecklib/v2/ui/AllenBaseActivity;", "Landroid/content/DialogInterface$OnCancelListener;", "()V", "isDestroy", "", "versionDialog", "Landroid/app/Dialog;", "dealVersionDialogCommit", "", "onCancel", "dialogInterface", "Landroid/content/DialogInterface;", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onDestroy", "onPause", "onResume", "onStop", "showCustomDialog", "showDefaultDialog", "showVersionDialog", "library_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class UIActivity extends AllenBaseActivity implements DialogInterface.OnCancelListener {
    private boolean isDestroy;
    private Dialog versionDialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ALog.e("version activity create");
        showVersionDialog();
    }

    @Override
    protected void onDestroy() {
        this.isDestroy = true;
        ALog.e("version activity destroy");
        super.onDestroy();
    }

    @Override
    public void showDefaultDialog() {
        String str;
        String str2;
        DownloadBuilder downloadBuilder = BuilderManager.INSTANCE.getDownloadBuilder();
        if (downloadBuilder != null) {
            UIData versionBundle = downloadBuilder.getVersionBundle();
            if (versionBundle != null) {
                str = versionBundle.getTitle();
                str2 = versionBundle.getContent();
                Intrinsics.checkNotNullExpressionValue(str2, "uiData.content");
            } else {
                str = "提示";
                str2 = "检测到新版本";
            }
            AlertDialog.Builder positiveButton = new AlertDialog.Builder(this).setTitle(str).setMessage(str2).setPositiveButton(getString(R.string.versionchecklib_confirm), new DialogInterface.OnClickListener() {
                @Override
                public final void onClick(DialogInterface dialogInterface, int i) {
                    UIActivity.showDefaultDialog$lambda$0(UIActivity.this, dialogInterface, i);
                }
            });
            if (downloadBuilder.getForceUpdateListener() == null) {
                positiveButton.setNegativeButton(getString(R.string.versionchecklib_cancel), new DialogInterface.OnClickListener() {
                    @Override
                    public final void onClick(DialogInterface dialogInterface, int i) {
                        UIActivity.showDefaultDialog$lambda$1(UIActivity.this, dialogInterface, i);
                    }
                });
                positiveButton.setCancelable(false);
            } else {
                positiveButton.setCancelable(false);
            }
            AlertDialog create = positiveButton.create();
            create.setCanceledOnTouchOutside(false);
            create.show();
            this.versionDialog = create;
        }
    }

    public static final void showDefaultDialog$lambda$0(UIActivity uIActivity, DialogInterface dialogInterface, int i) {
        Intrinsics.checkNotNullParameter(uIActivity, "this$0");
        uIActivity.dealVersionDialogCommit();
    }

    public static final void showDefaultDialog$lambda$1(UIActivity uIActivity, DialogInterface dialogInterface, int i) {
        Intrinsics.checkNotNullParameter(uIActivity, "this$0");
        Intrinsics.checkNotNullExpressionValue(dialogInterface, "d");
        uIActivity.onCancel(dialogInterface);
    }

    @Override
    public void showCustomDialog() {
        DownloadBuilder downloadBuilder = BuilderManager.INSTANCE.getDownloadBuilder();
        if (downloadBuilder == null) {
            return;
        }
        ALog.e("show customization dialog");
        final Dialog customVersionDialog = downloadBuilder.getCustomVersionDialogListener().getCustomVersionDialog(this, downloadBuilder.getVersionBundle());
        try {
            View findViewById = customVersionDialog.findViewById(R.id.versionchecklib_version_dialog_commit);
            if (findViewById != null) {
                ALog.e("view not null");
                findViewById.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        UIActivity.showCustomDialog$lambda$5$lambda$3(UIActivity.this, view);
                    }
                });
            } else {
                throwWrongIdsException();
            }
            View findViewById2 = customVersionDialog.findViewById(R.id.versionchecklib_version_dialog_cancel);
            if (findViewById2 != null) {
                findViewById2.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        UIActivity.showCustomDialog$lambda$5$lambda$4(UIActivity.this, customVersionDialog, view);
                    }
                });
            }
        } catch (Exception e) {
            e.printStackTrace();
            throwWrongIdsException();
        }
        customVersionDialog.show();
        this.versionDialog = customVersionDialog;
    }

    public static final void showCustomDialog$lambda$5$lambda$3(UIActivity uIActivity, View view) {
        Intrinsics.checkNotNullParameter(uIActivity, "this$0");
        ALog.e("click");
        uIActivity.dealVersionDialogCommit();
    }

    public static final void showCustomDialog$lambda$5$lambda$4(UIActivity uIActivity, Dialog dialog, View view) {
        Intrinsics.checkNotNullParameter(uIActivity, "this$0");
        Intrinsics.checkNotNullExpressionValue(dialog, "this");
        uIActivity.onCancel(dialog);
    }

    private final void showVersionDialog() {
        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.getCustomVersionDialogListener() != null) {
                    UIActivity.this.showCustomDialog();
                } else {
                    UIActivity.this.showDefaultDialog();
                }
            }
        }, 1, null);
        Dialog dialog = this.versionDialog;
        if (dialog != null) {
            dialog.setOnCancelListener(this);
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onStop() {
        super.onStop();
        Dialog dialog = this.versionDialog;
        if (dialog == null || !dialog.isShowing()) {
            return;
        }
        dialog.dismiss();
    }

    @Override
    protected void onResume() {
        super.onResume();
        Dialog dialog = this.versionDialog;
        if (dialog == null || dialog.isShowing()) {
            return;
        }
        dialog.show();
    }

    private final void dealVersionDialogCommit() {
        DownloadBuilder downloadBuilder = BuilderManager.INSTANCE.getDownloadBuilder();
        if (downloadBuilder != null) {
            if (downloadBuilder.getReadyDownloadCommitClickListener() != null) {
                downloadBuilder.getReadyDownloadCommitClickListener().onCommitClick();
            }
            if (downloadBuilder.isSilentDownload()) {
                String downloadAPKPath = downloadBuilder.getDownloadAPKPath();
                int i = R.string.versionchecklib_download_apkname;
                Object[] objArr = new Object[1];
                objArr[0] = downloadBuilder.getApkName() != null ? downloadBuilder.getApkName() : getPackageName();
                AppUtils.installApk(this, new File(downloadAPKPath + getString(i, objArr)), downloadBuilder.getCustomInstallListener());
                checkForceUpdate();
            } else {
                AllenEventBusUtil.sendEventBus(98);
            }
            finish();
        }
    }

    @Override
    public void onCancel(DialogInterface dialogInterface) {
        Intrinsics.checkNotNullParameter(dialogInterface, "dialogInterface");
        cancelHandler();
        AllenVersionChecker.getInstance().cancelAllMission();
        finish();
        checkForceUpdate();
    }
}