package com.ss.android.ugc.aweme.qrcode.view;

import X.1oX;
import X.3i8;
import X.4FQ;
import X.4vl;
import X.88u;
import X.8gF;
import X.C3621JcC;
import X.IIM;
import X.LxU;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import com.bytedance.apm.agent.v2.instrumentation.ActivityAgent;
import com.bytedance.covode.number.Covode;
import com.bytedance.sysoptimizer.EnterTransitionCrashOptimizer;

public class QRCodePermissionActivity extends 1oX {
    public static long LIZ;
    public boolean LIZIZ;
    public int LIZJ = -1;
    public boolean LIZLLL;

    static {
        Covode.recordClassIndex(102072);
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [com.ss.android.ugc.aweme.qrcode.view.QRCodePermissionActivity, X.1oX, android.app.Activity] */
    public void onDestroy() {
        8gF.LJ(this);
        QRCodePermissionActivity.super.onDestroy();
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [X.1hK, com.ss.android.ugc.aweme.qrcode.view.QRCodePermissionActivity, android.app.Activity] */
    public void onPause() {
        8gF.LIZJ(this);
        QRCodePermissionActivity.super.onPause();
    }

    /* JADX WARNING: type inference failed for: r3v0, types: [X.1hK, com.ss.android.ugc.aweme.qrcode.view.QRCodePermissionActivity, android.app.Activity] */
    public void onResume() {
        8gF.LIZIZ(this);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.qrcode.view.QRCodePermissionActivity", "onResume", true);
        QRCodePermissionActivity.super.onResume();
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.qrcode.view.QRCodePermissionActivity", "onResume", false);
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [com.ss.android.ugc.aweme.qrcode.view.QRCodePermissionActivity, X.1oX, android.app.Activity] */
    public void onStart() {
        8gF.LIZ(this);
        QRCodePermissionActivity.super.onStart();
    }

    public void onWindowFocusChanged(boolean z) {
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.qrcode.view.QRCodePermissionActivity", "onWindowFocusChanged", true);
        QRCodePermissionActivity.super.onWindowFocusChanged(z);
    }

    /* JADX WARNING: type inference failed for: r2v0, types: [android.content.Context, com.ss.android.ugc.aweme.qrcode.view.QRCodePermissionActivity] */
    public final void LIZIZ() {
        int i = this.LIZJ;
        if (i != -1) {
            ScanQRCodeActivityV2.LIZ(this, i, this.LIZLLL);
        } else {
            ScanQRCodeActivityV2.LIZ(this, this.LIZIZ);
        }
        finish();
    }

    /* JADX WARNING: type inference failed for: r1v0, types: [com.ss.android.ugc.aweme.qrcode.view.QRCodePermissionActivity, X.1oX, android.app.Activity] */
    public void onStop() {
        8gF.LIZLLL(this);
        QRCodePermissionActivity.super.onStop();
        if (EnterTransitionCrashOptimizer.getContext() != null) {
            try {
                getWindow().getDecorView().getViewTreeObserver().dispatchOnPreDraw();
            } catch (Throwable unused) {
            }
        }
        try {
            getWindow().getDecorView().getViewTreeObserver().dispatchOnPreDraw();
        } catch (Throwable unused2) {
        }
    }

    /* JADX WARNING: type inference failed for: r4v0, types: [android.content.Context, com.ss.android.ugc.aweme.qrcode.view.QRCodePermissionActivity] */
    public final void LIZ() {
        4vl r3 = new 4vl(this);
        r3.LIZLLL(2131827920);
        r3.LIZ(2131822315, false, new DialogInterface.OnClickListener() {
            static {
                Covode.recordClassIndex(102075);
            }

            public final void onClick(DialogInterface dialogInterface, int i) {
                QRCodePermissionActivity.this.finish();
            }
        });
        r3.LIZ(2131823147, new DialogInterface.OnClickListener() {
            static {
                Covode.recordClassIndex(102074);
            }

            /* JADX WARNING: type inference failed for: r0v0, types: [android.content.Context, com.ss.android.ugc.aweme.qrcode.view.QRCodePermissionActivity] */
            public final void onClick(DialogInterface dialogInterface, int i) {
                88u.LIZ(QRCodePermissionActivity.this);
                QRCodePermissionActivity.this.finish();
            }
        });
        r3.LIZ(new DialogInterface.OnDismissListener() {
            static {
                Covode.recordClassIndex(102073);
            }

            public final void onDismiss(DialogInterface dialogInterface) {
                QRCodePermissionActivity.this.finish();
            }
        });
        4FQ.LIZ(r3.LIZ().LIZJ());
    }

    /* JADX WARNING: type inference failed for: r7v0, types: [android.content.Context, X.1hK, com.ss.android.ugc.aweme.qrcode.view.QRCodePermissionActivity, X.1oX, android.app.Activity] */
    public void onCreate(Bundle bundle) {
        8gF.LIZ(this, bundle);
        boolean z = true;
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.qrcode.view.QRCodePermissionActivity", "onCreate", true);
        QRCodePermissionActivity.super.onCreate(bundle);
        if (IIM.LIZ(this) != 0) {
            z = false;
        }
        this.LIZIZ = getIntent().getBooleanExtra("enter_from", false);
        this.LIZJ = getIntent().getIntExtra("page_from", -1);
        this.LIZLLL = getIntent().getBooleanExtra("camera_only", false);
        if (z) {
            LIZIZ();
        } else if (IIM.LIZ()) {
            LxU.LIZ(this).LIZ(new String[]{"android.permission.CAMERA"}).LIZ(new C3621JcC(this));
        } else {
            LIZ();
        }
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.qrcode.view.QRCodePermissionActivity", "onCreate", false);
    }

    public static void LIZ(Context context, Intent intent) {
        3i8.LIZ(intent, context);
        context.startActivity(intent);
    }

    public static void LIZ(Context context, boolean z, boolean z2) {
        long currentTimeMillis = System.currentTimeMillis();
        if (currentTimeMillis - LIZ >= 1000) {
            LIZ = currentTimeMillis;
            Intent intent = new Intent(context, QRCodePermissionActivity.class);
            intent.putExtra("finishAfterScan", z);
            intent.putExtra("enter_from", z2);
            LIZ(context, intent);
        }
    }
}
