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

import X.070;
import X.0Gf;
import X.0Gi;
import X.0Gp;
import X.2GO;
import X.2HZ;
import X.2IP;
import X.2K7;
import X.2fU;
import X.2ha;
import X.3G1;
import X.3i8;
import X.46i;
import X.4B5;
import X.4TL;
import X.8gF;
import X.9EH;
import X.9Y3;
import X.Cc1;
import X.F2D;
import X.F2E;
import X.ISm;
import X.Jaj;
import X.KAv;
import X.LX6;
import X.LXH;
import X.Lw4;
import X.M12;
import X.OPC;
import X.OPD;
import X.OPE;
import X.OPF;
import X.OPG;
import X.OPH;
import X.OPI;
import X.OPJ;
import X.OPL;
import X.OPM;
import X.OPN;
import X.OPO;
import X.OPR;
import X.OQL;
import X.OQO;
import X.Rc9;
import X.SAl;
import X.SNU;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.animation.LinearInterpolator;
import android.view.animation.TranslateAnimation;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import com.bytedance.apm.agent.v2.instrumentation.ActivityAgent;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.sysoptimizer.EnterTransitionCrashOptimizer;
import com.ss.android.ugc.aweme.out.AVExternalServiceImpl;
import com.ss.android.ugc.aweme.profile.model.AvatarUri;
import com.ss.android.ugc.aweme.qrcode.presenter.QrCodeScanImpl;
import com.ss.android.ugc.aweme.qrcode.presenter.QrCodeScanService;
import com.ss.android.ugc.aweme.services.external.ability.IQRCodeScanner;
import com.ss.android.ugc.aweme.services.external.ability.camera.AVCameraParams;
import com.ss.android.ugc.aweme.services.external.ability.qr.AVEnigma;
import com.ss.android.ugc.aweme.services.external.ability.qr.AVEnigmaResult;
import com.ss.android.ugc.aweme.services.external.ability.qr.AVScanSettings;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Callable;
import org.greenrobot.eventbus.ThreadMode;

public class ScanQRCodeActivityV2 extends SNU implements View.OnClickListener, F2E, LXH, 2HZ, 2GO {
    public int LIZ;
    public boolean LIZIZ;
    public SurfaceView LIZJ;
    public IQRCodeScanner LIZLLL;
    public OPL LJ;
    public OPR LJFF;
    public F2D LJI;
    public boolean LJII;
    public boolean LJIIIIZZ;
    public boolean LJIIIZ;
    public boolean LJIIJ;
    public ImageView LJIIJJI;
    public GestureDetector LJIIL;
    public ScaleGestureDetector LJIILIIL;
    public GestureDetector LJIILJJIL;
    public float LJIILL = 1.0f;
    public boolean LJIILLIIL;
    public IQRCodeScanner.OnEnigmaScanListener LJIIZILJ = new IQRCodeScanner.OnEnigmaScanListener() {
        static {
            Covode.recordClassIndex(102077);
        }

        public final void onFail(int i) {
            if (ScanQRCodeActivityV2.this.LJIIJ && ScanQRCodeActivityV2.this.LJ != null) {
                ScanQRCodeActivityV2.this.LJ.LIZ(ScanQRCodeActivityV2.this.LJII);
            }
            if (ScanQRCodeActivityV2.this.LJII && ScanQRCodeActivityV2.this.LIZLLL != null) {
                ScanQRCodeActivityV2.this.LIZLLL.stopPicScan();
            }
            ScanQRCodeActivityV2.this.LJII = false;
        }

        public final void onSuccess(AVEnigmaResult aVEnigmaResult) {
            if (ScanQRCodeActivityV2.this.LJIIJ && !ScanQRCodeActivityV2.this.LJIIIZ && ScanQRCodeActivityV2.this.LJ != null && aVEnigmaResult != null) {
                if (aVEnigmaResult.getResult() != null && aVEnigmaResult.getResult().length > 0) {
                    ScanQRCodeActivityV2.this.LJIIIZ = true;
                    AVEnigma[] result = aVEnigmaResult.getResult();
                    if (ScanQRCodeActivityV2.this.LIZIZ) {
                        Intent intent = new Intent();
                        intent.putExtra("scan_code_result", result[0].getText());
                        intent.putExtra("scan_code_type", result[0].getType());
                        ScanQRCodeActivityV2.this.setResult(-1, intent);
                        ScanQRCodeActivityV2.this.finish();
                        return;
                    }
                    ScanQRCodeActivityV2.this.LJ.LIZ(ScanQRCodeActivityV2.this.LJII, result[0].getType(), result[0].getText(), ScanQRCodeActivityV2.this.LIZ);
                } else if (ScanQRCodeActivityV2.this.LIZLLL != null) {
                    ScanQRCodeActivityV2.this.LIZLLL.zoomByRatio(aVEnigmaResult.zoomFactor);
                }
            }
            ScanQRCodeActivityV2.this.LJII = false;
        }
    };
    public TextView LJIJ;
    public OQL LJIJI;
    public Jaj LJIJJ;
    public boolean LJIJJLI;
    public TextView LJIL;
    public boolean LJJ;
    public TextView LJJI;
    public TextView LJJIFFI;
    public FrameLayout LJJII;
    public RelativeLayout LJJIII;
    public boolean LJJIIJ;
    public OPC LJJIIJZLJL;
    public QrCodeScanService LJJIIZ;

    static {
        Covode.recordClassIndex(102076);
    }

    public final void LIZIZ(AvatarUri avatarUri) {
    }

    public final void LIZIZ(Exception exc) {
    }

    public Map<Integer, Object> getSubscriberEventTypes() {
        HashMap hashMap = new HashMap();
        hashMap.put(165, new Rc9(ScanQRCodeActivityV2.class, "onNetStateChangeEvent", 2IP.class, ThreadMode.POSTING, 0, false));
        return hashMap;
    }

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

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

    public final void LIZJ() {
        this.LJIIJJI.clearAnimation();
    }

    /* JADX WARNING: type inference failed for: r1v0, types: [com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2, android.app.Activity] */
    public final void LJIIIIZZ() {
        4B5.LIZ.LIZ(this);
    }

    public final void LIZIZ() {
        0Gp.LIZ(new OPI(this));
    }

    public final void LJ() {
        Jaj jaj = this.LJIJJ;
        if (jaj != null && jaj.isShowing()) {
            this.LJIJJ.dismiss();
        }
    }

    public final void LJFF() {
        this.LJIIIZ = false;
        IQRCodeScanner iQRCodeScanner = this.LIZLLL;
        if (iQRCodeScanner != null) {
            iQRCodeScanner.enableCameraScan(true, 65536);
        }
    }

    public final /* synthetic */ Object LJIIIZ() {
        MethodCollector.i(565);
        synchronized (this) {
            try {
                IQRCodeScanner iQRCodeScanner = this.LIZLLL;
                if (iQRCodeScanner != null) {
                    iQRCodeScanner.stop();
                }
            } catch (Throwable th) {
                MethodCollector.o(565);
                throw th;
            }
        }
        MethodCollector.o(565);
        return null;
    }

    /* JADX WARNING: type inference failed for: r2v0, types: [com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2, X.SNU, android.app.Activity] */
    public void onPause() {
        8gF.LIZJ(this);
        ScanQRCodeActivityV2.super.onPause();
        if (this.LJJ) {
            LJIIJ();
        }
        this.LIZJ.setVisibility(4);
    }

    /* JADX WARNING: type inference failed for: r4v0, types: [com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2, X.SNU, android.app.Activity] */
    public void onResume() {
        8gF.LIZIZ(this);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2", "onResume", true);
        this.LJJIIZ.LIZ();
        ScanQRCodeActivityV2.super.onResume();
        this.LIZJ.setVisibility(0);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2", "onResume", false);
    }

    private void LJIIJ() {
        IQRCodeScanner iQRCodeScanner = this.LIZLLL;
        if (iQRCodeScanner != null) {
            iQRCodeScanner.closeLight();
        }
        this.LJJ = false;
        this.LJIL.setAlpha(0.8f);
        this.LJIL.setText(2131826605);
        Drawable drawable = getResources().getDrawable(2131233703);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        this.LJIL.setCompoundDrawables((Drawable) null, drawable, (Drawable) null, (Drawable) null);
    }

    /* JADX WARNING: type inference failed for: r2v0, types: [android.content.Context, com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2] */
    public final void LIZLLL() {
        Jaj jaj = this.LJIJJ;
        if (jaj == null) {
            Jaj LIZ2 = Jaj.LIZ(this, "");
            this.LJIJJ = LIZ2;
            LIZ2.setIndeterminate(false);
        } else if (!jaj.isShowing()) {
            Jaj jaj2 = this.LJIJJ;
            jaj2.show();
            2fU.LIZ.LIZ(jaj2);
            this.LJIJJ.LIZ();
        }
    }

    public final void LJI() {
        TranslateAnimation translateAnimation = new TranslateAnimation(0.0f, 0.0f, (float) (-this.LJIIJJI.getHeight()), (float) (this.LJJII.getHeight() - 2ha.LIZ(20.0d)));
        translateAnimation.setDuration(2000);
        translateAnimation.setRepeatCount(-1);
        translateAnimation.setRepeatMode(1);
        translateAnimation.setFillAfter(false);
        translateAnimation.setInterpolator(new LinearInterpolator());
        this.LJIIJJI.startAnimation(translateAnimation);
    }

    /* JADX WARNING: type inference failed for: r4v0, types: [android.content.Context] */
    /* JADX WARNING: Multi-variable type inference failed */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LJII() {
        /*
            r9 = this;
            r2 = 564(0x234, float:7.9E-43)
            com.bytedance.frameworks.apm.trace.MethodCollector.i(r2)
            boolean r0 = r9.LJJIIJ
            if (r0 != 0) goto L_0x0036
            X.OPC r3 = new X.OPC
            android.widget.FrameLayout r0 = r9.LJJII
            int r0 = r0.getLeft()
            float r5 = (float) r0
            android.widget.FrameLayout r0 = r9.LJJII
            int r0 = r0.getTop()
            float r6 = (float) r0
            android.widget.FrameLayout r0 = r9.LJJII
            int r0 = r0.getRight()
            float r7 = (float) r0
            android.widget.FrameLayout r0 = r9.LJJII
            int r0 = r0.getBottom()
            float r8 = (float) r0
            r4 = r9
            r3.<init>(r4, r5, r6, r7, r8)
            r9.LJJIIJZLJL = r3
            android.widget.RelativeLayout r1 = r9.LJJIII
            r0 = 2
            r1.addView(r3, r0)
            r0 = 1
            r9.LJJIIJ = r0
        L_0x0036:
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r2)
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2.LJII():void");
    }

    /* JADX WARNING: type inference failed for: r3v0, types: [com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2, X.SNU, android.app.Activity] */
    public void onDestroy() {
        8gF.LJ(this);
        ScanQRCodeActivityV2.super.onDestroy();
        KAv.LIZIZ.LIZ("", 0);
        OPL opl = this.LJ;
        if (opl != null) {
            opl.LIZIZ();
        }
        F2D f2d = this.LJI;
        if (f2d != null) {
            f2d.LIZLLL();
            this.LJI.LIZJ = null;
        }
        this.LJ = null;
        0Gp.LIZ(new Callable<Object>() {
            static {
                Covode.recordClassIndex(102083);
            }

            public final Object call() {
                MethodCollector.i(804);
                if (ScanQRCodeActivityV2.this.LIZLLL != null) {
                    synchronized (ScanQRCodeActivityV2.this) {
                        try {
                            if (ScanQRCodeActivityV2.this.LIZLLL != null) {
                                ScanQRCodeActivityV2.this.LIZLLL.stop();
                                ScanQRCodeActivityV2.this.LIZLLL.release();
                                ScanQRCodeActivityV2.this.LIZLLL.setScanListener((IQRCodeScanner.OnEnigmaScanListener) null);
                                ScanQRCodeActivityV2.this.LIZLLL = null;
                            }
                        } finally {
                            MethodCollector.o(804);
                        }
                    }
                }
                return null;
            }
        });
        GestureDetector gestureDetector = this.LJIIL;
        if (gestureDetector != null) {
            gestureDetector.setOnDoubleTapListener((GestureDetector.OnDoubleTapListener) null);
        }
    }

    /* JADX WARNING: type inference failed for: r1v0, types: [com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2, X.SNU, android.app.Activity] */
    public void onStop() {
        8gF.LIZLLL(this);
        ScanQRCodeActivityV2.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: r9v0, types: [android.content.Context, com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2] */
    public final void LIZ() {
        if (this.LIZLLL == null) {
            LIZ((OPM) null);
        }
        final AVCameraParams aVCameraParams = new AVCameraParams(9EH.LJJIFFI.LIZ(), 1);
        final AVScanSettings aVScanSettings = new AVScanSettings();
        aVScanSettings.width = 1280;
        aVScanSettings.height = 720;
        float LIZIZ2 = (float) 3G1.LIZIZ(this);
        float LIZ2 = (float) 3G1.LIZ(this);
        if (9Y3.LIZ(9Y3.LIZ(), true, "scan_area_enlargement", 0) == 1) {
            aVScanSettings.detectRectLeft = 0.0f;
            aVScanSettings.detectRectTop = 0.0f;
            aVScanSettings.detectRectWidth = 1.0f;
            aVScanSettings.detectRectHeight = 1.0f;
        } else {
            aVScanSettings.detectRectLeft = this.LJJII.getX() / LIZIZ2;
            aVScanSettings.detectRectTop = this.LJJII.getY() / LIZ2;
            aVScanSettings.detectRectWidth = ((float) this.LJJII.getWidth()) / LIZIZ2;
            aVScanSettings.detectRectHeight = ((float) this.LJJII.getHeight()) / LIZ2;
        }
        aVScanSettings.detectRequirement = 65536;
        aVScanSettings.buildChainFlag = 1;
        aVScanSettings.enableDetectRect = true;
        0Gp.LIZ(new Callable<Object>() {
            static {
                Covode.recordClassIndex(102082);
            }

            /* JADX WARNING: type inference failed for: r3v0, types: [android.content.Context, com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2] */
            public final Object call() {
                MethodCollector.i(834);
                synchronized (ScanQRCodeActivityV2.this) {
                    try {
                        if (ScanQRCodeActivityV2.this.LIZLLL != null && ScanQRCodeActivityV2.this.LJIIIIZZ) {
                            IQRCodeScanner iQRCodeScanner = ScanQRCodeActivityV2.this.LIZLLL;
                            ? r3 = ScanQRCodeActivityV2.this;
                            iQRCodeScanner.startScan(r3, aVCameraParams, r3.LIZJ.getHolder(), aVScanSettings);
                        }
                    } catch (Throwable th) {
                        MethodCollector.o(834);
                        throw th;
                    }
                }
                MethodCollector.o(834);
                return null;
            }
        }, 0Gp.LIZ, (0Gf) null).LIZ(new 0Gi<Object, Object>() {
            static {
                Covode.recordClassIndex(102081);
            }

            public final Object then(0Gp<Object> r4) {
                MethodCollector.i(865);
                synchronized (ScanQRCodeActivityV2.this) {
                    try {
                        if (ScanQRCodeActivityV2.this.LIZLLL != null && !ScanQRCodeActivityV2.this.LJIIIIZZ) {
                            ScanQRCodeActivityV2.this.LIZLLL.stop();
                        }
                    } catch (Throwable th) {
                        MethodCollector.o(865);
                        throw th;
                    }
                }
                MethodCollector.o(865);
                return null;
            }
        }, 0Gp.LIZ, (0Gf) null).LIZ(new 0Gi<Object, Object>() {
            static {
                Covode.recordClassIndex(102080);
            }

            /* JADX WARNING: type inference failed for: r2v0, types: [android.content.Context, com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2] */
            /* JADX WARNING: type inference failed for: r2v1, types: [android.content.Context, com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2] */
            /* JADX WARNING: type inference failed for: r2v2, types: [android.content.Context, com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2] */
            public final Object then(0Gp<Object> r7) {
                ScanQRCodeActivityV2.this.LJIIL = new GestureDetector(ScanQRCodeActivityV2.this, new OPE(ScanQRCodeActivityV2.this, (byte) 0));
                ScanQRCodeActivityV2.this.LJIILIIL = new ScaleGestureDetector(ScanQRCodeActivityV2.this, new OPG(ScanQRCodeActivityV2.this, (byte) 0));
                ScanQRCodeActivityV2.this.LJIILJJIL = new GestureDetector(ScanQRCodeActivityV2.this, new OPD(ScanQRCodeActivityV2.this, (byte) 0));
                return null;
            }
        }, 0Gp.LIZIZ, (0Gf) null);
    }

    public final void LIZIZ(String str) {
        AVScanSettings aVScanSettings = new AVScanSettings();
        aVScanSettings.width = 1280;
        aVScanSettings.height = 720;
        aVScanSettings.buildChainFlag = 1;
        aVScanSettings.detectModelDir = "";
        this.LJII = true;
        this.LIZLLL.startPicScan(str, aVScanSettings, 1000);
    }

    public final void LIZ(int i) {
        SurfaceView surfaceView = this.LIZJ;
        if (surfaceView != null) {
            surfaceView.postDelayed(new OPH(this), (long) i);
        }
    }

    public void onConfigurationChanged(Configuration configuration) {
        ScanQRCodeActivityV2.super.onConfigurationChanged(configuration);
        OPC opc = this.LJJIIJZLJL;
        if (opc != null) {
            float left = (float) this.LJJII.getLeft();
            float top = (float) this.LJJII.getTop();
            float right = (float) this.LJJII.getRight();
            opc.LIZ = top;
            opc.LIZIZ = (float) this.LJJII.getBottom();
            opc.LIZJ = left;
            opc.LIZLLL = right;
            opc.invalidate();
        }
    }

    @ISm
    public void onNetStateChangeEvent(2IP r3) {
        if (!isDestroyed()) {
            if (2K7.LIZ.LIZJ()) {
                this.LJJI.setVisibility(8);
                this.LJIIJ = true;
                return;
            }
            this.LJJI.setVisibility(0);
            this.LJIIJ = false;
        }
    }

    public boolean onTouchEvent(MotionEvent motionEvent) {
        GestureDetector gestureDetector = this.LJIIL;
        if (gestureDetector != null && gestureDetector.onTouchEvent(motionEvent)) {
            return true;
        }
        GestureDetector gestureDetector2 = this.LJIILJJIL;
        if (gestureDetector2 != null && gestureDetector2.onTouchEvent(motionEvent)) {
            return true;
        }
        ScaleGestureDetector scaleGestureDetector = this.LJIILIIL;
        if (scaleGestureDetector == null || !scaleGestureDetector.onTouchEvent(motionEvent)) {
            return ScanQRCodeActivityV2.super.onTouchEvent(motionEvent);
        }
        return true;
    }

    /* JADX WARNING: type inference failed for: r4v0, types: [android.content.Context, com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2] */
    public final void LIZ(OPM opm) {
        this.LJIIIZ = false;
        AVExternalServiceImpl.LIZ().abilityService().cameraService().getScanner(true, this, this.LIZJ.getHolder(), new OPF(this, opm));
    }

    /* JADX WARNING: type inference failed for: r5v0, types: [com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2, X.1oX, X.SNU, android.app.Activity] */
    public void onClick(View view) {
        int id = view.getId();
        if (id == 2131372089) {
            if (this.LJJ) {
                LJIIJ();
                return;
            }
            IQRCodeScanner iQRCodeScanner = this.LIZLLL;
            if (iQRCodeScanner != null) {
                iQRCodeScanner.openLight();
            }
            this.LJJ = true;
            this.LJIL.setAlpha(1.0f);
            this.LJIL.setText(2131826604);
            Drawable drawable = getResources().getDrawable(2131233704);
            drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
            this.LJIL.setCompoundDrawables((Drawable) null, drawable, (Drawable) null, (Drawable) null);
        } else if (id == 2131372149 && !Cc1.LIZ(view, 1200)) {
            if (!46i.LJFF().isLogin()) {
                Lw4.LIZ(this, "scan", "click_my_qr", (Bundle) null, new OPJ(this));
            } else if (this.LJIJJLI) {
                finish();
            } else {
                LJIIIIZZ();
            }
        }
    }

    public final void LIZ(String str) {
        if (this.LIZLLL == null) {
            LIZ((OPM) new OPN(this, str));
        } else {
            LIZIZ(str);
        }
    }

    /* JADX WARNING: type inference failed for: r7v0, types: [X.NzO, android.widget.TextView] */
    public void onCreate(Bundle bundle) {
        String string;
        8gF.LIZ(this, bundle);
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2", "onCreate", true);
        4TL r1 = new 4TL((byte) 0);
        r1.LIZIZ = true;
        r1.LJI = 2130968611;
        r1.LJIIIIZZ = true;
        activityConfiguration(new SAl(r1));
        ScanQRCodeActivityV2.super.onCreate(bundle);
        setContentView(2131558514);
        this.LJIJJLI = getIntent().getBooleanExtra("enter_from", false);
        this.LIZ = getIntent().getIntExtra("scan_page_from", 0);
        this.LJIILLIIL = getIntent().getBooleanExtra("camera_only", false);
        this.LIZIZ = getIntent().getBooleanExtra("is_kill_self_after_scan", false);
        this.LJIJ = (TextView) findViewById(2131372149);
        OQL oql = (OQL) findViewById(2131371262);
        this.LJIJI = oql;
        oql.getBackBtn().setImageResource(2131232688);
        this.LJIIIIZZ = false;
        this.LIZJ = (SurfaceView) findViewById(2131370878);
        this.LJIL = (TextView) findViewById(2131372089);
        this.LJJI = (TextView) findViewById(2131371849);
        this.LJIIJJI = (ImageView) findViewById(2131369811);
        this.LJJIFFI = (TextView) findViewById(2131372238);
        this.LJJII = (FrameLayout) findViewById(2131365030);
        this.LJJIII = (RelativeLayout) findViewById(2131369741);
        OQL oql2 = this.LJIJI;
        M12.LIZ(oql2);
        oql2.getBackBtn().setImageResource(2131232367);
        this.LIZJ.getHolder().addCallback(new SurfaceHolder.Callback() {
            static {
                Covode.recordClassIndex(102078);
            }

            public final void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
            }

            public final void LIZ() {
                ScanQRCodeActivityV2.this.LIZLLL.enableCameraScan(true, 65536);
                ScanQRCodeActivityV2.this.LIZ();
                ScanQRCodeActivityV2.this.LJI();
                ScanQRCodeActivityV2.this.LJII();
            }

            public final void surfaceCreated(SurfaceHolder surfaceHolder) {
                MethodCollector.i(2290);
                synchronized (this) {
                    try {
                        ScanQRCodeActivityV2.this.LJIIIIZZ = true;
                    } catch (Throwable th) {
                        MethodCollector.o(2290);
                        throw th;
                    }
                }
                if (ScanQRCodeActivityV2.this.LIZLLL == null) {
                    ScanQRCodeActivityV2.this.LIZ((OPM) new OPO(this));
                    MethodCollector.o(2290);
                    return;
                }
                LIZ();
                MethodCollector.o(2290);
            }

            public final void surfaceDestroyed(SurfaceHolder surfaceHolder) {
                MethodCollector.i(2304);
                ScanQRCodeActivityV2.this.LJIIJJI.clearAnimation();
                synchronized (this) {
                    try {
                        ScanQRCodeActivityV2.this.LJIIIIZZ = false;
                    } finally {
                        MethodCollector.o(2304);
                    }
                }
                if (ScanQRCodeActivityV2.this.LIZLLL != null) {
                    synchronized (ScanQRCodeActivityV2.this) {
                        try {
                            if (ScanQRCodeActivityV2.this.LIZLLL != null) {
                                ScanQRCodeActivityV2.this.LIZLLL.stop();
                                ScanQRCodeActivityV2.this.LIZLLL.release();
                            }
                        } finally {
                            MethodCollector.o(2304);
                        }
                    }
                    return;
                }
                MethodCollector.o(2304);
            }
        });
        this.LJIJI.LJFF.setVisibility(8);
        ? endText = this.LJIJI.getEndText();
        endText.setTextColor(070.LIZJ(endText.getContext(), 2131099685));
        this.LJIJ.setOnClickListener(this);
        this.LJIJ.setText(getString(2131835050));
        this.LJIJI.setTitle((CharSequence) getString(2131831912));
        OQL oql3 = this.LJIJI;
        if (this.LJIILLIIL) {
            string = "";
        } else {
            string = getString(2131821475);
        }
        oql3.setEndText((CharSequence) string);
        this.LJIJI.setOnTitleBarClickListener(new OQO() {
            static {
                Covode.recordClassIndex(102079);
            }

            public final void LIZ(View view) {
                ScanQRCodeActivityV2.this.finish();
            }

            public final void LIZIZ(View view) {
                if (!ScanQRCodeActivityV2.this.LJIILLIIL) {
                    F2D f2d = ScanQRCodeActivityV2.this.LJI;
                    if (f2d.LIZIZ != null) {
                        f2d.LIZIZ.LIZ(2);
                    }
                }
            }
        });
        this.LJJIIZ = QrCodeScanImpl.LIZIZ();
        LIZ((OPM) null);
        LX6 lx6 = new LX6(this, this);
        this.LJFF = lx6;
        lx6.LIZ();
        this.LJ = this.LJFF;
        F2D f2d = new F2D();
        this.LJI = f2d;
        f2d.LIZJ = this;
        this.LJI.LIZIZ(this, (Fragment) null);
        this.LJIL.setOnClickListener(this);
        if (2K7.LIZ.LIZJ()) {
            this.LJJI.setVisibility(8);
            this.LJIIJ = true;
        } else {
            this.LJIIJ = false;
        }
        ActivityAgent.onTrace("com.ss.android.ugc.aweme.qrcode.view.ScanQRCodeActivityV2", "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) {
        Intent intent = new Intent(context, ScanQRCodeActivityV2.class);
        intent.putExtra("enter_from", z);
        LIZ(context, intent);
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        ScanQRCodeActivityV2.super.onActivityResult(i, i2, intent);
        F2D f2d = this.LJI;
        if (f2d != null) {
            f2d.LIZ(i, i2, intent);
        }
    }

    public static void LIZ(Context context, int i, boolean z) {
        Intent intent = new Intent(context, ScanQRCodeActivityV2.class);
        intent.putExtra("scan_page_from", i);
        intent.putExtra("camera_only", z);
        LIZ(context, intent);
    }
}
