package com.tencent.mm.plugin.mmsight.ui;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.ActivityManager;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.graphics.YuvImage;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.compatible.e.m;
import com.tencent.mm.compatible.e.q;
import com.tencent.mm.compatible.util.b;
import com.tencent.mm.g.a.mj;
import com.tencent.mm.graphics.MMBitmapFactory;
import com.tencent.mm.modelcontrol.VideoTransPara;
import com.tencent.mm.plugin.mmsight.SightCaptureResult;
import com.tencent.mm.plugin.mmsight.SightParams;
import com.tencent.mm.plugin.mmsight.model.CaptureMMProxy;
import com.tencent.mm.plugin.mmsight.model.a.d$a;
import com.tencent.mm.plugin.mmsight.model.a.k;
import com.tencent.mm.plugin.mmsight.model.c;
import com.tencent.mm.plugin.mmsight.model.e;
import com.tencent.mm.plugin.mmsight.model.i;
import com.tencent.mm.plugin.mmsight.model.j;
import com.tencent.mm.plugin.mmsight.ui.cameraglview.MMSightCameraGLSurfaceView;
import com.tencent.mm.plugin.report.service.h;
import com.tencent.mm.plugin.video.ObservableTextureView;
import com.tencent.mm.plugin.webview.ui.tools.widget.o;
import com.tencent.mm.pluginsdk.ui.tools.VideoPlayerTextureView;
import com.tencent.mm.protocal.protobuf.baa;
import com.tencent.mm.remoteservice.d;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.mm.sdk.platformtools.al;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.storage.ac;
import com.tencent.mm.ui.MMActivity;
import com.tencent.mm.ui.MMNewPhotoEditUI;
import com.tencent.mm.ui.ae;
import com.tencent.mm.ui.ak;
import com.tencent.mm.ui.base.a;
import com.tencent.smtt.sdk.TbsMediaPlayer$TbsMediaPlayerListener;
import com.tencent.ttpic.baseutils.IOUtils;
import com.tencent.ytcommon.BuildConfig;
import java.io.ByteArrayOutputStream;
import org.xwalk.core.XWalkFeature;

@a(3)
public class SightCaptureUI extends MMActivity implements d$a, c.a {
    private String cMW = BuildConfig.FLAVOR;
    private d ext = new d(ah.getContext());
    private VideoTransPara fcY;
    private ObservableTextureView gLR;
    private com.tencent.mm.plugin.mmsight.model.a.d gLs;
    private b gar;
    private int hGH = -1;
    private boolean hGI = false;
    private long hGJ = -1;
    private MMSightCaptureTouchView lmm;
    private View nPr;
    private TextView oCA;
    private View oCB;
    private b oCC;
    private boolean oCD = true;
    private baa oCE = new baa();
    private byte[] oCF;
    private int oCG;
    private int oCH;
    private int oCI;
    private int oCJ;
    private byte[] oCK;
    private int oCL;
    private c oCM;
    private boolean oCN = false;
    private boolean oCO = false;
    private boolean oCP = false;
    private int oCQ = 0;
    private int oCR = 0;
    private Thread oCS = null;
    private long oCT = -1;
    private boolean oCU = false;
    private boolean oCV = false;
    private Boolean oCW = Boolean.FALSE;
    private Point oCX;
    private com.tencent.mm.sdk.b.c oCY = new 12(this);
    private Runnable oCZ = new Runnable() {
        public final void run() {
            AppMethodBeat.i(55211);
            if (SightCaptureUI.this.hGH == 7 && SightCaptureUI.this.oCn != null) {
                ab.i("MicroMsg.SightCaptureUI", "showRecoderProgressBar");
                SightCaptureUI.this.oCn.bQs();
            }
            AppMethodBeat.o(55211);
        }
    };
    private int oCj = 1;
    private boolean oCk = true;
    private e oCl;
    private ViewGroup oCm;
    private MMSightRecordButton oCn;
    private View oCo;
    private View oCp;
    private ViewGroup oCq;
    private ViewGroup oCr;
    private ImageView oCs;
    private ImageView oCt;
    private SurfaceTexture oCu;
    CameraFrontSightView oCv;
    private ViewGroup oCw;
    private ImageView oCx;
    private MMSightCameraGLSurfaceView oCy;
    private com.tencent.mm.plugin.mmsight.ui.cameraglview.a oCz;
    private String oDa;
    private String oDb;
    private boolean oDc;
    private Bundle oDd;
    private Runnable oDe = new 19(this);
    private int osJ = 2;
    private SightParams owm;
    private VideoPlayerTextureView oxL;
    private VideoSeekBarEditorView oxM;
    private com.tencent.mm.pluginsdk.ui.tools.e.a oxS = new 20(this);

    public void onWindowFocusChanged(boolean z) {
        super.onWindowFocusChanged(z);
        AppMethodBeat.at(this, z);
    }

    public SightCaptureUI() {
        AppMethodBeat.i(55228);
        AppMethodBeat.o(55228);
    }

    static /* synthetic */ void B(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55269);
        sightCaptureUI.bQI();
        AppMethodBeat.o(55269);
    }

    static /* synthetic */ boolean J(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55273);
        boolean jb = sightCaptureUI.jb(false);
        AppMethodBeat.o(55273);
        return jb;
    }

    static /* synthetic */ void d(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55255);
        sightCaptureUI.bQA();
        AppMethodBeat.o(55255);
    }

    static /* synthetic */ void g(SightCaptureUI sightCaptureUI, int i) {
        AppMethodBeat.i(55271);
        sightCaptureUI.updateState(i);
        AppMethodBeat.o(55271);
    }

    static /* synthetic */ int m(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55258);
        int bQD = sightCaptureUI.bQD();
        AppMethodBeat.o(55258);
        return bQD;
    }

    static /* synthetic */ void r(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55262);
        sightCaptureUI.stopRecord();
        AppMethodBeat.o(55262);
    }

    static /* synthetic */ void s(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55263);
        sightCaptureUI.bQC();
        AppMethodBeat.o(55263);
    }

    static /* synthetic */ boolean w(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55267);
        boolean bQK = sightCaptureUI.bQK();
        AppMethodBeat.o(55267);
        return bQK;
    }

    static /* synthetic */ String zb(int i) {
        AppMethodBeat.i(55274);
        String za = za(i);
        AppMethodBeat.o(55274);
        return za;
    }

    public void onCreate(Bundle bundle) {
        AppMethodBeat.i(55229);
        supportRequestWindowFeature(1);
        super.onCreate(bundle);
        this.owm = (SightParams) getIntent().getParcelableExtra("KEY_SIGHT_PARAMS");
        if (this.owm == null) {
            ab.e("MicroMsg.SightCaptureUI", "error!!!! sightParams is null!!");
            AppMethodBeat.o(55229);
            return;
        }
        CaptureMMProxy.createProxy(new CaptureMMProxy(this.ext));
        this.ext.connect(new 1(this, bo.yz()));
        com.tencent.mm.sdk.b.a.xxA.c(this.oCY);
        AppMethodBeat.o(55229);
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        AppMethodBeat.i(55230);
        if (q.etc.eqV == 1 && i == TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_INFO_VIDEO_TRACK_LAGGING && this.oCD) {
            bQA();
        }
        boolean onKeyDown = super.onKeyDown(i, keyEvent);
        AppMethodBeat.o(55230);
        return onKeyDown;
    }

    public void onPause() {
        AppMethodBeat.i(55231);
        super.onPause();
        ab.i("MicroMsg.SightCaptureUI", "onPause, currentState: %s", new Object[]{za(this.hGH)});
        if (this.hGH == 2) {
            stopRecord();
        } else if (this.hGH == 1) {
            bQI();
        } else if (this.hGH == 4 && this.oxL != null) {
            this.oxL.pause();
        }
        o.JV(2);
        AppMethodBeat.o(55231);
    }

    public void onResume() {
        boolean z = false;
        AppMethodBeat.i(55232);
        super.onResume();
        Ne(8);
        String str = "MicroMsg.SightCaptureUI";
        String str2 = "onResume, currentState: %s, textureview available: %s";
        Object[] objArr = new Object[2];
        objArr[0] = za(this.hGH);
        if (this.gLR != null && this.gLR.isAvailable()) {
            z = true;
        }
        objArr[1] = Boolean.valueOf(z);
        ab.i(str, str2, objArr);
        if (this.hGH == 2 || this.hGH == 1) {
            bQC();
        } else if (this.hGH == 4) {
            if (this.gLR != null) {
                if (this.gLR.isAvailable()) {
                    this.oCz.WB();
                } else {
                    this.gLR.setTextureChangeCallback(new 21(this));
                }
            }
            if (this.oxL != null) {
                this.oxL.start();
            }
        } else if (this.hGH == 3) {
            if (this.gLR != null) {
                this.gLR.setTextureChangeCallback(null);
            }
            this.oCz.a(this.oCK, this.oCP, this.oCL);
        }
        o.JV(1);
        AppMethodBeat.o(55232);
    }

    public final int getForceOrientation() {
        return 1;
    }

    public void onConfigurationChanged(Configuration configuration) {
        AppMethodBeat.i(55233);
        super.onConfigurationChanged(configuration);
        if (this.oCW.booleanValue() && com.tencent.mm.compatible.util.d.iW(13)) {
            Point point = new Point(configuration.screenWidthDp, configuration.screenHeightDp);
            if (this.oCX == null || !this.oCX.equals(point)) {
                this.oCX = point;
                bQC();
            }
        }
        AppMethodBeat.o(55233);
    }

    private void bQA() {
        AppMethodBeat.i(55234);
        if (this.oCT <= 0 || bo.az(this.oCT) > 500) {
            ab.v("MicroMsg.TestCaptureUiEvent", "switchCameraClick %s, currentState: %s", new Object[]{bo.dpG().toString(), Integer.valueOf(this.hGH)});
            bQG();
            this.oCN = true;
            if (this.hGH == 2) {
                if (this.gLs == null || !this.gLs.WP()) {
                    ab.i("MicroMsg.SightCaptureUI", "switchCameraClick, not write camera data!");
                } else {
                    bQJ();
                    this.oCO = true;
                }
            } else if (this.hGH == 1) {
                updateState(6);
                if (jb(true)) {
                    updateState(1);
                }
            }
            bQH();
            this.oCT = bo.yz();
            AppMethodBeat.o(55234);
            return;
        }
        ab.i("MicroMsg.SightCaptureUI", "switchCameraClick, switch camera too frequently!!! ignore");
        AppMethodBeat.o(55234);
    }

    private void stopRecord() {
        AppMethodBeat.i(55235);
        ab.c("MicroMsg.SightCaptureUI", "stopRecord, currentStatus: %s", new Object[]{Integer.valueOf(this.hGH)});
        if (this.hGH == 2) {
            bQF();
        }
        AppMethodBeat.o(55235);
    }

    private void bQB() {
        AppMethodBeat.i(55236);
        try {
            LayoutParams layoutParams = this.oxL.getLayoutParams();
            this.oCq.removeView(this.oxL);
            this.oCq.addView(this.oxL, 0, layoutParams);
            AppMethodBeat.o(55236);
        } catch (Exception e) {
            ab.e("MicroMsg.SightCaptureUI", "clearVideoPlayViewContent, error: %s", new Object[]{e.getMessage()});
            AppMethodBeat.o(55236);
        }
    }

    private void bQC() {
        AppMethodBeat.i(55237);
        updateState(0);
        this.oCR = 0;
        this.hGI = false;
        this.oCV = false;
        if (this.oxL != null) {
            this.oxL.stop();
            this.oxL.setVideoCallback(null);
            bQB();
        }
        if (this.oCC != null) {
            this.oCC.release();
            this.oCC = null;
        }
        if (this.oCy != null) {
            this.oCy.setVisibility(0);
        }
        this.oCx.setImageBitmap(null);
        bQI();
        this.oCl = new e(this.fcY, this.owm.scene);
        this.oCl.a(this.oCz.fcA);
        if (this.oCl.v(this, this.oCD)) {
            if (this.gLR.isAvailable()) {
                this.oCu = this.gLR.getSurfaceTexture();
                ab.i("MicroMsg.SightCaptureUI", "surface already available, directly set local surface: %s", new Object[]{this.oCu});
                if (jb(false)) {
                    updateState(1);
                } else {
                    updateState(8);
                }
            } else {
                this.gLR.setTextureChangeCallback(new 8(this));
            }
            if (this.oCA != null && this.oCk) {
                this.oCA.setAlpha(1.0f);
                this.oCA.setVisibility(0);
            }
            this.oCM.reset();
            this.oCN = false;
            this.oCO = false;
            AppMethodBeat.o(55237);
            return;
        }
        updateState(8);
        AppMethodBeat.o(55237);
    }

    private boolean jb(boolean z) {
        AppMethodBeat.i(55238);
        ab.b("MicroMsg.SightCaptureUI", "createRecorder, surface: %s", new Object[]{this.oCu});
        this.oCV = false;
        if (this.gLs != null) {
            if (this.oCl != null) {
                this.oCl.b(this.gLs.getFrameDataCallback());
            }
            this.gLs.cancel();
        }
        if (this.oCl == null) {
            AppMethodBeat.o(55238);
            return false;
        }
        boolean a;
        this.oCE = new baa();
        this.oCE.wDP = true;
        this.oCE.wDO = j.ouz.ouO;
        if (this.owm != null) {
            this.oCE.wDR = this.owm.scene;
        }
        if (z) {
            a = this.oCl.a(this, this.oCu, true);
            this.oCD = this.oCl.bPv();
            if (!a) {
                AppMethodBeat.o(55238);
                return false;
            }
        } else if (this.oCl.a(this.oCu, true) < 0) {
            AppMethodBeat.o(55238);
            return false;
        }
        if (this.oCl.getEncodeVideoBestSize() == null) {
            AppMethodBeat.o(55238);
            return false;
        }
        k.bPR();
        this.gLs = k.p(this.fcY);
        if (this.gLs == null) {
            ab.e("MicroMsg.SightCaptureUI", "create mediaRecorder error");
            this.oCV = true;
            AppMethodBeat.o(55238);
            return false;
        }
        com.tencent.mm.plugin.mmsight.d.a(this.gLs, this.owm);
        this.gLs.a(this);
        this.oCl.a(this.gLs.getFrameDataCallback());
        if (this.oCz != null) {
            this.oCz.ab(this.oCl.getPreviewWidth(), this.oCl.getPreviewHeight(), this.oCl.getOrientation());
        }
        this.gLs.s(this.oCl.getPreviewWidth(), this.oCl.getPreviewHeight(), this.oCl.getEncodeVideoBestSize().x, this.oCl.getEncodeVideoBestSize().y);
        a = this.gLs.ko(this.oCl.getOrientation());
        ab.i("MicroMsg.SightCaptureUI", "preInit result: %s", new Object[]{Boolean.valueOf(a)});
        if (!a) {
            this.oCV = true;
        }
        AppMethodBeat.o(55238);
        return a;
    }

    private int bQD() {
        AppMethodBeat.i(55239);
        ab.i("MicroMsg.SightCaptureUI", "startRecordImpl");
        int b = this.gLs.b(this.oCl.getOrientation(), this.oCM.isLandscape(), this.oCM.getOrientation());
        ab.i("MicroMsg.SightCaptureUI", "startRecordImpl ret: %d", new Object[]{Integer.valueOf(b)});
        if (b >= 0) {
            this.oCl.a(e.a.ouj);
        }
        AppMethodBeat.o(55239);
        return b;
    }

    private void bQE() {
        AppMethodBeat.i(55240);
        this.oCV = true;
        updateState(8);
        if (this.gLs != null) {
            try {
                this.gLs.cancel();
                this.gLs = null;
                AppMethodBeat.o(55240);
                return;
            } catch (Exception e) {
                ab.printErrStackTrace("MicroMsg.SightCaptureUI", e, BuildConfig.FLAVOR, new Object[0]);
            }
        }
        AppMethodBeat.o(55240);
    }

    private void bQF() {
        AppMethodBeat.i(55241);
        updateState(7);
        this.oCn.setTouchEnable(false);
        this.gLs.v(new 10(this, this.oCl.getPreviewWidth(), this.oCl.getPreviewHeight()));
        AppMethodBeat.o(55241);
    }

    private void bQG() {
        AppMethodBeat.i(55242);
        k.bPR();
        if (k.isDebug()) {
            TextView textView = (TextView) findViewById(2131821713);
            textView.setVisibility(8);
            textView.setText(BuildConfig.FLAVOR);
            AppMethodBeat.o(55242);
            return;
        }
        AppMethodBeat.o(55242);
    }

    private void bQH() {
        AppMethodBeat.i(55243);
        k.bPR();
        if (k.isDebug()) {
            ab.i("MicroMsg.SightCaptureUI", "test for debug " + bo.dpG().toString());
            i.S(new 14(this));
            AppMethodBeat.o(55243);
            return;
        }
        AppMethodBeat.o(55243);
    }

    private String aU(String str, boolean z) {
        String RL;
        AppMethodBeat.i(55244);
        boolean z2 = CaptureMMProxy.getInstance().getBoolean(ac.a.xPU, true);
        boolean z3 = CaptureMMProxy.getInstance().getBoolean(ac.a.xPV, true);
        if (z) {
            RL = com.tencent.mm.plugin.mmsight.d.RL("jpg");
        } else {
            RL = com.tencent.mm.plugin.mmsight.d.RL("mp4");
        }
        if ((z2 && z) || (z3 && !z)) {
            ab.i("MicroMsg.SightCaptureUI", "auto save src %s dest %s state %s %s", new Object[]{str, RL, Boolean.valueOf(z2), Boolean.valueOf(z3)});
            com.tencent.mm.vfs.e.y(str, RL);
            com.tencent.mm.sdk.f.a.a(RL, this);
        }
        AppMethodBeat.o(55244);
        return RL;
    }

    private void bQI() {
        AppMethodBeat.i(55245);
        if (this.gLR != null) {
            this.gLR.setTextureChangeCallback(null);
        }
        if (this.oCl != null) {
            this.oCD = this.oCl.bPv();
            this.oCl.bPq();
            this.oCT = -1;
            this.hGJ = -1;
        }
        AppMethodBeat.o(55245);
    }

    private void bQJ() {
        AppMethodBeat.i(55246);
        String str = "MicroMsg.SightCaptureUI";
        String str2 = "switchCameraOnRecord, currentStatus: %s, mediaRecorder.status: %s";
        Object[] objArr = new Object[2];
        objArr[0] = Integer.valueOf(this.hGH);
        objArr[1] = this.gLs != null ? this.gLs.WL() : BuildConfig.FLAVOR;
        ab.i(str, str2, objArr);
        if (this.hGH == 2 && this.gLs != null && this.gLs.WL() == com.tencent.mm.plugin.mmsight.model.a.d.c.ovB) {
            this.gLs.pause();
            this.oCl.a(this, this.oCu, false);
            this.oCD = this.oCl.bPv();
            if (this.oCz != null) {
                this.oCz.ab(this.oCl.getPreviewWidth(), this.oCl.getPreviewHeight(), this.oCl.getOrientation());
            }
            if (this.gLs.WL() != com.tencent.mm.plugin.mmsight.model.a.d.c.ovJ) {
                ab.e("MicroMsg.SightCaptureUI", "switchCameraOnRecord, recorder status error: %s", new Object[]{this.gLs.WL()});
                AppMethodBeat.o(55246);
                return;
            }
            int previewWidth = this.oCl.getPreviewWidth();
            int previewHeight = this.oCl.getPreviewHeight();
            int orientation = this.oCl.getOrientation();
            Point WN = this.gLs.WN();
            ab.i("MicroMsg.SightCaptureUI", "switchCameraOnRecord, newPreviewSize: [%s, %s], oldPreviewSize: [%s], newOrientation: %s, oldOrientation: %s", new Object[]{Integer.valueOf(previewWidth), Integer.valueOf(previewHeight), WN, Integer.valueOf(orientation), Integer.valueOf(this.gLs.WO())});
            if (!(this.gLs.WO() == orientation && WN.x == previewWidth && WN.y == previewHeight)) {
                ab.e("MicroMsg.SightCaptureUI", "error oldOrientation! after switch, size or orientation not match");
            }
            this.gLs.s(this.oCl.getPreviewWidth(), this.oCl.getPreviewHeight(), this.oCl.getEncodeVideoBestSize().x, this.oCl.getEncodeVideoBestSize().y);
            this.gLs.G(orientation, this.oCl.getEncodeVideoBestSize().x, this.oCl.getEncodeVideoBestSize().y);
        }
        AppMethodBeat.o(55246);
    }

    public void onDestroy() {
        Object obj;
        AppMethodBeat.i(55247);
        super.onDestroy();
        ab.i("MicroMsg.SightCaptureUI", "onDestroy");
        this.ext.release();
        if (this.gLs != null) {
            this.gLs.a(null);
            this.gLs.v(null);
            this.gLs.clear();
        }
        if (this.hGH == -1) {
            obj = 1;
        } else {
            obj = null;
        }
        if (obj == null) {
            bQI();
            if (this.oxL != null) {
                this.oxL.stop();
                this.oxL.setVideoCallback(null);
            }
            if (this.gar != null) {
                this.gar.Mm();
            }
            if (this.oCC != null) {
                this.oCC.release();
                this.oCC = null;
            }
        }
        if (this.oCM != null) {
            this.oCM.disable();
            this.oCM.otK = null;
            this.oCM = null;
        }
        com.tencent.mm.plugin.mmsight.model.a.j.owk.WY();
        com.tencent.mm.sdk.b.a.xxA.d(this.oCY);
        AppMethodBeat.o(55247);
    }

    public final int getLayoutId() {
        return 2130968833;
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        AppMethodBeat.i(55248);
        super.onActivityResult(i, i2, intent);
        String str = "MicroMsg.SightCaptureUI";
        String str2 = "[onActivityResult] requestCode:%s  resultCode:%s data is null?:";
        Object[] objArr = new Object[3];
        objArr[0] = Integer.valueOf(i);
        objArr[1] = Integer.valueOf(i2);
        objArr[2] = Boolean.valueOf(intent == null);
        ab.i(str, str2, objArr);
        switch (i) {
            case 4369:
                ab.i("MicroMsg.SightCaptureUI", "[handlePhotoEditResult] resultCode:%s", new Object[]{Integer.valueOf(i2)});
                if (!(i2 != -1 || intent == null || this.gLs == null)) {
                    this.oDc = true;
                    this.oDd = intent.getBundleExtra("report_info");
                    this.oDa = intent.getStringExtra("raw_photo_path");
                    this.oDb = intent.getStringExtra("after_photo_edit");
                    ab.i("MicroMsg.SightCaptureUI", "rawEditPhotoPath:%s lastEditPhotoPath:%s imageState:%s", new Object[]{this.oDa, this.oDb, Boolean.valueOf(CaptureMMProxy.getInstance().getBoolean(ac.a.xPU, true))});
                    if (CaptureMMProxy.getInstance().getBoolean(ac.a.xPU, true)) {
                        this.gLs.mc(this.oDb);
                    } else {
                        String subCoreImageFullPath = CaptureMMProxy.getInstance().getSubCoreImageFullPath("photoEdited_" + System.currentTimeMillis());
                        ab.i("MicroMsg.SightCaptureUI", "saveFullPath:%s", new Object[]{subCoreImageFullPath});
                        com.tencent.mm.vfs.e.y(this.oDb, subCoreImageFullPath);
                        com.tencent.mm.vfs.e.deleteFile(this.oDb);
                        com.tencent.mm.sdk.f.a.a(this.oDb, this);
                        this.gLs.mc(subCoreImageFullPath);
                        this.oDb = subCoreImageFullPath;
                    }
                    Options options = new Options();
                    options.inJustDecodeBounds = true;
                    BitmapFactory.decodeFile(this.oDb, options);
                    ab.i("MicroMsg.SightCaptureUI", "rawW:%s rawH:%s", new Object[]{Integer.valueOf(options.outWidth), Integer.valueOf(options.outHeight)});
                    Bitmap ao = com.tencent.mm.sdk.platformtools.d.ao(this.oDb, options.outHeight, options.outWidth);
                    this.oCx.setVisibility(0);
                    this.oCx.setImageBitmap(ao);
                    this.oCy.setVisibility(8);
                    break;
                }
        }
        AppMethodBeat.o(55248);
    }

    private static String za(int i) {
        if (i == -1) {
            return "CAPTURE_STATE_BINGDING";
        }
        if (i == 0) {
            return "CAPTURE_STATE_INIT";
        }
        if (i == 1) {
            return "CAPTURE_STATE_CAPTURING";
        }
        if (i == 2) {
            return "CAPTURE_STATE_RECORDING";
        }
        if (i == 3) {
            return "CAPTURE_STATE_PREVIEW_PICTURE";
        }
        if (i == 4) {
            return "CAPTURE_STATE_PREVIEW_VIDEO";
        }
        if (i == 6) {
            return "CAPTURE_STATE_SUPERMAN";
        }
        if (i == 7) {
            return "CAPTURE_STATE_WAIT_TO_PREVIEW";
        }
        if (i == 8) {
            return "CAPTURE_STATE_INIT_ERROR";
        }
        if (i == 9) {
            return "CAPTURE_STATE_STOP_ERROR";
        }
        return "UNKNOW";
    }

    private void updateState(int i) {
        AppMethodBeat.i(55249);
        ab.i("MicroMsg.SightCaptureUI", "pre state %s %s update state %s %s", new Object[]{Integer.valueOf(this.hGH), za(this.hGH), Integer.valueOf(i), za(i)});
        ab.i("MicroMsg.TestCaptureUiEvent", "pre state %s %s update state %s %s %s", new Object[]{Integer.valueOf(this.hGH), za(this.hGH), Integer.valueOf(i), za(i), bo.dpG().toString()});
        if (i == this.hGH) {
            AppMethodBeat.o(55249);
        } else if (this.oCq == null) {
            AppMethodBeat.o(55249);
        } else {
            com.tencent.mm.plugin.mmsight.d.RM("TIME_RECODER_2_PLAY");
            this.hGH = i;
            if (this.hGH != 7) {
                al.af(this.oCZ);
            }
            if (this.hGH == 0) {
                this.oCq.setVisibility(8);
                this.oCt.setVisibility(8);
                this.oCr.setVisibility(8);
                this.oCx.setVisibility(8);
                this.oCw.setVisibility(0);
                if (this.oCQ > 1) {
                    this.oCs.setVisibility(0);
                }
                if (this.oCl != null) {
                    this.oCl.a(e.a.oui);
                }
                com.tencent.mm.plugin.mmsight.model.a.reset();
                if (this.oCS != null) {
                    try {
                        this.oCS.interrupt();
                    } catch (Exception e) {
                        ab.printErrStackTrace("MicroMsg.SightCaptureUI", e, "update to state init, interrupt failed: %s", new Object[]{e.getMessage()});
                    }
                    this.oCS = null;
                    AppMethodBeat.o(55249);
                    return;
                }
            } else if (this.hGH == 1 || this.hGH == 2) {
                this.oCq.setVisibility(0);
                this.oCt.setVisibility(8);
                this.oCr.setVisibility(0);
                this.oCr.setClipChildren(false);
                this.oCo.setVisibility(8);
                this.nPr.setVisibility(8);
                this.oCp.setVisibility(0);
                this.oCn.setVisibility(0);
                this.oxL.setVisibility(8);
                if (this.hGH == 1) {
                    this.oCn.reset();
                } else {
                    this.oCn.setTouchEnable(true);
                    this.oCn.bQt();
                }
                this.oCB.setVisibility(8);
                this.oCx.setVisibility(8);
                this.lmm.setVisibility(0);
                if (this.oCQ > 1) {
                    this.oCs.setVisibility(0);
                }
                this.lmm.bringToFront();
                this.oCs.bringToFront();
                bQG();
                bQH();
                AppMethodBeat.o(55249);
                return;
            } else if (this.hGH == 4 || this.hGH == 3) {
                this.oCq.setVisibility(0);
                this.oCr.setVisibility(8);
                this.oCr.setClipChildren(false);
                this.oCo.setVisibility(0);
                this.nPr.setVisibility(0);
                this.oCp.setVisibility(8);
                this.oCn.setVisibility(8);
                if (this.hGH == 3) {
                    this.oCt.setVisibility(0);
                    this.oCx.setVisibility(0);
                    this.oxL.setVisibility(8);
                } else {
                    this.oCx.setVisibility(8);
                    this.oxL.setVisibility(0);
                    this.oxL.setForceScaleFullScreen(true);
                    LayoutParams layoutParams = this.oxL.getLayoutParams();
                    layoutParams.width = -1;
                    layoutParams.height = -1;
                    this.oxL.setLayoutParams(layoutParams);
                    if (this.gLs.isLandscape()) {
                        this.oCz.WB();
                    }
                    this.oCw.setVisibility(8);
                }
                this.lmm.setVisibility(8);
                AppMethodBeat.o(55249);
                return;
            } else if (this.hGH == 6) {
                this.oCo.setVisibility(8);
                this.nPr.setVisibility(8);
                this.oCt.setVisibility(8);
                this.oCp.setVisibility(8);
                this.oCn.setVisibility(8);
                AppMethodBeat.o(55249);
                return;
            } else if (this.hGH == 7) {
                this.oCo.setVisibility(8);
                this.nPr.setVisibility(8);
                this.oCp.setVisibility(8);
                this.oCs.setVisibility(8);
                this.oCt.setVisibility(8);
                this.oCn.setTouchEnable(false);
                al.n(this.oCZ, 1500);
                this.oCn.bgk();
                AppMethodBeat.o(55249);
                return;
            } else if (this.hGH == 8) {
                this.oCq.setVisibility(0);
                this.oCr.setVisibility(0);
                this.oCr.setClipChildren(false);
                this.oCo.setVisibility(8);
                this.nPr.setVisibility(8);
                this.oCt.setVisibility(8);
                this.oCp.setVisibility(0);
                if (this.oCQ > 1) {
                    this.oCs.setVisibility(0);
                }
                this.oCn.setVisibility(0);
                this.lmm.setVisibility(0);
                this.oxL.setVisibility(8);
                this.oCB.setVisibility(8);
                this.oCx.setVisibility(8);
                if (this.oCV) {
                    Toast.makeText(this, 2131301440, 1).show();
                } else {
                    Toast.makeText(this, 2131301445, 1).show();
                }
                this.oCn.setTouchEnable(false);
                this.oCn.setEnabled(false);
                AppMethodBeat.o(55249);
                return;
            } else if (this.hGH == 9) {
                this.oCo.setVisibility(8);
                this.nPr.setVisibility(8);
                this.oCt.setVisibility(8);
                this.oCp.setVisibility(0);
                this.oCs.setVisibility(8);
                this.oCn.reset();
                this.oCn.setTouchEnable(false);
                this.oCn.setEnabled(false);
                Toast.makeText(this, 2131301441, 1).show();
            }
            AppMethodBeat.o(55249);
        }
    }

    private void jc(boolean z) {
        AppMethodBeat.i(55250);
        ab.i("MicroMsg.SightCaptureUI", "[clearPhotoEditCache] isDelete:%s mLastEditPhotoPath:%s mRawEditPhotoPath:%s", new Object[]{Boolean.valueOf(z), this.oDb, this.oDa});
        if (!bo.isNullOrNil(this.oDb) && z) {
            com.tencent.mm.vfs.e.deleteFile(this.oDb);
        }
        if (!bo.isNullOrNil(this.oDa)) {
            com.tencent.mm.vfs.e.deleteFile(this.oDa);
        }
        this.oDb = null;
        this.oDa = null;
        mj mjVar = new mj();
        mjVar.cIo.cuy = 0;
        com.tencent.mm.sdk.b.a.xxA.m(mjVar);
        AppMethodBeat.o(55250);
    }

    public void onBackPressed() {
        AppMethodBeat.i(55251);
        ab.i("MicroMsg.SightCaptureUI", "onBackPressed %d", new Object[]{Integer.valueOf(this.hGH)});
        if (this.oCC != null && this.oCC.wY()) {
            AppMethodBeat.o(55251);
        } else if (this.oCC != null) {
            this.oCC.release();
            this.oCC = null;
            Ne(8);
            this.oCo.setVisibility(0);
            this.nPr.setVisibility(0);
            this.oCt.setVisibility(0);
            AppMethodBeat.o(55251);
        } else {
            if (bQK()) {
                super.onBackPressed();
                overridePendingTransition(-1, 2131034259);
                jc(true);
            }
            AppMethodBeat.o(55251);
        }
    }

    private boolean bQK() {
        return this.hGH == 4 || this.hGH == 3 || this.hGH == 1 || this.hGH == 8 || this.hGH == 9;
    }

    public final void yR(int i) {
        AppMethodBeat.i(55252);
        if (this.oCQ <= 1) {
            AppMethodBeat.o(55252);
        } else if (this.hGH == 2) {
            AppMethodBeat.o(55252);
        } else {
            ab.i("MicroMsg.SightCaptureUI", "onOrientationChange: %s", new Object[]{Integer.valueOf(i)});
            if (i < 0) {
                AppMethodBeat.o(55252);
                return;
            }
            float f;
            if (i != 90 && i != 270) {
                f = (float) i;
            } else if (i == 270) {
                f = 90.0f;
            } else {
                f = -90.0f;
            }
            if (this.oCs.getRotation() == f) {
                AppMethodBeat.o(55252);
                return;
            }
            this.oCs.animate().rotation(f).setDuration(100).start();
            AppMethodBeat.o(55252);
        }
    }

    public final void asv() {
        AppMethodBeat.i(55253);
        ab.i("MicroMsg.SightCaptureUI", "onError: %s", new Object[]{Integer.valueOf(1)});
        try {
            if (this.gLs != null) {
                this.gLs.reset();
            }
        } catch (Exception e) {
            ab.e("MicroMsg.SightCaptureUI", "onError, reset mediaRecorder error: %s", new Object[]{e.getMessage()});
        }
        updateState(9);
        AppMethodBeat.o(55253);
    }

    static /* synthetic */ void b(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55254);
        sightCaptureUI.dyg();
        sightCaptureUI.Ne(8);
        if (sightCaptureUI.owm == null) {
            ab.e("MicroMsg.SightCaptureUI", "sightParams error!");
            AppMethodBeat.o(55254);
            return;
        }
        sightCaptureUI.oCQ = com.tencent.mm.compatible.e.d.getNumberOfCameras();
        ab.i("MicroMsg.SightCaptureUI", "initOnCreate, numCamera: %s", new Object[]{Integer.valueOf(sightCaptureUI.oCQ)});
        sightCaptureUI.gar = new b(sightCaptureUI);
        sightCaptureUI.oCk = sightCaptureUI.owm.osP;
        sightCaptureUI.osJ = sightCaptureUI.owm.osJ;
        sightCaptureUI.oCD = sightCaptureUI.osJ == 2;
        k.bPR().owm = sightCaptureUI.owm;
        sightCaptureUI.oCj = sightCaptureUI.owm.mode;
        ab.i("MicroMsg.SightCaptureUI", "SightCaptureUI onCreate, captureMode: %s, showHint: %s, defaultCamera: %s, scene: %s", new Object[]{Integer.valueOf(sightCaptureUI.oCj), Boolean.valueOf(sightCaptureUI.oCk), Integer.valueOf(sightCaptureUI.osJ), Integer.valueOf(sightCaptureUI.owm.scene)});
        sightCaptureUI.fcY = sightCaptureUI.owm.fcY;
        if (sightCaptureUI.fcY == null) {
            ab.e("MicroMsg.SightCaptureUI", "SightCaptureUI onCreate, cannot get videoParams");
            AppMethodBeat.o(55254);
            return;
        }
        ab.i("MicroMsg.SightCaptureUI", "SightCaptureUI onCreate, videoParams: %s", new Object[]{sightCaptureUI.fcY});
        sightCaptureUI.getWindow().addFlags(2097280);
        if (com.tencent.mm.compatible.util.d.iW(19)) {
            sightCaptureUI.getWindow().setFlags(201327616, 201327616);
            com.tencent.mm.plugin.mmsight.d.iV(true);
        } else {
            sightCaptureUI.getWindow().setFlags(1024, 1024);
            com.tencent.mm.plugin.mmsight.d.iV(false);
        }
        if (VERSION.SDK_INT >= 21) {
            sightCaptureUI.getWindow().addFlags(67108864);
        }
        sightCaptureUI.oCM = new c(sightCaptureUI);
        sightCaptureUI.oCM.otK = sightCaptureUI;
        sightCaptureUI.oCM.enable();
        sightCaptureUI.oCm = (ViewGroup) sightCaptureUI.findViewById(2131820987);
        sightCaptureUI.oCq = (ViewGroup) sightCaptureUI.findViewById(2131821708);
        sightCaptureUI.oCr = (ViewGroup) sightCaptureUI.findViewById(2131821720);
        sightCaptureUI.oCv = (CameraFrontSightView) sightCaptureUI.findViewById(2131821707);
        sightCaptureUI.gLR = (ObservableTextureView) sightCaptureUI.findViewById(2131821723);
        sightCaptureUI.oCn = (MMSightRecordButton) sightCaptureUI.findViewById(2131821721);
        sightCaptureUI.oCo = sightCaptureUI.findViewById(2131821715);
        sightCaptureUI.nPr = sightCaptureUI.findViewById(2131821716);
        sightCaptureUI.oCp = sightCaptureUI.findViewById(2131821714);
        sightCaptureUI.oCw = (ViewGroup) sightCaptureUI.findViewById(2131821705);
        sightCaptureUI.oCA = (TextView) sightCaptureUI.findViewById(2131821722);
        if (sightCaptureUI.oCj == 2) {
            sightCaptureUI.oCA.setText(2131301443);
        } else if (sightCaptureUI.oCj == 1) {
            sightCaptureUI.oCA.setText(2131301444);
        } else if (sightCaptureUI.oCj == 0) {
            sightCaptureUI.oCA.setText(2131301442);
        }
        sightCaptureUI.oxL = (VideoPlayerTextureView) sightCaptureUI.findViewById(2131821710);
        sightCaptureUI.oCs = (ImageView) sightCaptureUI.findViewById(2131821719);
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) sightCaptureUI.oCs.getLayoutParams();
        int i = layoutParams.topMargin;
        if (ae.hD(sightCaptureUI.mController.ylL)) {
            i += ae.hC(sightCaptureUI.mController.ylL);
        }
        layoutParams.setMargins(layoutParams.leftMargin, i, layoutParams.rightMargin, layoutParams.bottomMargin);
        sightCaptureUI.oCs.setLayoutParams(layoutParams);
        sightCaptureUI.oCt = (ImageView) sightCaptureUI.findViewById(2131821712);
        sightCaptureUI.oCt.setOnClickListener(new 22(sightCaptureUI));
        sightCaptureUI.oCx = (ImageView) sightCaptureUI.findViewById(2131821711);
        sightCaptureUI.oCy = (MMSightCameraGLSurfaceView) sightCaptureUI.findViewById(2131821706);
        sightCaptureUI.lmm = (MMSightCaptureTouchView) sightCaptureUI.findViewById(2131821718);
        sightCaptureUI.oCB = sightCaptureUI.findViewById(2131821709);
        sightCaptureUI.oCz = new com.tencent.mm.plugin.mmsight.ui.cameraglview.a(sightCaptureUI.oCy);
        if (sightCaptureUI.oCk) {
            sightCaptureUI.oCA.setVisibility(0);
        } else {
            sightCaptureUI.oCA.setVisibility(8);
        }
        int fromDPToPix = com.tencent.mm.bz.a.fromDPToPix(sightCaptureUI.mController.ylL, 120);
        sightCaptureUI.oCv.ez(fromDPToPix, fromDPToPix);
        if (com.tencent.mm.compatible.util.d.iW(19)) {
            i = Math.max(ak.fr(sightCaptureUI), ak.hx(sightCaptureUI));
            MarginLayoutParams marginLayoutParams = (MarginLayoutParams) sightCaptureUI.oCn.getLayoutParams();
            marginLayoutParams.bottomMargin += i;
            sightCaptureUI.oCn.setLayoutParams(marginLayoutParams);
            marginLayoutParams = (MarginLayoutParams) sightCaptureUI.oCp.getLayoutParams();
            marginLayoutParams.bottomMargin += i;
            sightCaptureUI.oCp.setLayoutParams(marginLayoutParams);
            marginLayoutParams = (MarginLayoutParams) sightCaptureUI.oCo.getLayoutParams();
            marginLayoutParams.bottomMargin += i;
            sightCaptureUI.oCo.setLayoutParams(marginLayoutParams);
            marginLayoutParams = (MarginLayoutParams) sightCaptureUI.oCt.getLayoutParams();
            marginLayoutParams.bottomMargin += i;
            sightCaptureUI.oCt.setLayoutParams(marginLayoutParams);
            marginLayoutParams = (MarginLayoutParams) sightCaptureUI.nPr.getLayoutParams();
            marginLayoutParams.bottomMargin = i + marginLayoutParams.bottomMargin;
            sightCaptureUI.nPr.setLayoutParams(marginLayoutParams);
        }
        if (sightCaptureUI.oCj == 1 || sightCaptureUI.oCj == 0) {
            sightCaptureUI.oCn.setLongPressCallback(new 23(sightCaptureUI));
            sightCaptureUI.oCn.setErrorPressCallback(new 24(sightCaptureUI));
            sightCaptureUI.oCn.setLongPressScrollCallback(new 25(sightCaptureUI));
        }
        if (sightCaptureUI.oCj == 0 || sightCaptureUI.oCj == 2) {
            sightCaptureUI.oCn.setSimpleTapCallback(new 26(sightCaptureUI));
        }
        if (sightCaptureUI.oCQ > 1) {
            sightCaptureUI.oCs.setOnClickListener(new 27(sightCaptureUI));
        } else {
            sightCaptureUI.oCs.setVisibility(8);
        }
        sightCaptureUI.nPr.setOnClickListener(new 2(sightCaptureUI));
        sightCaptureUI.oCo.setOnClickListener(new 3(sightCaptureUI));
        sightCaptureUI.oCp.setOnClickListener(new 4(sightCaptureUI));
        sightCaptureUI.lmm.setTouchCallback(new 5(sightCaptureUI));
        sightCaptureUI.updateState(0);
        sightCaptureUI.bQC();
        sightCaptureUI.oCW = Boolean.TRUE;
        AppMethodBeat.o(55254);
    }

    static /* synthetic */ void h(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55256);
        ab.i("MicroMsg.SightCaptureUI", "[gotoPhotoEditUI]");
        if (sightCaptureUI.gLs == null) {
            ab.e("MicroMsg.SightCaptureUI", "mediaRecorder == NULL");
            AppMethodBeat.o(55256);
            return;
        }
        String stringExtra = sightCaptureUI.getIntent().getStringExtra("GalleryUI_FromUser");
        String stringExtra2 = sightCaptureUI.getIntent().getStringExtra("GalleryUI_ToUser");
        Intent intent = new Intent();
        intent.putExtra("GalleryUI_FromUser", stringExtra);
        intent.putExtra("GalleryUI_ToUser", stringExtra2);
        if (sightCaptureUI.owm.scene == 1) {
            intent.putExtra("from_scene", 290);
        } else if (sightCaptureUI.owm.scene == 2) {
            intent.putExtra("from_scene", 289);
        }
        intent.putExtra("raw_photo_path", bo.isNullOrNil(sightCaptureUI.oDa) ? sightCaptureUI.gLs.WI() : sightCaptureUI.oDa);
        intent.putExtra("after_photo_edit", sightCaptureUI.oDb);
        intent.setClass(sightCaptureUI, MMNewPhotoEditUI.class);
        sightCaptureUI.startActivityForResult(intent, 4369);
        AppMethodBeat.o(55256);
    }

    static /* synthetic */ void i(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55257);
        if (ak.hw(sightCaptureUI)) {
            sightCaptureUI.Ne(0);
        }
        sightCaptureUI.oxM = (VideoSeekBarEditorView) sightCaptureUI.findViewById(2131821717);
        if (ak.hw(sightCaptureUI)) {
            MarginLayoutParams marginLayoutParams = (MarginLayoutParams) sightCaptureUI.oxM.getLayoutParams();
            marginLayoutParams.bottomMargin = Math.max(ak.fr(sightCaptureUI), ak.hx(sightCaptureUI));
            sightCaptureUI.oxM.setLayoutParams(marginLayoutParams);
        }
        sightCaptureUI.oCC = new b();
        sightCaptureUI.oCC.oBR = 2;
        sightCaptureUI.oCC.oBN = true;
        sightCaptureUI.oCC.a(sightCaptureUI, sightCaptureUI.owm.scene, sightCaptureUI.gLs.getFilePath(), sightCaptureUI.oxM, sightCaptureUI.oxL, sightCaptureUI.oCq, sightCaptureUI.fcY, false);
        sightCaptureUI.oCC.oBL = new b.a() {
            public final void bQf() {
                AppMethodBeat.i(55204);
                ab.i("MicroMsg.SightCaptureUI", "on video edit finish");
                if (SightCaptureUI.this.oCC != null) {
                    SightCaptureUI.this.cMW = bo.bc(SightCaptureUI.this.oCC.cvZ, BuildConfig.FLAVOR);
                    SightCaptureUI.this.oCC.n(false, SightCaptureUI.this.owm.osR);
                    SightCaptureUI.this.oCC.release();
                    SightCaptureUI.this.oCC = null;
                }
                SightCaptureUI.this.oCo.setVisibility(0);
                SightCaptureUI.this.nPr.setVisibility(0);
                SightCaptureUI.this.oCt.setVisibility(0);
                SightCaptureUI.this.oxL.stop();
                SightCaptureUI.this.oxL.setVideoPath(SightCaptureUI.this.gLs.getFilePath());
                SightCaptureUI.this.oxL.setLoop(true);
                SightCaptureUI.this.oxL.setForceScaleFullScreen(true);
                SightCaptureUI.this.oxL.setVideoCallback(SightCaptureUI.this.oxS);
                SightCaptureUI.this.Ne(8);
                com.tencent.mm.sdk.g.d.post(new 1(this), "SightCaptureUI_edit_finish_save_new_thumb");
                SightCaptureUI.this.oCU = true;
                AppMethodBeat.o(55204);
            }

            public final void bQg() {
                AppMethodBeat.i(55205);
                ab.i("MicroMsg.SightCaptureUI", "on video edit exit");
                if (SightCaptureUI.this.oCC != null) {
                    SightCaptureUI.this.oCC.n(true, SightCaptureUI.this.owm.osR);
                    SightCaptureUI.this.oCC.release();
                    SightCaptureUI.this.oCC = null;
                }
                SightCaptureUI.this.Ne(8);
                SightCaptureUI.this.oCo.setVisibility(0);
                SightCaptureUI.this.nPr.setVisibility(0);
                SightCaptureUI.this.oCt.setVisibility(0);
                AppMethodBeat.o(55205);
            }

            public final void onError() {
                AppMethodBeat.i(55206);
                ab.i("MicroMsg.SightCaptureUI", "on video edit error");
                if (SightCaptureUI.this.oCC != null) {
                    SightCaptureUI.this.oCC.release();
                    SightCaptureUI.this.oCC = null;
                }
                al.d(new 2(this));
                AppMethodBeat.o(55206);
            }
        };
        sightCaptureUI.oCo.setVisibility(8);
        sightCaptureUI.nPr.setVisibility(8);
        sightCaptureUI.oCt.setVisibility(8);
        AppMethodBeat.o(55257);
    }

    static /* synthetic */ void n(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55259);
        if (sightCaptureUI.oCA != null && sightCaptureUI.oCk) {
            sightCaptureUI.oCA.animate().alpha(0.0f).setDuration(100).setListener(new 7(sightCaptureUI)).start();
        }
        AppMethodBeat.o(55259);
    }

    static /* synthetic */ void o(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55260);
        if (sightCaptureUI.gLs != null) {
            ab.v("MicroMsg.TestCaptureUiEvent", "startRecord, mediaRecorder.status: %s, %s", new Object[]{sightCaptureUI.gLs.WL(), bo.dpG().toString()});
            sightCaptureUI.updateState(6);
            if (sightCaptureUI.gLs.WL() == com.tencent.mm.plugin.mmsight.model.a.d.c.ovE) {
                sightCaptureUI.oCR = sightCaptureUI.bQD();
                if (sightCaptureUI.oCR < 0) {
                    sightCaptureUI.bQE();
                    AppMethodBeat.o(55260);
                    return;
                }
            } else if (sightCaptureUI.oCR < 0) {
                sightCaptureUI.bQE();
                AppMethodBeat.o(55260);
                return;
            }
            sightCaptureUI.updateState(2);
            if (sightCaptureUI.oCl != null) {
                sightCaptureUI.oCl.bPm();
            }
            sightCaptureUI.oCn.a((sightCaptureUI.fcY.duration * XWalkFeature.INTERFACE_GEO_LOCATION_PERMISSION) - 500, 0, new 9(sightCaptureUI));
        }
        AppMethodBeat.o(55260);
    }

    static /* synthetic */ void q(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55261);
        if (!(sightCaptureUI.oCl == null || !sightCaptureUI.oCl.bPu() || sightCaptureUI.oCM == null || sightCaptureUI.hGI || (sightCaptureUI.hGJ >= 0 && bo.az(sightCaptureUI.hGJ) > 300))) {
            sightCaptureUI.hGI = true;
            if (sightCaptureUI.oCA != null && sightCaptureUI.oCk) {
                sightCaptureUI.oCA.setVisibility(8);
            }
            sightCaptureUI.updateState(7);
            sightCaptureUI.oCn.setTouchEnable(false);
            sightCaptureUI.oCP = sightCaptureUI.oCM.isLandscape();
            sightCaptureUI.oCK = null;
            sightCaptureUI.oCL = -1;
            sightCaptureUI.oCl.a(new 6(sightCaptureUI), sightCaptureUI.oCP, sightCaptureUI.oCM.getOrientation());
            sightCaptureUI.hGJ = bo.yz();
        }
        AppMethodBeat.o(55261);
    }

    static /* synthetic */ void t(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55264);
        if (sightCaptureUI.owm.scene == 1 || sightCaptureUI.owm.scene == 2 || sightCaptureUI.owm.scene == 7) {
            int i = sightCaptureUI.oCN ? sightCaptureUI.oCO ? 2 : 1 : 0;
            h.pYm.e(13820, new Object[]{Integer.valueOf(i), Integer.valueOf(sightCaptureUI.owm.scene), sightCaptureUI.owm.osR, Long.valueOf(bo.anT())});
        }
        if (sightCaptureUI.owm != null && sightCaptureUI.oCU) {
            com.tencent.mm.plugin.mmsight.a.a.a(new com.tencent.mm.plugin.mmsight.a.a.a(sightCaptureUI.owm.scene));
        }
        Intent intent = new Intent();
        String filePath = sightCaptureUI.gLs.getFilePath();
        String WO = com.tencent.mm.plugin.sight.base.d.WO(filePath);
        if (sightCaptureUI.owm.osQ) {
            sightCaptureUI.aU(filePath, false);
        }
        if (com.tencent.mm.plugin.mmsight.model.a.bPi() != null) {
            sightCaptureUI.oCE.wDS = com.tencent.mm.plugin.mmsight.model.a.bPi().bPj();
        }
        int WM = sightCaptureUI.gLs.WM();
        if (sightCaptureUI.oCU) {
            com.tencent.mm.plugin.sight.base.a WR = com.tencent.mm.plugin.sight.base.d.WR(sightCaptureUI.gLs.getFilePath());
            if (WR != null) {
                WM = Math.round(((float) WR.eWK) / 1000.0f);
            }
        }
        intent.putExtra("key_req_result", new SightCaptureResult(sightCaptureUI.oCl.bPv(), filePath, WO, sightCaptureUI.gLs.getFileName(), sightCaptureUI.cMW, WM, sightCaptureUI.oCE));
        intent.putExtra("KSessionID", sightCaptureUI.owm.osR);
        intent.putExtra("latitude", sightCaptureUI.getIntent().getDoubleExtra("album_business_bubble_media_by_coordinate_latitude", 181.0d));
        intent.putExtra("longitude", sightCaptureUI.getIntent().getDoubleExtra("album_business_bubble_media_by_coordinate_longitude", 91.0d));
        sightCaptureUI.setResult(-1, intent);
        sightCaptureUI.finish();
        AppMethodBeat.o(55264);
    }

    static /* synthetic */ void u(SightCaptureUI sightCaptureUI) {
        Object obj;
        AppMethodBeat.i(55265);
        if (sightCaptureUI.oCS != null && sightCaptureUI.oCS.isAlive()) {
            try {
                sightCaptureUI.oCS.join();
            } catch (Exception e) {
                ab.printErrStackTrace("MicroMsg.SightCaptureUI", e, "wait saveCaptureImageThread error: %s", new Object[]{e.getMessage()});
            }
        }
        if (sightCaptureUI.owm.scene == 1 || sightCaptureUI.owm.scene == 2 || sightCaptureUI.owm.scene == 7) {
            int i = 0;
            if (sightCaptureUI.oCN) {
                i = 1;
            }
            h.pYm.e(13820, new Object[]{Integer.valueOf(i), Integer.valueOf(sightCaptureUI.owm.scene), sightCaptureUI.owm.osR, Long.valueOf(bo.anT())});
        }
        if (sightCaptureUI.owm.scene == 1) {
            h.pYm.e(13858, new Object[]{Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(0)});
        } else if (sightCaptureUI.owm.scene == 2) {
            h.pYm.e(13858, new Object[]{Integer.valueOf(2), Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(0)});
        }
        Intent intent = new Intent();
        if (bo.isNullOrNil(sightCaptureUI.oDb) || sightCaptureUI.gLs == null || !sightCaptureUI.oDb.equals(sightCaptureUI.gLs.WI())) {
            obj = null;
        } else {
            obj = 1;
        }
        if (obj == null && sightCaptureUI.owm.osQ) {
            ab.i("MicroMsg.SightCaptureUI", "is not Photo editted!");
            sightCaptureUI.aU(sightCaptureUI.gLs.WI(), true);
        }
        intent.putExtra("key_req_result", new SightCaptureResult(sightCaptureUI.oCl.bPv(), sightCaptureUI.gLs.WI()));
        intent.putExtra("KSessionID", sightCaptureUI.owm.osR);
        intent.putExtra("latitude", sightCaptureUI.getIntent().getDoubleExtra("album_business_bubble_media_by_coordinate_latitude", 181.0d));
        intent.putExtra("longitude", sightCaptureUI.getIntent().getDoubleExtra("album_business_bubble_media_by_coordinate_longitude", 91.0d));
        sightCaptureUI.setResult(-1, intent);
        Bundle bundle = sightCaptureUI.oDd;
        if (bundle == null) {
            ab.e("MicroMsg.SightCaptureUI", "[reportPhotoEdit] date == null");
        } else if (sightCaptureUI.oDc) {
            int i2 = bundle.getInt("report_info_emotion_count");
            int i3 = bundle.getInt("report_info_text_count");
            int i4 = bundle.getInt("report_info_mosaic_count");
            int i5 = bundle.getInt("report_info_doodle_count");
            boolean z = bundle.getBoolean("report_info_iscrop");
            int i6 = bundle.getInt("report_info_undo_count");
            boolean z2 = bundle.getBoolean("report_info_is_rotation");
            String str = "MicroMsg.SightCaptureUI";
            String str2 = "[reportPhotoEdit] emojiCount:%s,textCount:%s,mosaicCount:%s,penCount:%s,isCrop:%s,undoCount:%s,isRotation:%s";
            Object[] objArr = new Object[7];
            objArr[0] = Integer.valueOf(i2);
            objArr[1] = Integer.valueOf(i3);
            objArr[2] = Integer.valueOf(i4);
            objArr[3] = Integer.valueOf(i5);
            objArr[4] = Integer.valueOf(z ? 1 : 0);
            objArr[5] = Integer.valueOf(i6);
            objArr[6] = Boolean.valueOf(z2);
            ab.i(str, str2, objArr);
            h hVar = h.pYm;
            objArr = new Object[12];
            objArr[0] = Integer.valueOf(1);
            objArr[1] = Integer.valueOf(1);
            objArr[2] = Integer.valueOf(i2);
            objArr[3] = Integer.valueOf(i3);
            objArr[4] = Integer.valueOf(i4);
            objArr[5] = Integer.valueOf(i5);
            objArr[6] = Integer.valueOf(z ? 1 : 0);
            objArr[7] = Integer.valueOf(i6);
            objArr[8] = Integer.valueOf(3);
            objArr[9] = Integer.valueOf(z2 ? 1 : 0);
            objArr[10] = sightCaptureUI.owm.osR;
            objArr[11] = Long.valueOf(bo.anT());
            hVar.e(13857, objArr);
        } else {
            ab.i("MicroMsg.SightCaptureUI", "[reportPhotoEdit] reportPhotoEdit == false");
        }
        sightCaptureUI.finish();
        AppMethodBeat.o(55265);
    }

    static /* synthetic */ void A(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55268);
        ab.i("MicroMsg.SightCaptureUI", "setRevertAndSendBtnPos");
        if (sightCaptureUI.oCt.getVisibility() == 8) {
            sightCaptureUI.lmm.setVisibility(8);
        } else {
            sightCaptureUI.lmm.setVisibility(0);
        }
        Point eu = com.tencent.mm.plugin.mmsight.d.eu(sightCaptureUI);
        int dimensionPixelSize = sightCaptureUI.getResources().getDimensionPixelSize(2131428553);
        int dimensionPixelSize2 = sightCaptureUI.getResources().getDimensionPixelSize(2131428555);
        sightCaptureUI.oCn.getX();
        sightCaptureUI.oCo.setTranslationX(((((float) eu.x) / 2.0f) - ((float) dimensionPixelSize2)) - (((float) dimensionPixelSize) / 2.0f));
        sightCaptureUI.nPr.setTranslationX(((((float) (-eu.x)) / 2.0f) + ((float) dimensionPixelSize2)) + (((float) dimensionPixelSize) / 2.0f));
        sightCaptureUI.oCo.setEnabled(false);
        sightCaptureUI.nPr.setEnabled(false);
        AppMethodBeat.o(55268);
    }

    static /* synthetic */ void D(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55270);
        if (bo.cb(sightCaptureUI.oCF) || sightCaptureUI.oCH <= 0 || sightCaptureUI.oCG <= 0) {
            ab.e("MicroMsg.SightCaptureUI", "saveCaptureYuvDataToBitmap error");
        } else {
            try {
                Bitmap b;
                YuvImage yuvImage = new YuvImage(sightCaptureUI.oCF, 17, sightCaptureUI.oCG, sightCaptureUI.oCH, null);
                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                yuvImage.compressToJpeg(new Rect(0, 0, sightCaptureUI.oCG, sightCaptureUI.oCH), 100, byteArrayOutputStream);
                byte[] toByteArray = byteArrayOutputStream.toByteArray();
                Bitmap decodeByteArray = MMBitmapFactory.decodeByteArray(toByteArray, 0, toByteArray.length);
                if (!sightCaptureUI.oCP || sightCaptureUI.oCJ == 180) {
                    int i = sightCaptureUI.oCI;
                    if (sightCaptureUI.oCJ == 180) {
                        i += 180;
                        if (i > 360) {
                            i -= 360;
                        }
                    }
                    b = com.tencent.mm.sdk.platformtools.d.b(decodeByteArray, (float) i);
                    decodeByteArray.recycle();
                } else if (Math.abs(sightCaptureUI.oCI - sightCaptureUI.oCJ) == 0) {
                    b = com.tencent.mm.sdk.platformtools.d.b(decodeByteArray, 180.0f);
                    decodeByteArray.recycle();
                } else {
                    b = decodeByteArray;
                }
                try {
                    com.tencent.mm.sdk.platformtools.d.a(b, 90, CompressFormat.JPEG, sightCaptureUI.gLs.WI(), false);
                    ab.i("MicroMsg.SightCaptureUI", "bitmap filelen %s", new Object[]{Long.valueOf(com.tencent.mm.vfs.e.asZ(r1))});
                } catch (Exception e) {
                    ab.e("MicroMsg.SightCaptureUI", "error for saveBitmapToImage %s", new Object[]{e.getMessage()});
                }
                com.tencent.mm.plugin.mmsight.model.a.j.owk.g(sightCaptureUI.oCF);
                sightCaptureUI.oCH = 0;
                sightCaptureUI.oCG = 0;
                sightCaptureUI.oCJ = 0;
                sightCaptureUI.oCI = 0;
                sightCaptureUI.oCF = null;
            } catch (Exception e2) {
                ab.printErrStackTrace("MicroMsg.SightCaptureUI", e2, "saveCaptureYuvDataToBitmap error: %s", new Object[]{e2.getMessage()});
            }
        }
        sightCaptureUI.hGI = false;
        AppMethodBeat.o(55270);
    }

    static /* synthetic */ void G(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55272);
        sightCaptureUI.oCo.animate().translationX(0.0f).setDuration(200).setListener(new 16(sightCaptureUI)).start();
        sightCaptureUI.nPr.animate().translationX(0.0f).setDuration(200).setListener(new AnimatorListenerAdapter() {
            public final void onAnimationEnd(Animator animator) {
                AppMethodBeat.i(55209);
                SightCaptureUI.this.nPr.setEnabled(true);
                AppMethodBeat.o(55209);
            }

            public final void onAnimationStart(Animator animator) {
                AppMethodBeat.i(55210);
                SightCaptureUI.this.nPr.setEnabled(false);
                AppMethodBeat.o(55210);
            }
        }).start();
        AppMethodBeat.o(55272);
    }

    static /* synthetic */ void L(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55275);
        i.R(new 11(sightCaptureUI));
        AppMethodBeat.o(55275);
    }

    static /* synthetic */ void M(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55276);
        ab.i("MicroMsg.SightCaptureUI", "start preview");
        if (sightCaptureUI.gar != null) {
            sightCaptureUI.gar.requestFocus();
        }
        sightCaptureUI.oxL.setVisibility(0);
        sightCaptureUI.oxL.setAlpha(0.0f);
        sightCaptureUI.oxL.setVideoPath(sightCaptureUI.gLs.getFilePath());
        sightCaptureUI.oxL.setLoop(true);
        sightCaptureUI.oxL.setForceScaleFullScreen(true);
        sightCaptureUI.oxL.setVideoCallback(sightCaptureUI.oxS);
        AppMethodBeat.o(55276);
    }

    static /* synthetic */ void O(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55277);
        if (sightCaptureUI.hGH == 1 || sightCaptureUI.hGH == 2) {
            String bPo = sightCaptureUI.oCl.bPo();
            if (!bo.isNullOrNil(bPo)) {
                StringBuilder append = new StringBuilder().append(bPo + IOUtils.LINE_SEPARATOR_UNIX + String.format("CPU: cur %s max:%s", new Object[]{m.Lz(), m.Lx()})).append(IOUtils.LINE_SEPARATOR_UNIX);
                Object[] objArr = new Object[1];
                k.bPR();
                objArr[0] = k.bPV();
                al.d(new 13(sightCaptureUI, append.append(String.format("RecorderType %s", objArr)).toString() + IOUtils.LINE_SEPARATOR_UNIX + String.format("MemoryClass: %sMB, TotalMem: %sMB", new Object[]{Integer.valueOf(((ActivityManager) ah.getContext().getSystemService("activity")).getLargeMemoryClass()), Integer.valueOf(com.tencent.mm.plugin.mmsight.d.ev(sightCaptureUI))})));
            }
        }
        AppMethodBeat.o(55277);
    }

    static /* synthetic */ void V(SightCaptureUI sightCaptureUI) {
        AppMethodBeat.i(55278);
        try {
            Bitmap tv = com.tencent.mm.plugin.mmsight.d.tv(sightCaptureUI.gLs.getFilePath());
            if (!(tv == null || sightCaptureUI.fcY == null || Math.min(tv.getWidth(), tv.getHeight()) <= sightCaptureUI.fcY.fAf)) {
                int width = tv.getWidth();
                int height = tv.getHeight();
                int i = sightCaptureUI.fcY.fAf > 0 ? sightCaptureUI.fcY.fAf : sightCaptureUI.fcY.width;
                if (width < height) {
                    width = (int) (((float) height) / ((((float) width) * 1.0f) / ((float) i)));
                    height = i;
                } else {
                    height = (int) (((float) width) / ((((float) height) * 1.0f) / ((float) i)));
                    width = i;
                }
                com.tencent.mm.sdk.platformtools.d.a(Bitmap.createScaledBitmap(tv, height, width, true), 60, CompressFormat.JPEG, sightCaptureUI.gLs.Wy(), true);
            }
            AppMethodBeat.o(55278);
        } catch (Exception e) {
            ab.printErrStackTrace("MicroMsg.SightCaptureUI", e, "saveNewThumbAfterEdit error: %s", new Object[]{e.getMessage()});
            AppMethodBeat.o(55278);
        }
    }
}
