导航菜单

页面标题

页面副标题

微商客 v2.1.2 - CaptureVideoActivity.java 源代码

正在查看: 微商客 v2.1.2 应用的 CaptureVideoActivity.java JAVA 源代码文件

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


package com.qiyukf.uikit.session.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.hardware.Camera;
import android.media.CamcorderProfile;
import android.media.MediaRecorder;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcelable;
import android.text.TextUtils;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.fragment.app.Fragment;
import com.qiyukf.module.log.UnicornLog;
import com.qiyukf.nimlib.net.a.c.a;
import com.qiyukf.nimlib.r.v;
import com.qiyukf.uikit.common.activity.BaseFragmentActivity;
import com.qiyukf.unicorn.R;
import com.qiyukf.unicorn.api.event.EventCallback;
import com.qiyukf.unicorn.api.event.UnicornEventBase;
import com.qiyukf.unicorn.api.event.entry.RequestPermissionEventEntry;
import com.qiyukf.unicorn.c;
import com.qiyukf.unicorn.g.l;
import com.qiyukf.unicorn.mediaselect.Matisse;
import com.qiyukf.unicorn.mediaselect.MimeType;
import com.qiyukf.unicorn.mediaselect.filter.Filter;
import com.qiyukf.unicorn.n.i;
import com.qiyukf.unicorn.n.r;
import com.qiyukf.unicorn.widget.dialog.UnicornDialog;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

public class CaptureVideoActivity extends BaseFragmentActivity implements SurfaceHolder.Callback, View.OnClickListener {
    public static final String EXTRA_DATA_FILE_NAME = "EXTRA_DATA_FILE_NAME";
    public static final String EXTRA_DATA_VIDEO_PATH = "EXTRA_DATA_VIDEO_PATH";
    public static final String EXTRA_DATA_VIDEO_URL_LIST = "EXTRA_DATA_VIDEO_URL_LIST";
    public static final String SELECT_VIDEO_TYPE_TAG = "SELECT_VIDEO_TYPE_TAG";
    private static final String TAG = "CaptureVideoActivity";
    private static final int VIDEO_HEIGHT = 240;
    private static final int VIDEO_TIMES = 30;
    private static final int VIDEO_WIDTH = 320;
    private Camera camera;
    private long end;
    private String filename;
    private MediaRecorder mediaRecorder;
    private ImageView openAudio;
    private ImageView recordBtn;
    private ImageView recordingState;
    private TextView recordingTimeTextView;
    private long start;
    private SurfaceHolder surfaceHolder;
    private SurfaceView surfaceview;
    private ImageView switchCamera;
    private ImageView ysfIvCaptureCancel;
    private ImageView ysfIvCaptureSend;
    private ImageView ysfIvCaptureVideoFinish;
    private ImageView ysfIvVideoSelect;
    private ProgressBar ysfPbVideoProgressBar;
    private TextView ysfTvVideoProgressSecond;
    public Handler handler = new Handler();
    private int cameraId = 0;
    private boolean previewing = false;
    private boolean multiCamera = false;
    private boolean recording = false;
    private long duration = 0;
    private boolean destroyed = false;
    private int mAngle = 0;
    private boolean isAudioOpen = false;
    private LinkedList<Point> backCameraSize = new LinkedList<>();
    private LinkedList<Point> frontCameraSize = new LinkedList<>();
    private Runnable runnable = new Runnable() {
        @Override
        public void run() {
            CaptureVideoActivity.this.end = new Date().getTime();
            CaptureVideoActivity captureVideoActivity = CaptureVideoActivity.this;
            captureVideoActivity.duration = captureVideoActivity.end - CaptureVideoActivity.this.start;
            int i = (int) (CaptureVideoActivity.this.duration / 1000);
            CaptureVideoActivity.this.ysfTvVideoProgressSecond.setText(i + "s");
            CaptureVideoActivity.this.ysfPbVideoProgressBar.setProgress(i);
            CaptureVideoActivity.this.recordingTimeTextView.setText(v.a(i));
            if (i % 2 == 0) {
                CaptureVideoActivity.this.recordingState.setBackgroundResource(R.drawable.ysf_record_start);
            } else {
                CaptureVideoActivity.this.recordingState.setBackgroundResource(R.drawable.ysf_record_video);
            }
            if (i >= 30) {
                CaptureVideoActivity.this.ysfPbVideoProgressBar.setProgress(100);
                CaptureVideoActivity.this.ysfTvVideoProgressSecond.setText("30s");
                CaptureVideoActivity.this.stopRecorder();
                return;
            }
            CaptureVideoActivity.this.handler.postDelayed(this, 1000L);
        }
    };
    private Point currentUsePoint = null;

    private int roundRotation(int i) {
        if (i == 1) {
            return 90;
        }
        if (i != 2) {
            return i != 3 ? 0 : 270;
        }
        return 180;
    }

    @Override
    protected boolean hasTitleBar() {
        return false;
    }

    public static void start(Fragment fragment, String str, int i) {
        Intent intent = new Intent();
        intent.setClass(fragment.getActivity(), CaptureVideoActivity.class);
        intent.putExtra(EXTRA_DATA_FILE_NAME, str);
        fragment.startActivityForResult(intent, i);
    }

    public static void start(Activity activity, String str, int i) {
        Intent intent = new Intent();
        intent.setClass(activity, CaptureVideoActivity.class);
        intent.putExtra(EXTRA_DATA_FILE_NAME, str);
        activity.startActivityForResult(intent, i);
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        getWindow().setFormat(-3);
        getWindow().setFlags(Filter.K, Filter.K);
        setContentView(R.layout.ysf_capture_video_activity);
        parseIntent();
        if (this.filename == null) {
            finish();
            return;
        }
        findViews();
        initActionBar();
        setViewsListener();
        updateRecordUI(true);
        getVideoPreviewSize();
        SurfaceView surfaceView = (SurfaceView) findViewById(R.id.videoView);
        this.surfaceview = surfaceView;
        SurfaceHolder holder = surfaceView.getHolder();
        holder.setType(3);
        holder.addCallback(this);
        resizeSurfaceView();
    }

    private void parseIntent() {
        if (getIntent().getExtras() != null) {
            this.filename = getIntent().getExtras().getString(EXTRA_DATA_FILE_NAME);
        }
    }

    private void findViews() {
        this.recordingTimeTextView = (TextView) findViewById(R.id.record_times);
        this.recordingState = (ImageView) findViewById(R.id.recording_id);
        this.recordBtn = (ImageView) findViewById(R.id.record_btn);
        this.ysfIvVideoSelect = (ImageView) findViewById(R.id.ysf_iv_video_select);
        this.switchCamera = (ImageView) findViewById(R.id.switch_cameras);
        this.openAudio = (ImageView) findViewById(R.id.ysf_open_audio);
        ProgressBar progressBar = (ProgressBar) findViewById(R.id.ysf_pb_video_progress_bar);
        this.ysfPbVideoProgressBar = progressBar;
        progressBar.setVisibility(0);
        this.ysfPbVideoProgressBar.setMax(30);
        TextView textView = (TextView) findViewById(R.id.ysf_tv_video_progress_second);
        this.ysfTvVideoProgressSecond = textView;
        textView.setVisibility(0);
        this.ysfTvVideoProgressSecond.setText("30s");
        ImageView imageView = (ImageView) findViewById(R.id.ysf_iv_capture_send);
        this.ysfIvCaptureSend = imageView;
        imageView.setVisibility(8);
        ImageView imageView2 = (ImageView) findViewById(R.id.ysf_iv_capture_cancel);
        this.ysfIvCaptureCancel = imageView2;
        imageView2.setVisibility(8);
        this.ysfIvCaptureVideoFinish = (ImageView) findViewById(R.id.ysf_iv_capture_video_finish);
    }

    private void initActionBar() {
        checkMultiCamera();
    }

    private void setViewsListener() {
        this.recordBtn.setOnClickListener(this);
        this.switchCamera.setOnClickListener(this);
        this.ysfIvCaptureCancel.setOnClickListener(this);
        this.ysfIvCaptureSend.setOnClickListener(this);
        this.ysfIvVideoSelect.setOnClickListener(this);
        this.ysfIvCaptureVideoFinish.setOnClickListener(this);
        this.openAudio.setOnClickListener(this);
    }

    private void switchCamera() {
        this.cameraId = (this.cameraId + 1) % Camera.getNumberOfCameras();
        resizeSurfaceView();
        shutdownCamera();
        initCamera();
        startPreview();
    }

    public void onResume() {
        super.onResume();
        getWindow().setFlags(128, 128);
    }

    public void onStop() {
        super.onStop();
        getWindow().setFlags(0, 128);
        if (this.recording) {
            stopRecorder();
            sendVideo();
        } else {
            shutdownCamera();
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        shutdownCamera();
        this.destroyed = true;
    }

    @Override
    public void onBackPressed() {
        if (this.recording) {
            stopRecorder();
        }
        shutdownCamera();
        setResult(0);
        finish();
    }

    private void getVideoPreviewSize(boolean z) {
        if (CamcorderProfile.hasProfile(z ? 1 : 0, 4)) {
            CamcorderProfile camcorderProfile = CamcorderProfile.get(z ? 1 : 0, 4);
            if (camcorderProfile != null) {
                Point point = new Point();
                point.x = camcorderProfile.videoFrameWidth;
                point.y = camcorderProfile.videoFrameHeight;
                if (z) {
                    this.frontCameraSize.addLast(point);
                } else {
                    this.backCameraSize.addLast(point);
                }
            }
        } else {
            UnicornLog.i(TAG, (z ? "Back Camera" : "Front Camera").concat(" no QUALITY_480P"));
        }
        if (CamcorderProfile.hasProfile(z ? 1 : 0, 3)) {
            CamcorderProfile camcorderProfile2 = CamcorderProfile.get(z ? 1 : 0, 3);
            if (camcorderProfile2 != null) {
                Point point2 = new Point();
                point2.x = camcorderProfile2.videoFrameWidth;
                point2.y = camcorderProfile2.videoFrameHeight;
                if (z) {
                    this.frontCameraSize.addLast(point2);
                } else {
                    this.backCameraSize.addLast(point2);
                }
            }
        } else {
            UnicornLog.i(TAG, (z ? "Back Camera" : "Front Camera").concat(" no QUALITY_CIF"));
        }
        if (CamcorderProfile.hasProfile(z ? 1 : 0, 7)) {
            CamcorderProfile camcorderProfile3 = CamcorderProfile.get(z ? 1 : 0, 7);
            if (camcorderProfile3 != null) {
                Point point3 = new Point();
                point3.x = camcorderProfile3.videoFrameWidth;
                point3.y = camcorderProfile3.videoFrameHeight;
                if (z) {
                    this.frontCameraSize.addLast(point3);
                } else {
                    this.backCameraSize.addLast(point3);
                }
            }
        } else {
            UnicornLog.i(TAG, (z ? "Back Camera" : "Front Camera").concat(" no QUALITY_QVGA"));
        }
        CamcorderProfile camcorderProfile4 = CamcorderProfile.get(z ? 1 : 0, 0);
        if (camcorderProfile4 == null) {
            Point point4 = new Point();
            point4.x = VIDEO_WIDTH;
            point4.y = VIDEO_HEIGHT;
            if (z) {
                this.frontCameraSize.addLast(point4);
            } else {
                this.backCameraSize.addLast(point4);
            }
            UnicornLog.i(TAG, (z ? "Back Camera" : "Front Camera").concat(" no QUALITY_LOW"));
            return;
        }
        Point point5 = new Point();
        point5.x = camcorderProfile4.videoFrameWidth;
        point5.y = camcorderProfile4.videoFrameHeight;
        if (z) {
            this.frontCameraSize.addLast(point5);
        } else {
            this.backCameraSize.addLast(point5);
        }
    }

    private void getVideoPreviewSize() {
        this.backCameraSize.clear();
        this.frontCameraSize.clear();
        getVideoPreviewSize(false);
        if (Camera.getNumberOfCameras() >= 2) {
            getVideoPreviewSize(true);
        }
    }

    private void resizeSurfaceView() {
        Point first;
        if (this.cameraId == 0) {
            first = this.backCameraSize.getFirst();
        } else {
            first = this.frontCameraSize.getFirst();
        }
        Point point = this.currentUsePoint;
        if (point == null || !first.equals(point)) {
            this.currentUsePoint = first;
            int width = getWindowManager().getDefaultDisplay().getWidth();
            int i = (first.x * width) / first.y;
            SurfaceView surfaceView = this.surfaceview;
            if (surfaceView != null) {
                RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) surfaceView.getLayoutParams();
                layoutParams.width = width;
                layoutParams.height = i;
                layoutParams.addRule(13);
                this.surfaceview.setLayoutParams(layoutParams);
            }
        }
    }

    private void setCamcorderProfile() {
        CamcorderProfile camcorderProfile = CamcorderProfile.get(4);
        if (camcorderProfile != null && this.isAudioOpen) {
            Point point = this.currentUsePoint;
            if (point != null) {
                camcorderProfile.videoFrameWidth = point.x;
                camcorderProfile.videoFrameHeight = this.currentUsePoint.y;
            }
            camcorderProfile.fileFormat = 2;
            if (Build.MODEL.equalsIgnoreCase("MB525") || Build.MODEL.equalsIgnoreCase("C8812") || Build.MODEL.equalsIgnoreCase("C8650")) {
                camcorderProfile.videoCodec = 1;
            } else {
                camcorderProfile.videoCodec = 2;
            }
            camcorderProfile.audioCodec = 3;
            this.mediaRecorder.setProfile(camcorderProfile);
            return;
        }
        this.mediaRecorder.setOutputFormat(2);
        this.mediaRecorder.setVideoEncoder(2);
        if (this.isAudioOpen) {
            this.mediaRecorder.setAudioEncoder(1);
        }
        this.mediaRecorder.setVideoSize(VIDEO_WIDTH, VIDEO_HEIGHT);
    }

    private void setVideoOrientation() {
        Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
        Camera.getCameraInfo(this.cameraId, cameraInfo);
        this.mediaRecorder.setOrientationHint(cameraInfo.orientation);
    }

    public void updateRecordUI(boolean z) {
        if (this.recording) {
            this.recordBtn.setVisibility(0);
            this.recordBtn.setBackgroundResource(R.drawable.ysf_ic_video_record_stop);
            this.ysfIvCaptureCancel.setVisibility(8);
            this.ysfIvCaptureSend.setVisibility(8);
            this.ysfIvVideoSelect.setVisibility(8);
            return;
        }
        if (z) {
            this.recordBtn.setVisibility(0);
            this.recordBtn.setBackgroundResource(R.drawable.ysf_ic_video_record_start);
            this.ysfIvCaptureCancel.setVisibility(8);
            this.ysfIvCaptureSend.setVisibility(8);
            this.ysfIvVideoSelect.setVisibility(0);
            return;
        }
        this.recordBtn.setVisibility(8);
        this.ysfIvCaptureCancel.setVisibility(0);
        this.ysfIvCaptureSend.setVisibility(0);
        this.ysfIvVideoSelect.setVisibility(8);
    }

    private boolean startRecorderInternal() throws Exception {
        shutdownCamera();
        if (!initCamera()) {
            return false;
        }
        this.switchCamera.setVisibility(8);
        this.openAudio.setVisibility(8);
        this.mediaRecorder = new MediaRecorder();
        this.camera.unlock();
        this.mediaRecorder.setCamera(this.camera);
        if (this.isAudioOpen) {
            this.mediaRecorder.setAudioSource(5);
        }
        this.mediaRecorder.setVideoSource(1);
        setCamcorderProfile();
        this.mediaRecorder.setPreviewDisplay(this.surfaceHolder.getSurface());
        this.mediaRecorder.setMaxDuration(30000);
        this.mediaRecorder.setOutputFile(this.filename);
        setVideoOrientation();
        this.mediaRecorder.prepare();
        this.mediaRecorder.start();
        return true;
    }

    private void startRecorder() {
        try {
            startRecorderInternal();
            this.recording = true;
            this.start = new Date().getTime();
            this.handler.postDelayed(this.runnable, 1000L);
            this.recordingTimeTextView.setText("00:00");
            updateRecordUI(false);
        } catch (Exception e) {
            UnicornLog.e(TAG, "start MediaRecord failed:", e);
            Toast.makeText((Context) this, R.string.ysf_start_camera_to_record_failed, 0).show();
            if (this.mediaRecorder != null) {
                this.mediaRecorder.release();
                this.mediaRecorder = null;
            }
            Camera camera = this.camera;
            if (camera != null) {
                camera.release();
                this.camera = null;
            }
        }
    }

    public void stopRecorder() {
        MediaRecorder mediaRecorder = this.mediaRecorder;
        if (mediaRecorder != null) {
            try {
                mediaRecorder.stop();
            } catch (Exception e) {
                UnicornLog.i(TAG, "停止失败,可能已经停止", e);
            }
            this.mediaRecorder.release();
            this.mediaRecorder = null;
        }
        Camera camera = this.camera;
        if (camera != null) {
            camera.release();
            this.camera = null;
        }
        this.handler.removeCallbacks(this.runnable);
        this.recordingState.setBackgroundResource(R.drawable.ysf_record_start);
        this.recording = false;
        if (this.duration <= 1) {
            tooShortAlert();
        } else {
            updateRecordUI(false);
        }
    }

    private void sendVideo() {
        if (this.filename == null) {
            return;
        }
        File file = new File(this.filename);
        if (file.exists()) {
            int length = ((int) file.length()) / Filter.K;
            float f = length / 1024.0f;
            String str = "" + (f > 1.0f ? getString(R.string.ysf_capture_video_size_in_mb, new Object[]{Float.valueOf(f)}) : getString(R.string.ysf_capture_video_size_in_kb, new Object[]{Integer.valueOf(length)}));
            getString(R.string.ysf_is_send_video);
            if (f <= 1.0f && length < 10) {
                tooShortAlert();
                return;
            }
        }
        Intent intent = new Intent();
        intent.putExtra("duration", this.duration);
        intent.putExtra(SELECT_VIDEO_TYPE_TAG, 0);
        intent.putExtra(EXTRA_DATA_FILE_NAME, this.filename);
        setResult(-1, intent);
        finish();
    }

    private void tooShortAlert() {
        this.duration = 0L;
        r.b(R.string.ysf_video_record_short);
        cancelRecord();
    }

    private void cancelRecord() {
        a.b(this.filename);
        this.recordingTimeTextView.setText("00:00");
        this.ysfTvVideoProgressSecond.setText("30s");
        this.ysfPbVideoProgressBar.setProgress(0);
        updateRecordUI(true);
        shutdownCamera();
        initCamera();
        startPreview();
        checkMultiCamera();
    }

    public void checkMultiCamera() {
        if (Camera.getNumberOfCameras() > 1) {
            this.multiCamera = true;
            this.switchCamera.setVisibility(0);
        } else {
            this.switchCamera.setVisibility(8);
        }
        this.openAudio.setVisibility(0);
    }

    private boolean initCamera() {
        try {
            if (this.multiCamera) {
                this.camera = Camera.open(this.cameraId);
            } else {
                this.camera = Camera.open();
            }
            if (this.camera != null) {
                setCameraParameters();
            }
            return this.camera != null;
        } catch (RuntimeException e) {
            UnicornLog.e(TAG, "init camera failed: ", e);
            Toast.makeText((Context) this, R.string.ysf_connect_vedio_device_fail, 0).show();
            return false;
        }
    }

    private void setCameraParameters() {
        Camera.Parameters parameters = this.camera.getParameters();
        if (parameters.isVideoStabilizationSupported()) {
            parameters.setVideoStabilization(true);
        }
        if (parameters.getSupportedFocusModes().contains("continuous-video")) {
            parameters.setFocusMode("continuous-video");
        }
        if (parameters != null) {
            this.mAngle = setCameraDisplayOrientation(this, this.cameraId, this.camera);
        }
        parameters.setPreviewSize(this.currentUsePoint.x, this.currentUsePoint.y);
        try {
            this.camera.setParameters(parameters);
        } catch (RuntimeException e) {
            UnicornLog.e(TAG, "setParameters failed", e);
        }
    }

    private void shutdownCamera() {
        Camera camera = this.camera;
        if (camera != null) {
            if (this.previewing) {
                camera.stopPreview();
            }
            this.camera.release();
            this.camera = null;
            this.previewing = false;
        }
    }

    @Override
    public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
        this.surfaceHolder = surfaceHolder;
    }

    @Override
    public void surfaceCreated(SurfaceHolder surfaceHolder) {
        this.surfaceHolder = surfaceHolder;
        shutdownCamera();
        if (initCamera()) {
            startPreview();
            if (c.g().isCaptureVideoRecordAudioPermission) {
                openRecordAudio();
            } else if (!i.a(this, l.h)) {
                UnicornDialog.showDoubleBtnDialog(this, null, TextUtils.isEmpty(c.g().captureVideoRecordTip) ? "" : c.g().captureVideoRecordTip, true, new UnicornDialog.OnClickListener() {
                    @Override
                    public void onClick(int i) {
                        if (i == 0) {
                            CaptureVideoActivity.this.checkPermissionAndRecord(null, null);
                        }
                    }
                });
            } else {
                setAudioOpen(true);
            }
        }
    }

    @Override
    public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
        this.surfaceHolder = null;
        this.mediaRecorder = null;
    }

    private void startPreview() {
        try {
            this.camera.setPreviewDisplay(this.surfaceHolder);
            this.camera.startPreview();
            this.previewing = true;
        } catch (Exception e) {
            Toast.makeText((Context) this, R.string.ysf_connect_vedio_device_fail, 0).show();
            shutdownCamera();
            e.printStackTrace();
        }
    }

    public int setCameraDisplayOrientation(Context context, int i, Camera camera) {
        int i2;
        Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
        Camera.getCameraInfo(i, cameraInfo);
        int i3 = cameraInfo.orientation;
        boolean z = cameraInfo.facing == 1;
        int roundRotation = roundRotation(((WindowManager) context.getSystemService("window")).getDefaultDisplay().getRotation());
        if (z) {
            i2 = (360 - ((i3 + roundRotation) % 360)) % 360;
        } else {
            i2 = ((i3 - roundRotation) + 360) % 360;
            if ("Xiaomi_MI-ONE Plus".equalsIgnoreCase(Build.MANUFACTURER + "_" + Build.MODEL)) {
                i2 = 90;
            }
        }
        camera.setDisplayOrientation(i2);
        return i2;
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.ysf_iv_capture_cancel) {
            cancelRecord();
            return;
        }
        if (view.getId() == R.id.ysf_iv_capture_send) {
            sendVideo();
            return;
        }
        if (view.getId() == R.id.record_btn) {
            if (this.recording) {
                stopRecorder();
                return;
            } else {
                startRecorder();
                return;
            }
        }
        if (view.getId() == R.id.switch_cameras) {
            switchCamera();
            return;
        }
        if (view.getId() == R.id.ysf_iv_capture_video_finish) {
            finish();
            return;
        }
        if (view.getId() == R.id.ysf_iv_video_select) {
            Matisse.startSelectMediaFile((Activity) this, MimeType.ofVideo(), 9, 35);
        } else if (view.getId() == R.id.ysf_open_audio) {
            if (this.isAudioOpen) {
                setAudioOpen(false);
            } else {
                openRecordAudio();
            }
        }
    }

    public void checkPermissionAndRecord(final UnicornEventBase unicornEventBase, final RequestPermissionEventEntry requestPermissionEventEntry) {
        i.a((Activity) this).a(l.h).a(new i.a() {
            @Override
            public void onGranted() {
                CaptureVideoActivity.this.setAudioOpen(true);
            }

            @Override
            public void onDenied() {
                UnicornEventBase unicornEventBase2 = unicornEventBase;
                if (unicornEventBase2 != null) {
                    unicornEventBase2.onDenyEvent(CaptureVideoActivity.this, requestPermissionEventEntry);
                }
            }
        }).a();
    }

    public void setAudioOpen(boolean z) {
        this.isAudioOpen = z;
        if (z) {
            this.openAudio.setImageResource(R.drawable.ysf_ic_audio_open);
        } else {
            this.openAudio.setImageResource(R.drawable.ysf_ic_audio_close);
        }
    }

    protected void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i == 35 && i2 == -1 && intent != null) {
            UnicornLog.i(TAG, "OnActivityResult data= " + Matisse.obtainOriginalState(intent));
            UnicornLog.i(TAG, "obtainResult(data) data= " + Matisse.obtainResult(intent).get(0).toString());
            UnicornLog.i(TAG, "obtainPathResult(data) data= " + Matisse.obtainPathResult(intent).get(0));
            Intent intent2 = new Intent();
            intent2.putExtra("duration", this.duration);
            ArrayList<String> arrayList = (ArrayList) Matisse.obtainPathResult(intent);
            ArrayList<? extends Parcelable> arrayList2 = (ArrayList) Matisse.obtainResult(intent);
            intent2.putExtra(SELECT_VIDEO_TYPE_TAG, 1);
            intent2.putParcelableArrayListExtra(EXTRA_DATA_VIDEO_URL_LIST, arrayList2);
            intent2.putStringArrayListExtra(EXTRA_DATA_VIDEO_PATH, arrayList);
            setResult(-1, intent2);
            finish();
        }
    }

    private void openRecordAudio() {
        if (c.g().sdkEvents != null && c.g().sdkEvents.eventProcessFactory != null && !i.a(this, l.h)) {
            final UnicornEventBase eventOf = c.g().sdkEvents.eventProcessFactory.eventOf(5);
            if (eventOf != null) {
                List<String> asList = Arrays.asList(l.h);
                final RequestPermissionEventEntry requestPermissionEventEntry = new RequestPermissionEventEntry();
                requestPermissionEventEntry.setScenesType(1);
                requestPermissionEventEntry.setPermissionList(asList);
                eventOf.onEvent(requestPermissionEventEntry, this, new EventCallback() {
                    @Override
                    public void onInterceptEvent() {
                    }

                    @Override
                    public void onProcessEventSuccess(Object obj) {
                        CaptureVideoActivity.this.checkPermissionAndRecord(eventOf, requestPermissionEventEntry);
                    }

                    @Override
                    public void onPorcessEventError() {
                        CaptureVideoActivity.this.checkPermissionAndRecord(eventOf, requestPermissionEventEntry);
                    }

                    @Override
                    public void onNotPorcessEvent() {
                        CaptureVideoActivity.this.checkPermissionAndRecord(eventOf, requestPermissionEventEntry);
                    }
                });
                return;
            }
            checkPermissionAndRecord(null, null);
            return;
        }
        checkPermissionAndRecord(null, null);
    }
}