LandLiveSpliceActivity.java 源代码


package main.live4;

import activity.setting.WiFiSettingActivity;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import base.HiActivity;
import bean.HumanRect;
import bean.MyCamera;
import com.bytedance.sdk.openadsdk.TTAdConstant;
import com.bytedance.sdk.openadsdk.downloadnew.core.TTDownloadField;
import com.heytap.mcssdk.a.a;
import com.hichip.base.HiLog;
import com.hichip.callback.ICameraIOSessionCallback;
import com.hichip.callback.ICameraPlayStateCallback;
import com.hichip.campro.R;
import com.hichip.content.HiChipDefines;
import com.hichip.control.HiCamera;
import com.hichip.tools.Packet;
import com.xiaomi.mipush.sdk.Constants;
import common.ConstantCommand;
import common.HiDataValue;
import common.MyLiveViewGLMonitor;
import common.SpliceViewGLMonitor;
import custom.HumanRectView;
import custom.SwitchButton;
import custom.dialog.NiftyDialogBuilder;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
import main.MainActivity;
import main.live4.LandLiveSpliceActivity;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import service.LiteosConnectService;
import utils.AppManager;
import utils.HiLogcatUtil;
import utils.HiTools;
import utils.LiuHaiScreenTools;
import utils.MyToast;
import utils.OrientationWatchDog;

public class LandLiveSpliceActivity extends HiActivity implements View.OnClickListener, View.OnTouchListener, ICameraIOSessionCallback, ICameraPlayStateCallback, SeekBar.OnSeekBarChangeListener, OrientationWatchDog.OnOrientationListener {
    private static final int FLING_MIN_DISTANCE = 60;
    private static final int MY_PERMISSION_REQUEST_CODE = 10043;
    private HiChipDefines.ABSOLUTE_LIGHT_TYPE abs_light;
    private float action_down_x;
    private float action_down_y;
    private ConstantCommand.HI_P2P_S_AUDIBLE_VISUAL_ALARM_TYPE audible_visual_alarm_type;
    private HiChipDefines.HI_P2P_S_AUDIO_ATTR audio_attr;
    private int cameraPosition;
    private HiChipDefines.HI_P2P_S_DISPLAY display_param;
    private float down_X;
    private float down_Y;
    private int flipChecked;
    public HumanRectView humanRectView;
    private boolean isClickFinish;
    private boolean isCountDown;
    private boolean isListening;
    private boolean isReceiveDisconnect;
    private boolean isTalking;
    ImageView iv_bg;
    ImageView iv_land_more;
    ImageView iv_land_snapshot;
    public ImageView iv_landscape_listen;
    public ImageView iv_landscape_record;
    public ImageView iv_landscape_talk;
    public ImageView iv_recording;
    ImageView iv_signal;
    float lastX;
    float lastY;
    private int lightModel;
    private HiChipDefines.HI_P2P_WHITE_LIGHT_INFO light_info;
    private HiChipDefines.HI_P2P_WHITE_LIGHT_INFO_EXT light_info_ext;
    LinearLayout ll_4g_signal;
    LinearLayout ll_land_return;
    LinearLayout ll_land_snapshot;
    private LinearLayout ll_pup_content;
    private LinearLayout ll_pup_main;
    public LinearLayout ll_recording;
    LinearLayout ll_signal;
    private int mDp_250;
    public int mFlagPreset;
    private ConstantCommand.HI_P2P_Garden_Lamp_INFO mGarden_lamp_info;
    private boolean mGarden_set_cancel;
    private int mInputMethod;
    private boolean mIsListenTrans;
    private boolean mIsListening;
    private boolean mIsRecording;
    private boolean mIsSwitchResolution;
    private boolean mIsTXTJ;
    private boolean mIsTalking;
    ImageView mIvLoading2;
    public SpliceViewGLMonitor mMonitor;
    private OrientationWatchDog mOrientationWatchDog;
    private int mRecordingState;
    private int mStartRecordTime;
    private TimerTask mTask;
    private Timer mTimer;
    private boolean mVoiceIsTran;
    private int mirrorChecked;
    private int monitor_height;
    private int monitor_width;
    int moveX;
    int moveY;
    float move_x;
    float move_y;
    private int msaveGardenstate;
    private MyCamera myCamera;
    private String[] osList;
    private long preHumanTime;
    private boolean reGetSignal;
    private boolean receiveHumanParams;
    private String record2File;
    private String recordFile;
    private int recordedTime;
    public RelativeLayout rl_landscape_button;
    public RelativeLayout rl_landscape_one;
    public LinearLayout root_lock_screen;
    private SeekBar sb_brightness;
    private SeekBar sb_contrast;
    private SeekBar sb_saturation;
    private SeekBar seekBar_input;
    private SeekBar seekBar_output;
    private Timer timer;
    private TimerTask timerTask;
    TextView tv_brand;
    private TextView tv_brightness;
    private TextView tv_contrast;
    TextView tv_landscape_video_quality;
    public TextView tv_record_time;
    private TextView tv_saturation;
    int xlenOld;
    int ylenOld;
    private int quality = 1;
    private SimpleDateFormat sdf = new SimpleDateFormat("mm:ss", Locale.getDefault());
    private int maxInputValue = 100;
    private int maxOutputValue = 100;
    private List<HumanRect> humanRects = new ArrayList();
    private boolean isFirst = true;
    private Runnable runnable = new Runnable() {
        @Override
        public void run() {
            LandLiveSpliceActivity.this.isCountDown = true;
        }
    };
    private boolean firstInChangeStream = false;
    private double largeMul = 12.0d;
    private Handler mLITEHandler = new Handler();
    private boolean isLeft = true;
    public int isLarge = 0;
    private boolean isFirstRevolveLand = false;
    private boolean isReadyPlay = false;
    public boolean mIsOnpause = false;
    double nLenStart = 0.0d;
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            int i = message.what;
            if (i == -2147483647) {
                LandLiveSpliceActivity.this.handMsgPlayState(message);
                return;
            }
            if (i == 288) {
                LandLiveSpliceActivity landLiveSpliceActivity = LandLiveSpliceActivity.this;
                MyToast.showToast(landLiveSpliceActivity, landLiveSpliceActivity.getString(R.string.failed_recording));
                return;
            }
            if (i != 2384) {
                return;
            }
            HiLogcatUtil.e("initViewAndData" + LandLiveSpliceActivity.this.mMonitor.left + Constants.COLON_SEPARATOR + LandLiveSpliceActivity.this.mMonitor.bottom + Constants.COLON_SEPARATOR + LandLiveSpliceActivity.this.mMonitor.width + Constants.COLON_SEPARATOR + LandLiveSpliceActivity.this.mMonitor.height + Constants.COLON_SEPARATOR);
            LandLiveSpliceActivity.this.mMonitor.setMatrix(LandLiveSpliceActivity.this.mMonitor.left, LandLiveSpliceActivity.this.mMonitor.bottom, LandLiveSpliceActivity.this.mMonitor.width, LandLiveSpliceActivity.this.mMonitor.height);
        }
    };
    private Handler mIOHandler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            MyCamera myCamera = (MyCamera) message.obj;
            int i = message.what;
            if (i == -1879048191) {
                LandLiveSpliceActivity.this.handSessionState(message, myCamera);
            } else {
                if (i != -1879048189) {
                    return;
                }
                if (message.arg2 == 0) {
                    LandLiveSpliceActivity.this.handIOCTRLSuccess(message, myCamera);
                } else {
                    LandLiveSpliceActivity.this.handIOCTRLFail(message, myCamera);
                }
            }
        }
    };
    public boolean mselectsecondTab = false;
    public Handler mRecHandler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            if (message.what != 110) {
                return;
            }
            if (LandLiveSpliceActivity.this.iv_recording.getVisibility() == 4) {
                LandLiveSpliceActivity.this.iv_recording.setVisibility(0);
            } else {
                LandLiveSpliceActivity.this.iv_recording.setVisibility(4);
            }
            LandLiveSpliceActivity.access$2812(LandLiveSpliceActivity.this, 1000);
            LandLiveSpliceActivity.this.tv_record_time.setText(LandLiveSpliceActivity.this.sdf.format(new Date(LandLiveSpliceActivity.this.mStartRecordTime)));
            LandLiveSpliceActivity.this.mRecHandler.sendEmptyMessageDelayed(110, 1000L);
        }
    };
    private Handler humanRectHandler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            int i;
            byte[] bArr;
            if (message.what != 10010) {
                return;
            }
            byte[] bArr2 = (byte[]) message.obj;
            int i2 = message.arg1;
            if (i2 > 3) {
                i2 = 3;
            }
            LandLiveSpliceActivity.this.humanRects.clear();
            if (LandLiveSpliceActivity.this.mMonitor == null || LandLiveSpliceActivity.this.mMonitor.height <= ((int) ((LandLiveSpliceActivity.this.mMonitor.screen_width * 9.0d) / 32.0d))) {
                int i3 = 0;
                while (i3 < i2) {
                    byte[] bArr3 = new byte[20];
                    int i4 = (i3 * 20) + 8;
                    if (bArr2.length - i4 >= 20) {
                        System.arraycopy(bArr2, i4, bArr3, 0, 20);
                        ConstantCommand.HI_P2P_ALARM_MD hi_p2p_alarm_md = new ConstantCommand.HI_P2P_ALARM_MD(bArr3);
                        i = i2;
                        bArr = bArr2;
                        HumanRect humanRect = new HumanRect(hi_p2p_alarm_md.u32X, hi_p2p_alarm_md.u32Y, hi_p2p_alarm_md.u32Width, hi_p2p_alarm_md.u32Height, LandLiveSpliceActivity.this.monitor_width, (int) ((LandLiveSpliceActivity.this.monitor_width * 9.0d) / 32.0d));
                        if (humanRect.getRect_height() != 0 && humanRect.getRect_width() != 0) {
                            LandLiveSpliceActivity.this.humanRects.add(humanRect);
                        }
                    } else {
                        i = i2;
                        bArr = bArr2;
                    }
                    i3++;
                    i2 = i;
                    bArr2 = bArr;
                }
                LandLiveSpliceActivity.this.humanRectView.refreshRect(LandLiveSpliceActivity.this.humanRects, LandLiveSpliceActivity.this.myCamera.getVideoQuality());
            }
        }
    };
    private Handler mHandler_lockScreen = new Handler() {
        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                LandLiveSpliceActivity.this.root_lock_screen.setVisibility(0);
                LandLiveSpliceActivity.this.mHandler_lockScreen.sendEmptyMessageDelayed(1, 3000L);
            } else {
                LandLiveSpliceActivity.this.root_lock_screen.setVisibility(8);
                LandLiveSpliceActivity.this.mHandler_lockScreen.removeCallbacksAndMessages(null);
            }
        }
    };

    @Override
    public void callbackPlayUTC(HiCamera hiCamera, int i) {
    }

    @Override
    public void callbackPlayUTC2Dual(HiCamera hiCamera, int i, int i2, int i3) {
    }

    @Override
    public void callbackPlayUTCDual(HiCamera hiCamera, int i, int i2) {
    }

    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {
    }

    @Override
    protected int setLayoutId() {
        return R.layout.activity_live_spliceland;
    }

    static int access$2812(LandLiveSpliceActivity landLiveSpliceActivity, int i) {
        int i2 = landLiveSpliceActivity.mStartRecordTime + i;
        landLiveSpliceActivity.mStartRecordTime = i2;
        return i2;
    }

    @Override
    protected void initWindow() {
        hideBottomUIMenu();
    }

    @Override
    protected void init(Bundle bundle) {
        getWindow().addFlags(128);
        getWindow().setFlags(1024, 1024);
        EventBus.getDefault().register(this);
        getIntentData();
        if (this.myCamera == null) {
            return;
        }
        initView();
        startLiveShow();
        initData();
        setListener();
        this.largeMul = 6.0d;
        if (Build.VERSION.SDK_INT < 29) {
            this.largeMul = 3.0d;
        }
        OrientationWatchDog orientationWatchDog = new OrientationWatchDog(this);
        this.mOrientationWatchDog = orientationWatchDog;
        orientationWatchDog.setOnOrientationListener(this);
        this.mOrientationWatchDog.startWatch();
    }

    private void initData() {
        initHumanTimer();
        getSignalOperator();
        getLightModel();
    }

    public class AnonymousClass2 extends TimerTask {
        AnonymousClass2() {
        }

        @Override
        public void run() {
            LandLiveSpliceActivity.this.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    LandLiveSpliceActivity.AnonymousClass2.this.lambda$run$0$LandLiveSpliceActivity$2();
                }
            });
        }

        public void lambda$run$0$LandLiveSpliceActivity$2() {
            if (System.currentTimeMillis() - LandLiveSpliceActivity.this.preHumanTime > 1000) {
                LandLiveSpliceActivity.this.humanRectView.cleanRect(false);
            }
        }
    }

    private void initHumanTimer() {
        this.mTimer = new Timer();
        this.mTask = new AnonymousClass2();
    }

    private void getLightModel() {
        if (this.myCamera.appGetCommandFunction(HiChipDefines.HI_P2P_WHITE_LIGHT_GET_EXT)) {
            this.lightModel = 1;
            return;
        }
        if (this.myCamera.appGetCommandFunction(HiChipDefines.HI_P2P_WHITE_LIGHT_GET)) {
            this.lightModel = 2;
            return;
        }
        if (this.myCamera.appGetCommandFunction(HiChipDefines.HI_P2P_GET_ABSOLUTE_LIGHT_TYPE)) {
            this.lightModel = 3;
            return;
        }
        if (this.myCamera.appGetCommandFunction(16790)) {
            this.lightModel = 4;
        } else if (this.myCamera.appGetCommandFunction(ConstantCommand.HI_P2P_Garden_Lamp)) {
            this.lightModel = 3;
        } else if (this.myCamera.appGetCommandFunction(ConstantCommand.HI_P2P_GET_Garden_Lamp)) {
            this.lightModel = 5;
        }
    }

    private void initView() {
        this.mDp_250 = HiTools.dip2px(this, 250.0f);
        MyCamera myCamera = this.myCamera;
        if (myCamera != null) {
            int videoQuality = myCamera.getVideoQuality();
            this.quality = videoQuality;
            this.tv_landscape_video_quality.setText(getString(videoQuality == 0 ? R.string.high_definition : R.string.fluent));
        }
        if (this.myCamera.getdevDual()) {
            this.iv_land_more.setVisibility(8);
        }
        handLandScape();
    }

    private void handLandScape() {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        this.mMonitor.screen_height = displayMetrics.heightPixels;
        this.mMonitor.screen_width = displayMetrics.widthPixels;
        initMatrix(this.mMonitor.screen_width, this.mMonitor.screen_height);
        SpliceViewGLMonitor spliceViewGLMonitor = this.mMonitor;
        spliceViewGLMonitor.width = spliceViewGLMonitor.screen_width;
        this.mMonitor.height = (int) ((r0.screen_width * 9.0d) / 32.0d);
        this.mMonitor.left = 0;
        SpliceViewGLMonitor spliceViewGLMonitor2 = this.mMonitor;
        spliceViewGLMonitor2.bottom = (spliceViewGLMonitor2.screen_height - this.mMonitor.height) / 2;
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -1);
        layoutParams.topMargin = (int) ((this.mMonitor.screen_height - ((this.mMonitor.screen_width * 9.0d) / 32.0d)) / 2.0d);
        layoutParams.height = (int) ((this.mMonitor.screen_width * 9.0d) / 32.0d);
        this.humanRectView.setLayoutParams(layoutParams);
        RelativeLayout.LayoutParams layoutParams2 = new RelativeLayout.LayoutParams(this.ll_recording.getLayoutParams());
        layoutParams2.setMargins(HiTools.dip2px(this, 20.0f), HiTools.dip2px(this, 55.0f), 0, 0);
        this.ll_recording.setLayoutParams(layoutParams2);
        HiLogcatUtil.e("initViewAndData" + this.mMonitor.left + Constants.COLON_SEPARATOR + this.mMonitor.bottom + Constants.COLON_SEPARATOR + this.mMonitor.width + Constants.COLON_SEPARATOR + this.mMonitor.height + Constants.COLON_SEPARATOR);
        SpliceViewGLMonitor spliceViewGLMonitor3 = this.mMonitor;
        spliceViewGLMonitor3.setMatrix(spliceViewGLMonitor3.left, this.mMonitor.bottom, this.mMonitor.width, this.mMonitor.height);
        Handler handler = this.mHandler;
        if (handler != null) {
            handler.sendEmptyMessageDelayed(2384, 200L);
        }
    }

    private void setListener() {
        this.ll_land_return.setOnClickListener(this);
        this.tv_landscape_video_quality.setOnClickListener(this);
        this.iv_land_snapshot.setOnClickListener(this);
        this.iv_landscape_record.setOnClickListener(this);
        this.iv_landscape_talk.setOnClickListener(this);
        this.iv_land_more.setOnClickListener(this);
        this.iv_landscape_listen.setOnClickListener(this);
        this.root_lock_screen.setOnClickListener(this);
    }

    private void startLiveShow() {
        HiLogcatUtil.e("initViewAndData" + this.mMonitor.left + Constants.COLON_SEPARATOR + this.mMonitor.bottom + Constants.COLON_SEPARATOR + this.mMonitor.width + Constants.COLON_SEPARATOR + this.mMonitor.height + Constants.COLON_SEPARATOR);
        this.mMonitor.setState(0);
        this.mMonitor.setmIsFullScreen(1);
        this.mMonitor.setOnTouchListener(this);
        this.mMonitor.setCamera(this.myCamera);
        this.myCamera.setLiveShowMonitor(this.mMonitor);
        this.isReadyPlay = true;
        this.myCamera.registerIOSessionListener(this);
        this.myCamera.registerPlayStateListener(this);
        if (this.myCamera.getConnectState() != 4) {
            showLoadingView();
            this.myCamera.connect();
        } else {
            if (this.quality != 1) {
                HiLogcatUtil.d("单画面 ChangeStream quality =  " + this.quality);
                this.mVoiceIsTran = false;
                this.mIsSwitchResolution = true;
                this.iv_recording.postDelayed(new Runnable() {
                    @Override
                    public final void run() {
                        LandLiveSpliceActivity.this.lambda$startLiveShow$0$LandLiveSpliceActivity();
                    }
                }, 300L);
                this.firstInChangeStream = true;
                this.iv_recording.postDelayed(this.runnable, 10000L);
            } else {
                this.mIsSwitchResolution = false;
                if (!this.mIsTalking && this.mIsListening) {
                    this.iv_landscape_listen.setSelected(true);
                    clickListen();
                }
                if (this.mIsTalking && !this.mIsListening) {
                    handTalkingNew();
                }
                if (this.mIsRecording) {
                    this.isFirst = false;
                    clickRecording();
                    this.mStartRecordTime = getIntent().getIntExtra("mStartRecordTime", 0);
                }
                this.isReadyPlay = true;
            }
            this.tv_record_time.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    LandLiveSpliceActivity.this.lambda$startLiveShow$1$LandLiveSpliceActivity();
                }
            }, 3000L);
        }
        dealWithLITEInGroup();
    }

    public void lambda$startLiveShow$0$LandLiveSpliceActivity() {
        HiLogcatUtil.eTag("==test11", this.mIsSwitchResolution + "");
        this.myCamera.ChangeStream(this.quality);
    }

    public void lambda$startLiveShow$1$LandLiveSpliceActivity() {
        this.receiveHumanParams = true;
    }

    private void dealWithLITEInGroup() {
        String[] strArr = this.osList;
        if (strArr != null) {
            int length = strArr.length;
            boolean z = false;
            int i = 0;
            while (true) {
                if (i >= length) {
                    break;
                }
                if (!TextUtils.isEmpty(strArr[i])) {
                    z = true;
                    break;
                }
                i++;
            }
            if (z) {
                delayDisconnect();
            }
        }
    }

    private void delayDisconnect() {
        this.mLITEHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                for (String str : LandLiveSpliceActivity.this.osList) {
                    if (!TextUtils.isEmpty(str)) {
                        for (MyCamera myCamera : HiDataValue.CameraList) {
                            if (myCamera.getUid().equals(str)) {
                                Intent intent = new Intent(LandLiveSpliceActivity.this, (Class<?>) LiteosConnectService.class);
                                intent.putExtra(HiDataValue.EXTRAS_KEY_UID, myCamera.getUid());
                                LandLiveSpliceActivity.this.startService(intent);
                            }
                        }
                    }
                }
            }
        }, 15000L);
    }

    private void getIntentData() {
        String stringExtra = getIntent().getStringExtra(HiDataValue.EXTRAS_KEY_UID);
        this.cameraPosition = getIntent().getIntExtra("position", 0);
        this.monitor_width = getIntent().getIntExtra("monitor_width", 0);
        this.monitor_height = getIntent().getIntExtra("monitor_height", 0);
        this.mIsListening = getIntent().getBooleanExtra("isListening", false);
        this.mIsTalking = getIntent().getBooleanExtra("isTalking", false);
        this.mIsRecording = getIntent().getBooleanExtra("isRecording", false);
        this.recordedTime = getIntent().getIntExtra("mStartRecordTime", 0);
        this.mIsListenTrans = getIntent().getBooleanExtra("isNeedReOpenListen", false);
        this.mVoiceIsTran = getIntent().getBooleanExtra("isListenPause", false);
        String[] stringArrayExtra = getIntent().getStringArrayExtra("OSList");
        if (stringArrayExtra != null) {
            this.osList = (String[]) stringArrayExtra.clone();
        }
        if (TextUtils.isEmpty(stringExtra)) {
            return;
        }
        for (MyCamera myCamera : HiDataValue.CameraList) {
            if (myCamera.getUid().equals(stringExtra)) {
                this.myCamera = myCamera;
            }
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        this.mIsOnpause = false;
    }

    @Override
    public void onPause() {
        Handler handler;
        MyCamera myCamera;
        super.onPause();
        if (this.mIsOnpause) {
            return;
        }
        MyCamera myCamera2 = this.myCamera;
        if (myCamera2 != null) {
            myCamera2.unregisterPlayStateListener(this);
            this.myCamera.unregisterIOSessionListener(this);
        }
        Timer timer = this.timer;
        if (timer != null) {
            timer.cancel();
            this.timer = null;
        }
        TimerTask timerTask = this.timerTask;
        if (timerTask != null) {
            timerTask.cancel();
            this.timerTask = null;
        }
        Handler handler2 = this.mRecHandler;
        if (handler2 != null) {
            handler2.removeCallbacksAndMessages(null);
        }
        Handler handler3 = this.mHandler;
        if (handler3 != null) {
            handler3.removeCallbacksAndMessages(null);
        }
        Handler handler4 = this.mIOHandler;
        if (handler4 != null) {
            handler4.removeCallbacksAndMessages(null);
        }
        if ((this.isClickFinish || this.isReceiveDisconnect) && (handler = this.mLITEHandler) != null) {
            handler.removeCallbacksAndMessages(null);
        }
        if (!this.isClickFinish && !this.isReceiveDisconnect) {
            AppManager.getInstance().killAllActivityNoMain(MainActivity.class);
        }
        if (!this.isClickFinish && (myCamera = this.myCamera) != null) {
            myCamera.stopLiveShow();
            HiLogcatUtil.e("test", " stopLiveShow ");
            if (this.isListening) {
                this.isListening = false;
                this.myCamera.stopListening();
            }
            if (this.isTalking) {
                this.isTalking = false;
                this.myCamera.stopTalk();
            }
            if (this.mRecordingState == 2) {
                this.mRecordingState = 0;
                this.myCamera.stopRecording();
            }
        }
        EventBus.getDefault().unregister(this);
        this.mTimer.cancel();
        this.mTimer = null;
        this.mTask = null;
    }

    @Override
    public void onBackPressed() {
        if (!this.mIsSwitchResolution || this.isCountDown) {
            this.isClickFinish = true;
            if (this.isCountDown) {
                AppManager.getInstance().killAllActivityNoMain(MainActivity.class);
            } else {
                Intent intent = new Intent();
                if (this.quality != 1) {
                    intent.putExtra("changedQuality1", this.cameraPosition == 1);
                    intent.putExtra("changedQuality2", this.cameraPosition == 2);
                    intent.putExtra("changedQuality3", this.cameraPosition == 3);
                    intent.putExtra("changedQuality4", this.cameraPosition == 4);
                }
                intent.putExtra("position", this.cameraPosition);
                intent.putExtra("isListening", this.isListening);
                intent.putExtra("isTalking", this.isTalking);
                intent.putExtra("mStartRecordTime", this.mStartRecordTime);
                intent.putExtra("isRecording", this.mRecordingState == 2);
                intent.putExtra("isNeedReOpenListen", this.mIsListenTrans);
                intent.putExtra("isListenPause", this.mVoiceIsTran);
                setResult(-1, intent);
                finish();
                overridePendingTransition(0, android.R.anim.fade_out);
            }
            SpliceViewGLMonitor spliceViewGLMonitor = this.mMonitor;
            if (spliceViewGLMonitor != null) {
                spliceViewGLMonitor.FreeMonitor();
                this.mMonitor = null;
            }
        }
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_land_more:
                handLandMore();
                this.rl_landscape_one.setVisibility(8);
                this.rl_landscape_button.setVisibility(8);
                return;
            case R.id.iv_land_snapshot:
                if (HiTools.HiPermission(this, this, 1, MY_PERMISSION_REQUEST_CODE)) {
                    this.mIsOnpause = true;
                    return;
                } else {
                    clickSnapshot();
                    return;
                }
            case R.id.iv_landscape_listen:
                clickListen();
                return;
            case R.id.iv_landscape_record:
                if (HiTools.HiPermission(this, this, 1, MY_PERMISSION_REQUEST_CODE)) {
                    this.mIsOnpause = true;
                    return;
                } else {
                    clickRecording();
                    return;
                }
            case R.id.iv_landscape_talk:
                if (HiTools.HiPermission(this, this, 2, MY_PERMISSION_REQUEST_CODE)) {
                    this.mIsOnpause = true;
                    return;
                } else {
                    handTalkingNew();
                    return;
                }
            case R.id.ll_land_return:
                HiLogcatUtil.e("" + this.mIsSwitchResolution);
                if (!this.mIsSwitchResolution || this.isCountDown) {
                    this.isClickFinish = true;
                    if (this.isCountDown) {
                        AppManager.getInstance().killAllActivityNoMain(MainActivity.class);
                        return;
                    }
                    Intent intent = new Intent();
                    if (this.quality != 1) {
                        intent.putExtra("changedQuality1", this.cameraPosition == 1);
                        intent.putExtra("changedQuality2", this.cameraPosition == 2);
                        intent.putExtra("changedQuality3", this.cameraPosition == 3);
                        intent.putExtra("changedQuality4", this.cameraPosition == 4);
                    }
                    intent.putExtra("position", this.cameraPosition);
                    intent.putExtra("isListening", this.isListening);
                    intent.putExtra("isTalking", this.isTalking);
                    intent.putExtra("mStartRecordTime", this.mStartRecordTime);
                    intent.putExtra("isRecording", this.mRecordingState == 2);
                    intent.putExtra("isNeedReOpenListen", this.mIsListenTrans);
                    intent.putExtra("isListenPause", this.mVoiceIsTran);
                    setResult(-1, intent);
                    finish();
                    overridePendingTransition(0, android.R.anim.fade_out);
                    return;
                }
                return;
            case R.id.root_lock_screen:
                OrientationWatchDog orientationWatchDog = this.mOrientationWatchDog;
                if (orientationWatchDog != null) {
                    orientationWatchDog.setLockScreen(true);
                }
                this.root_lock_screen.setVisibility(8);
                this.mHandler_lockScreen.removeCallbacksAndMessages(null);
                return;
            case R.id.tv_landscape_video_quality:
                handVideoQuality(this.tv_landscape_video_quality);
                return;
            default:
                return;
        }
    }

    @Override
    public void onWindowFocusChanged(boolean z) {
        super.onWindowFocusChanged(z);
        hideBottomUIMenu();
    }

    private void handLandMore() {
        View inflate = View.inflate(this, R.layout.pup_splicelandscape_more, null);
        getWindowManager().getDefaultDisplay().getMetrics(new DisplayMetrics());
        PopupWindow popupWindow = new PopupWindow(inflate);
        popupWindow.setBackgroundDrawable(new ColorDrawable(0));
        popupWindow.setHeight(-1);
        popupWindow.setWidth(this.mDp_250);
        popupWindow.setOutsideTouchable(true);
        popupWindow.setAnimationStyle(R.style.AnimTopRight);
        popupWindow.showAtLocation(inflate, 17, getWindowManager().getDefaultDisplay().getWidth(), 0);
        this.ll_pup_content = (LinearLayout) inflate.findViewById(R.id.ll_pup_content);
        this.ll_pup_main = (LinearLayout) inflate.findViewById(R.id.ll_pup_main);
        ((ImageView) inflate.findViewById(R.id.land_iv_volume)).setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                LandLiveSpliceActivity.this.lambda$handLandMore$2$LandLiveSpliceActivity(view);
            }
        });
        ((ImageView) inflate.findViewById(R.id.iv_txtj_land)).setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                LandLiveSpliceActivity.this.lambda$handLandMore$3$LandLiveSpliceActivity(view);
            }
        });
        ImageView imageView = (ImageView) inflate.findViewById(R.id.iv_night_mode_land);
        LinearLayout linearLayout = (LinearLayout) inflate.findViewById(R.id.ll_night_mode_land);
        TextView textView = (TextView) inflate.findViewById(R.id.tv_name);
        linearLayout.setVisibility(this.lightModel == 0 ? 8 : 0);
        if (this.lightModel == 4) {
            textView.setText(R.string.light_and_sound_alarm);
        } else if (this.myCamera.appGetCommandFunction(ConstantCommand.HI_P2P_Garden_Lamp)) {
            textView.setText(R.string.gardenlight);
            imageView.setImageResource(R.mipmap.tyd_land);
        }
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                LandLiveSpliceActivity.this.lambda$handLandMore$4$LandLiveSpliceActivity(view);
            }
        });
    }

    public void lambda$handLandMore$2$LandLiveSpliceActivity(View view) {
        this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_GET_AUDIO_ATTR, null);
    }

    public void lambda$handLandMore$3$LandLiveSpliceActivity(View view) {
        this.mIsTXTJ = true;
        this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_GET_DISPLAY_PARAM, null);
    }

    public void lambda$handLandMore$4$LandLiveSpliceActivity(View view) {
        getLightParams();
    }

    private void handZoomAndFocus(View view) {
        if (view == null) {
            return;
        }
        ((TextView) view.findViewById(R.id.tv_zoomin)).setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view2, MotionEvent motionEvent) {
                if (motionEvent.getAction() == 0) {
                    LandLiveSpliceActivity.this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_PTZ_CTRL, HiChipDefines.HI_P2P_S_PTZ_CTRL.parseContent(0, 9, 0, (short) MyLiveViewGLMonitor.PTZ_STEP, (short) 10));
                } else if (motionEvent.getAction() == 1) {
                    LandLiveSpliceActivity.this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_PTZ_CTRL, HiChipDefines.HI_P2P_S_PTZ_CTRL.parseContent(0, 0, 0, (short) MyLiveViewGLMonitor.PTZ_STEP, (short) 10));
                }
                return false;
            }
        });
        ((TextView) view.findViewById(R.id.tv_zoomout)).setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view2, MotionEvent motionEvent) {
                if (motionEvent.getAction() == 0) {
                    LandLiveSpliceActivity.this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_PTZ_CTRL, HiChipDefines.HI_P2P_S_PTZ_CTRL.parseContent(0, 10, 0, (short) MyLiveViewGLMonitor.PTZ_STEP, (short) 10));
                } else if (motionEvent.getAction() == 1) {
                    LandLiveSpliceActivity.this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_PTZ_CTRL, HiChipDefines.HI_P2P_S_PTZ_CTRL.parseContent(0, 0, 0, (short) MyLiveViewGLMonitor.PTZ_STEP, (short) 10));
                }
                return false;
            }
        });
        ((TextView) view.findViewById(R.id.tv_focusin)).setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view2, MotionEvent motionEvent) {
                if (motionEvent.getAction() == 0) {
                    LandLiveSpliceActivity.this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_PTZ_CTRL, HiChipDefines.HI_P2P_S_PTZ_CTRL.parseContent(0, 11, 0, (short) MyLiveViewGLMonitor.PTZ_STEP, (short) 10));
                } else if (motionEvent.getAction() == 1) {
                    LandLiveSpliceActivity.this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_PTZ_CTRL, HiChipDefines.HI_P2P_S_PTZ_CTRL.parseContent(0, 0, 0, (short) MyLiveViewGLMonitor.PTZ_STEP, (short) 10));
                }
                return false;
            }
        });
        ((TextView) view.findViewById(R.id.tv_focusout)).setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view2, MotionEvent motionEvent) {
                if (motionEvent.getAction() == 0) {
                    LandLiveSpliceActivity.this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_PTZ_CTRL, HiChipDefines.HI_P2P_S_PTZ_CTRL.parseContent(0, 12, 0, (short) MyLiveViewGLMonitor.PTZ_STEP, (short) 10));
                } else if (motionEvent.getAction() == 1) {
                    LandLiveSpliceActivity.this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_PTZ_CTRL, HiChipDefines.HI_P2P_S_PTZ_CTRL.parseContent(0, 0, 0, (short) MyLiveViewGLMonitor.PTZ_STEP, (short) 10));
                }
                return false;
            }
        });
    }

    private void handLandShowContent(final View view) {
        this.ll_pup_main.setVisibility(8);
        this.ll_pup_content.setVisibility(0);
        this.ll_pup_content.removeAllViews();
        this.ll_pup_content.addView(view, new LinearLayout.LayoutParams(-1, -1));
        ObjectAnimator ofFloat = ObjectAnimator.ofFloat(view, "translationX", this.mDp_250, 0.0f);
        ofFloat.setDuration(300L);
        ofFloat.start();
        LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.ll_land_mirror_flip);
        if (linearLayout != null) {
            linearLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view2) {
                    ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(view, "translationX", 0.0f, LandLiveSpliceActivity.this.mDp_250);
                    ofFloat2.setDuration(300L);
                    ofFloat2.start();
                    ofFloat2.addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animator) {
                            super.onAnimationEnd(animator);
                            LandLiveSpliceActivity.this.ll_pup_content.setVisibility(8);
                            LandLiveSpliceActivity.this.ll_pup_content.removeAllViews();
                            LandLiveSpliceActivity.this.ll_pup_main.setVisibility(0);
                            ObjectAnimator ofFloat3 = ObjectAnimator.ofFloat(LandLiveSpliceActivity.this.ll_pup_main, "Alpha", 0.0f, 1.0f);
                            ofFloat3.setDuration(200L);
                            ofFloat3.start();
                        }
                    });
                }
            });
        }
    }

    private void getLightParams() {
        int i = this.lightModel;
        if (i == 1) {
            this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_WHITE_LIGHT_GET_EXT, null);
            return;
        }
        if (i == 2) {
            this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_WHITE_LIGHT_GET, null);
            return;
        }
        if (i == 3) {
            this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_GET_ABSOLUTE_LIGHT_TYPE, null);
        } else if (i == 4) {
            this.myCamera.sendIOCtrl(16790, null);
        } else {
            if (i != 5) {
                return;
            }
            this.myCamera.sendIOCtrl(ConstantCommand.HI_P2P_GET_Garden_Lamp, null);
        }
    }

    private void clickListen() {
        if (this.mRecordingState == 2) {
            if (this.mVoiceIsTran) {
                this.myCamera.PausePlayAudio();
                this.mIsListenTrans = false;
                if (this.isListening) {
                    this.myCamera.PausePlayAudio();
                    this.mIsListenTrans = false;
                } else {
                    this.myCamera.ResumePlayAudio();
                }
            } else {
                this.myCamera.stopRecording();
                this.myCamera.startListening();
                this.mVoiceIsTran = true;
                this.mStartRecordTime = 0;
                this.recordedTime = 0;
                TimerRecording();
            }
            if (this.isListening) {
                this.iv_landscape_listen.setSelected(false);
            } else {
                this.iv_landscape_listen.setSelected(true);
            }
        } else if (this.isListening) {
            this.iv_landscape_listen.setSelected(false);
            this.myCamera.stopListening();
            this.mIsListenTrans = false;
            this.mVoiceIsTran = false;
        } else {
            this.iv_landscape_listen.setSelected(true);
            this.myCamera.startListening();
            this.mVoiceIsTran = true;
        }
        if (this.isTalking) {
            this.iv_landscape_talk.setSelected(false);
            this.myCamera.stopTalk();
            this.isTalking = !this.isTalking;
        }
        this.isListening = !this.isListening;
    }

    private void handTalkingNew() {
        if (this.mRecordingState == 2) {
            if (this.isListening) {
                this.myCamera.PausePlayAudio();
                this.iv_landscape_listen.setSelected(false);
                this.isListening = !this.isListening;
                this.mIsListenTrans = true;
            }
        } else if (this.isListening) {
            this.myCamera.stopListening();
            this.mVoiceIsTran = false;
            this.iv_landscape_listen.setSelected(false);
            this.isListening = !this.isListening;
            this.mIsListenTrans = true;
        }
        if (this.isTalking) {
            this.myCamera.stopTalk();
            if (this.mIsListenTrans && !this.isListening) {
                if (this.mVoiceIsTran) {
                    this.myCamera.ResumePlayAudio();
                } else {
                    this.myCamera.startListening();
                    this.mVoiceIsTran = true;
                }
                this.iv_landscape_listen.setSelected(true);
                this.isListening = true;
            }
        } else {
            this.myCamera.startTalk();
        }
        boolean z = !this.isTalking;
        this.isTalking = z;
        this.iv_landscape_talk.setSelected(z);
    }

    private void clickRecording() {
        int i = this.mRecordingState;
        if (i == 0) {
            this.mRecordingState = 2;
            TimerRecording();
            this.mStartRecordTime = 0;
            this.iv_landscape_record.setSelected(true);
            this.ll_recording.setVisibility(0);
            this.iv_recording.setVisibility(0);
            this.mRecHandler.sendEmptyMessage(110);
            return;
        }
        if (i == 2) {
            this.mRecordingState = 0;
            if (this.mVoiceIsTran && !this.iv_landscape_listen.isSelected()) {
                this.myCamera.stopListening();
                this.mVoiceIsTran = false;
            }
            this.myCamera.stopRecording();
            Timer timer = this.timer;
            if (timer != null) {
                timer.cancel();
                this.timer = null;
            }
            TimerTask timerTask = this.timerTask;
            if (timerTask != null) {
                timerTask.cancel();
                this.timerTask = null;
            }
            this.iv_landscape_record.setSelected(false);
            this.ll_recording.setVisibility(4);
            this.iv_recording.setVisibility(4);
            this.mRecHandler.removeCallbacksAndMessages(null);
        }
    }

    private void TimerRecording() {
        Timer timer = this.timer;
        if (timer != null) {
            timer.cancel();
            this.timer = null;
        }
        TimerTask timerTask = this.timerTask;
        if (timerTask != null) {
            timerTask.cancel();
            this.timerTask = null;
        }
        final File file = new File(HiDataValue.getPathCameraVideoLocalRecord(this.myCamera.getUid(), this));
        if (!file.exists()) {
            file.mkdirs();
        }
        this.timer = new Timer();
        TimerTask timerTask2 = new TimerTask() {
            @Override
            public void run() {
                if (LandLiveSpliceActivity.this.mRecordingState == 2) {
                    LandLiveSpliceActivity.this.myCamera.stopRecording();
                }
                if (LandLiveSpliceActivity.this.myCamera.getdevDual()) {
                    boolean z = LandLiveSpliceActivity.this.myCamera.getdevDual();
                    LandLiveSpliceActivity.this.recordFile = file.getAbsoluteFile() + "/" + HiTools.getFileNameWithTimeExt(1, z ? 1 : 0);
                    int i = LandLiveSpliceActivity.this.myCamera.getdevDual() ? 2 : z ? 1 : 0;
                    LandLiveSpliceActivity.this.record2File = file.getAbsoluteFile() + "/" + HiTools.getFileNameWithTimeExt(1, i);
                } else {
                    LandLiveSpliceActivity.this.recordFile = file.getAbsoluteFile() + "/" + HiTools.getFileNameWithTime(1);
                }
                long availableSize = HiTools.getAvailableSize();
                if (availableSize >= 100 || availableSize <= 0) {
                    if (LandLiveSpliceActivity.this.isFirst) {
                        LandLiveSpliceActivity.this.mHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                if (!LandLiveSpliceActivity.this.myCamera.getdevDual()) {
                                    LandLiveSpliceActivity.this.myCamera.startRecording(LandLiveSpliceActivity.this.recordFile);
                                } else {
                                    LandLiveSpliceActivity.this.myCamera.startRecordingExt(LandLiveSpliceActivity.this.recordFile, LandLiveSpliceActivity.this.record2File);
                                }
                                LandLiveSpliceActivity.this.isFirst = false;
                            }
                        });
                        return;
                    } else {
                        LandLiveSpliceActivity.this.mHandler.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                if (!LandLiveSpliceActivity.this.myCamera.getdevDual()) {
                                    LandLiveSpliceActivity.this.myCamera.startRecording(LandLiveSpliceActivity.this.recordFile);
                                } else {
                                    LandLiveSpliceActivity.this.myCamera.startRecordingExt(LandLiveSpliceActivity.this.recordFile, LandLiveSpliceActivity.this.record2File);
                                }
                            }
                        }, 1000L);
                        return;
                    }
                }
                LandLiveSpliceActivity.this.mHandler.sendEmptyMessage(WiFiSettingActivity.SET_WIFI_END);
            }
        };
        this.timerTask = timerTask2;
        if (this.recordedTime == 0) {
            this.timer.schedule(timerTask2, 0L, TTAdConstant.AD_MAX_EVENT_TIME);
        } else {
            this.isFirst = false;
            this.timer.schedule(timerTask2, 600000 - r0, TTAdConstant.AD_MAX_EVENT_TIME);
        }
    }

    public void clickSnapshot() {
        if (this.myCamera != null) {
            if (HiTools.isSDCardValid()) {
                File file = new File(HiDataValue.getPathCameraSnapshot(this.myCamera.getUid(), this));
                if (!file.exists()) {
                    file.mkdirs();
                }
                String fileNameWithTime = HiTools.getFileNameWithTime(0);
                String str = file.getAbsoluteFile() + "/" + fileNameWithTime;
                MyCamera myCamera = this.myCamera;
                Bitmap snapshot = myCamera != null ? myCamera.getSnapshot() : null;
                if (snapshot != null && HiTools.saveImage(str, snapshot)) {
                    SaveToPhone(str, fileNameWithTime);
                    Toast.makeText(this, getText(R.string.tips_snapshot_success), 0).show();
                    return;
                } else {
                    Toast.makeText(this, getText(R.string.tips_snapshot_failed), 0).show();
                    return;
                }
            }
            Toast.makeText(this, getText(R.string.tips_no_sdcard).toString(), 0).show();
        }
    }

    private void SaveToPhone(final String str, final String str2) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    MediaStore.Images.Media.insertImage(LandLiveSpliceActivity.this.getContentResolver(), str, str2, (String) null);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                LandLiveSpliceActivity.this.sendBroadcast(new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE", Uri.parse("file://" + str)));
            }
        }).start();
    }

    private void handVideoQuality(View view) {
        HiLogcatUtil.e("" + this.mIsSwitchResolution);
        if (this.mIsSwitchResolution) {
            return;
        }
        clickRatio((TextView) view);
    }

    private void clickRatio(TextView textView) {
        View inflate = getLayoutInflater().inflate(R.layout.popview_resolution_ratio, (ViewGroup) null, false);
        final PopupWindow popupWindow = new PopupWindow(inflate);
        popupWindow.setBackgroundDrawable(new ColorDrawable(0));
        popupWindow.setOutsideTouchable(true);
        popupWindow.setFocusable(false);
        popupWindow.setWidth(-2);
        popupWindow.setHeight(-2);
        int[] iArr = new int[2];
        textView.getLocationOnScreen(iArr);
        popupWindow.showAtLocation(textView, 0, iArr[0] - (!this.isLeft ? 0 : LiuHaiScreenTools.getNotchHeight(this) - HiTools.dip2px(this, 5.0f)), iArr[1] - HiTools.dip2px(this, 90.0f));
        final TextView textView2 = (TextView) inflate.findViewById(R.id.ratio_high);
        final TextView textView3 = (TextView) inflate.findViewById(R.id.ratio_fluent);
        int i = this.quality;
        if (i == 0) {
            textView2.setSelected(true);
            textView3.setSelected(false);
        } else if (i == 1) {
            textView2.setSelected(false);
            textView3.setSelected(true);
        }
        textView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                LandLiveSpliceActivity.this.lambda$clickRatio$5$LandLiveSpliceActivity(popupWindow, textView2, textView3, view);
            }
        });
        textView3.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                LandLiveSpliceActivity.this.lambda$clickRatio$6$LandLiveSpliceActivity(popupWindow, textView3, textView2, view);
            }
        });
    }

    public void lambda$clickRatio$5$LandLiveSpliceActivity(PopupWindow popupWindow, TextView textView, TextView textView2, View view) {
        popupWindow.dismiss();
        textView.setSelected(true);
        textView2.setSelected(false);
        HiLogcatUtil.e("");
        switchVideoQuality(0);
    }

    public void lambda$clickRatio$6$LandLiveSpliceActivity(PopupWindow popupWindow, TextView textView, TextView textView2, View view) {
        popupWindow.dismiss();
        textView.setSelected(true);
        textView2.setSelected(false);
        HiLogcatUtil.e("");
        switchVideoQuality(1);
    }

    private void switchVideoQuality(int i) {
        if (this.myCamera == null || i == this.quality) {
            return;
        }
        HiLogcatUtil.e("" + this.mIsSwitchResolution);
        this.mIsSwitchResolution = true;
        this.quality = i;
        setViewWhetherClick(false);
        this.myCamera.stopListening();
        this.iv_landscape_listen.setSelected(false);
        this.mIsListenTrans = false;
        this.isListening = false;
        this.mVoiceIsTran = false;
        if (this.isTalking) {
            this.myCamera.stopTalk();
            this.isTalking = false;
            this.iv_landscape_talk.setSelected(false);
        }
        this.myCamera.ChangeStream(this.quality);
    }

    private void setViewWhetherClick(boolean z) {
        this.iv_landscape_listen.setClickable(z);
        this.iv_landscape_record.setClickable(z);
        this.iv_land_snapshot.setClickable(z);
        this.iv_landscape_talk.setClickable(z);
    }

    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {
        if (view.getId() == R.id.live_monitor) {
            int pointerCount = motionEvent.getPointerCount();
            if ((motionEvent.getAction() & 255) == 5 && 2 == pointerCount) {
                this.mMonitor.setTouchMove(2);
                for (int i = 0; i < pointerCount; i++) {
                    new Point((int) motionEvent.getX(i), (int) motionEvent.getY(i));
                }
                this.xlenOld = Math.abs(((int) motionEvent.getX(0)) - ((int) motionEvent.getX(1)));
                int abs = Math.abs(((int) motionEvent.getY(0)) - ((int) motionEvent.getY(1)));
                this.ylenOld = abs;
                int i2 = this.xlenOld;
                this.nLenStart = Math.sqrt((i2 * i2) + (abs * abs));
            } else {
                if ((motionEvent.getAction() & 255) == 2 && 2 == pointerCount) {
                    this.mMonitor.setTouchMove(2);
                    for (int i3 = 0; i3 < pointerCount; i3++) {
                        new Point((int) motionEvent.getX(i3), (int) motionEvent.getY(i3));
                    }
                    int abs2 = Math.abs(((int) motionEvent.getX(0)) - ((int) motionEvent.getX(1)));
                    int abs3 = Math.abs(((int) motionEvent.getY(0)) - ((int) motionEvent.getY(1)));
                    int abs4 = Math.abs(abs2 - this.xlenOld);
                    int abs5 = Math.abs(abs3 - this.ylenOld);
                    double d = abs2;
                    double d2 = abs3;
                    double sqrt = Math.sqrt((d * d) + (d2 * d2));
                    if (abs4 < 20 && abs5 < 20) {
                        return false;
                    }
                    if (sqrt > this.nLenStart) {
                        resetMonitorSize(true, sqrt);
                    } else {
                        resetMonitorSize(false, sqrt);
                    }
                    this.xlenOld = abs2;
                    this.ylenOld = abs3;
                    this.nLenStart = sqrt;
                    return true;
                }
                if (pointerCount == 1) {
                    int action = motionEvent.getAction();
                    if (action == 0) {
                        this.down_X = motionEvent.getRawX();
                        this.down_Y = motionEvent.getRawY();
                        this.action_down_x = motionEvent.getRawX();
                        float rawY = motionEvent.getRawY();
                        this.action_down_y = rawY;
                        this.lastX = this.action_down_x;
                        this.lastY = rawY;
                        this.mMonitor.setTouchMove(0);
                    } else if (action != 1) {
                        if (action == 2 && this.mMonitor.getTouchMove() == 0) {
                            this.move_x = motionEvent.getRawX();
                            this.move_y = motionEvent.getRawY();
                        }
                    } else if (this.mMonitor.getTouchMove() == 0 && this.mMonitor.getState() == 0) {
                        float rawX = motionEvent.getRawX();
                        float rawY2 = motionEvent.getRawY();
                        float f = rawX - this.down_X;
                        float f2 = rawY2 - this.down_Y;
                        if (Math.abs(f) >= HiTools.dip2px(this, 2.0f) || Math.abs(f2) >= HiTools.dip2px(this, 2.0f)) {
                            short s = 58;
                            if (this.myCamera.getChipVersion() == 1 && this.myCamera.getDeviceType() != 3) {
                                s = 25;
                            }
                            if (f > 0.0f && Math.abs(f) > Math.abs(f2)) {
                                int abs6 = (int) ((Math.abs(f) / (this.mMonitor.screen_width / 2)) * 100.0f);
                                if (abs6 > 100) {
                                    abs6 = 100;
                                }
                                if (abs6 <= 0) {
                                    abs6 = 1;
                                }
                                if (!this.myCamera.getdevDual()) {
                                    this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_PTZ_CTRL, HiChipDefines.HI_P2P_S_PTZ_CTRL.parseContent(0, 2, 1, s, (short) abs6));
                                }
                            }
                            if (f < 0.0f && Math.abs(f) > Math.abs(f2)) {
                                int abs7 = (int) ((Math.abs(f) / (this.mMonitor.screen_width / 2)) * 100.0f);
                                if (abs7 > 100) {
                                    abs7 = 100;
                                }
                                if (abs7 <= 0) {
                                    abs7 = 1;
                                }
                                if (!this.myCamera.getdevDual()) {
                                    this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_PTZ_CTRL, HiChipDefines.HI_P2P_S_PTZ_CTRL.parseContent(0, 1, 1, s, (short) abs7));
                                }
                            }
                            if (f2 > 0.0f && Math.abs(f2) > Math.abs(f)) {
                                int abs8 = (int) ((Math.abs(f2) / (this.mMonitor.screen_width / 2)) * 100.0f);
                                if (abs8 > 100) {
                                    abs8 = 100;
                                }
                                if (abs8 <= 0) {
                                    abs8 = 1;
                                }
                                if (!this.myCamera.getdevDual()) {
                                    this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_PTZ_CTRL, HiChipDefines.HI_P2P_S_PTZ_CTRL.parseContent(0, 4, 1, s, (short) abs8));
                                }
                            }
                            if (f2 < 0.0f && Math.abs(f2) > Math.abs(f)) {
                                int abs9 = (int) ((Math.abs(f2) / (this.mMonitor.screen_width / 2)) * 100.0f);
                                int i4 = abs9 <= 100 ? abs9 : 100;
                                if (i4 <= 0) {
                                    i4 = 1;
                                }
                                if (!this.myCamera.getdevDual()) {
                                    this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_PTZ_CTRL, HiChipDefines.HI_P2P_S_PTZ_CTRL.parseContent(0, 3, 1, s, (short) i4));
                                }
                            }
                        }
                    }
                }
            }
        }
        return false;
    }

    private void resetMonitorSize(boolean z, double d) {
        this.isLarge = z ? 1 : 2;
        HiLogcatUtil.e("initViewAndData" + this.mMonitor.left + Constants.COLON_SEPARATOR + this.mMonitor.bottom + Constants.COLON_SEPARATOR + this.mMonitor.width + Constants.COLON_SEPARATOR + this.mMonitor.height + Constants.COLON_SEPARATOR);
        if (this.mMonitor.height == 0 && this.mMonitor.width == 0) {
            initMatrix(this.mMonitor.screen_width, this.mMonitor.screen_height);
        }
        int i = (int) (d / 2.0d);
        this.moveX = i;
        this.moveY = (i * 9) / 32;
        if (!z) {
            if (this.mMonitor.width > this.mMonitor.screen_width && this.mMonitor.left == 0 && this.mMonitor.bottom >= 0 && this.mMonitor.height > (this.mMonitor.screen_width * 9.0d) / 32.0d) {
                this.mMonitor.bottom -= this.moveY / 2;
                this.mMonitor.width -= this.moveX;
                this.mMonitor.height -= this.moveY;
                if (this.mMonitor.height <= (this.mMonitor.screen_width * 9.0d) / 32.0d) {
                    this.mMonitor.height = (int) ((r12.screen_width * 9.0d) / 32.0d);
                }
                if (this.mMonitor.width <= this.mMonitor.screen_width) {
                    SpliceViewGLMonitor spliceViewGLMonitor = this.mMonitor;
                    spliceViewGLMonitor.width = spliceViewGLMonitor.screen_width;
                }
                if (this.mMonitor.bottom >= ((int) (this.mMonitor.screen_height - (((this.mMonitor.screen_width * 9.0d) / 32.0d) / 2.0d)))) {
                    this.mMonitor.bottom = (int) (r12.screen_height - (((this.mMonitor.screen_width * 9.0d) / 32.0d) / 2.0d));
                }
            } else {
                this.mMonitor.left += this.moveX / 2;
                this.mMonitor.bottom += this.moveY / 2;
                this.mMonitor.width -= this.moveX;
                this.mMonitor.height -= this.moveY;
            }
            if (this.mMonitor.bottom + this.mMonitor.height < this.mMonitor.screen_height) {
                SpliceViewGLMonitor spliceViewGLMonitor2 = this.mMonitor;
                spliceViewGLMonitor2.bottom = (spliceViewGLMonitor2.screen_height - this.mMonitor.height) / 2;
            }
            if (this.mMonitor.left + this.mMonitor.width < this.mMonitor.screen_width) {
                SpliceViewGLMonitor spliceViewGLMonitor3 = this.mMonitor;
                spliceViewGLMonitor3.left = spliceViewGLMonitor3.screen_width - this.mMonitor.width;
            }
        } else if (this.mMonitor.width <= this.largeMul * this.mMonitor.screen_width && this.mMonitor.height <= ((this.largeMul * this.mMonitor.screen_width) * 9.0d) / 32.0d) {
            this.mMonitor.left -= this.moveX / 2;
            this.mMonitor.bottom -= this.moveY / 2;
            this.mMonitor.width += this.moveX;
            this.mMonitor.height += this.moveY;
        }
        if (this.mMonitor.left > 0 || this.mMonitor.width < this.mMonitor.screen_width) {
            if (this.mMonitor.left >= 0 && this.mMonitor.width > this.mMonitor.screen_width) {
                this.mMonitor.left = 0;
            }
            if (this.mMonitor.width <= this.mMonitor.screen_width || this.mMonitor.height <= ((int) ((this.mMonitor.screen_width * 9.0d) / 32.0d))) {
                initMatrix(this.mMonitor.screen_width, (int) ((this.mMonitor.screen_width * 9.0d) / 32.0d));
            }
            SpliceViewGLMonitor spliceViewGLMonitor4 = this.mMonitor;
            spliceViewGLMonitor4.bottom = (spliceViewGLMonitor4.screen_height - this.mMonitor.height) / 2;
        }
        if (this.mMonitor.width > this.mMonitor.screen_width) {
            if (this.mMonitor.getState() == 0) {
                this.humanRectView.cleanRect(true);
            }
            this.mMonitor.setState(1);
        } else {
            if (this.mMonitor.getState() == 1) {
                this.humanRectView.cleanRect(false);
            }
            this.mMonitor.setState(0);
        }
        SpliceViewGLMonitor spliceViewGLMonitor5 = this.mMonitor;
        spliceViewGLMonitor5.setMatrix(spliceViewGLMonitor5.left, this.mMonitor.bottom, this.mMonitor.width, this.mMonitor.height);
    }

    private void initMatrix(int i, int i2) {
        this.mMonitor.left = 0;
        this.mMonitor.bottom = 0;
        this.mMonitor.width = i;
        this.mMonitor.height = i2;
    }

    @Override
    public void receiveSessionState(HiCamera hiCamera, int i) {
        Message obtainMessage = this.mIOHandler.obtainMessage();
        obtainMessage.what = HiDataValue.HANDLE_MESSAGE_SESSION_STATE;
        obtainMessage.arg1 = i;
        obtainMessage.obj = hiCamera;
        this.mIOHandler.sendMessage(obtainMessage);
    }

    @Override
    public void receiveIOCtrlData(HiCamera hiCamera, int i, byte[] bArr, int i2) {
        HiLogcatUtil.e("" + i + ":::" + i2);
        Bundle bundle = new Bundle();
        bundle.putByteArray("data", bArr);
        Message obtainMessage = this.mIOHandler.obtainMessage();
        obtainMessage.what = HiDataValue.HANDLE_MESSAGE_RECEIVE_IOCTRL;
        obtainMessage.obj = hiCamera;
        obtainMessage.arg1 = i;
        obtainMessage.arg2 = i2;
        obtainMessage.setData(bundle);
        this.mIOHandler.sendMessage(obtainMessage);
    }

    @Override
    public void callbackStateDual(HiCamera hiCamera, int i, int i2, int i3, int i4) {
        if (HiTools.mDualvalue == 0 || HiTools.mDualvalue == 1) {
            if (i == 2) {
                return;
            }
        } else if (HiTools.mDualvalue == 2 && i == 1) {
            return;
        }
        Bundle bundle = new Bundle();
        bundle.putInt(a.k, i2);
        bundle.putString(HiDataValue.EXTRAS_KEY_UID, hiCamera.getUid());
        Message obtainMessage = this.mHandler.obtainMessage();
        obtainMessage.what = HiDataValue.HANDLE_MESSAGE_PLAY_STATE;
        obtainMessage.setData(bundle);
        this.mHandler.sendMessage(obtainMessage);
    }

    @Override
    public void callbackState(HiCamera hiCamera, int i, int i2, int i3) {
        Bundle bundle = new Bundle();
        bundle.putInt(a.k, i);
        bundle.putString(HiDataValue.EXTRAS_KEY_UID, hiCamera.getUid());
        Message obtainMessage = this.mHandler.obtainMessage();
        obtainMessage.what = HiDataValue.HANDLE_MESSAGE_PLAY_STATE;
        obtainMessage.setData(bundle);
        this.mHandler.sendMessage(obtainMessage);
    }

    @Override
    public void callbackRecordState(HiCamera hiCamera, int i, int i2, int i3, String str) {
        Bundle bundle = new Bundle();
        bundle.putInt(a.k, i);
        bundle.putString(TTDownloadField.TT_FILE_NAME, str);
        bundle.putString(HiDataValue.EXTRAS_KEY_UID, hiCamera.getUid());
        Message obtainMessage = this.mHandler.obtainMessage();
        obtainMessage.what = HiDataValue.HANDLE_MESSAGE_PLAY_STATE;
        obtainMessage.setData(bundle);
        this.mHandler.sendMessage(obtainMessage);
    }

    @Override
    public void callbackRecordStateDual(HiCamera hiCamera, int i, int i2, int i3, int i4, String str) {
        Bundle bundle = new Bundle();
        bundle.putInt(a.k, i2);
        bundle.putString(TTDownloadField.TT_FILE_NAME, str);
        bundle.putString(HiDataValue.EXTRAS_KEY_UID, hiCamera.getUid());
        Message obtainMessage = this.mHandler.obtainMessage();
        obtainMessage.what = HiDataValue.HANDLE_MESSAGE_PLAY_STATE;
        obtainMessage.setData(bundle);
        this.mHandler.sendMessage(obtainMessage);
    }

    public void handIOCTRLFail(Message message, MyCamera myCamera) {
        int i = message.arg1;
        if (i != 4097) {
            if (i != 12550) {
                return;
            }
            dismissLoadingView();
            return;
        }
        this.iv_recording.removeCallbacks(this.runnable);
        this.isCountDown = false;
        HiLogcatUtil.eTag("==test44", this.mIsSwitchResolution + "");
        this.mIsSwitchResolution = false;
        setViewWhetherClick(true);
        if (this.firstInChangeStream) {
            if (myCamera != null && this.quality == 0) {
                this.quality = 1;
                this.myCamera.ChangeStream(1);
                return;
            } else {
                backToFourLive();
                return;
            }
        }
        MyCamera myCamera2 = this.myCamera;
        if (myCamera2 != null && myCamera2.getVideoQuality() != this.quality) {
            this.quality = this.myCamera.getVideoQuality();
            MyCamera myCamera3 = this.myCamera;
            myCamera3.ChangeStream(myCamera3.getVideoQuality());
            return;
        }
        backToFourLive();
    }

    private void backToFourLive() {
        MyCamera myCamera = this.myCamera;
        if (myCamera != null) {
            myCamera.stopPlayback();
        }
        this.isReceiveDisconnect = true;
        MyToast.showToast(getApplicationContext(), getString(R.string.netword_abnormal));
        Intent intent = new Intent();
        if (this.quality != 1) {
            intent.putExtra("changedQuality1", this.cameraPosition == 1);
            intent.putExtra("changedQuality2", this.cameraPosition == 2);
            intent.putExtra("changedQuality3", this.cameraPosition == 3);
            intent.putExtra("changedQuality4", this.cameraPosition == 4);
        }
        intent.putExtra("position", this.cameraPosition);
        intent.putExtra("isListening", this.isListening);
        intent.putExtra("isTalking", this.isTalking);
        intent.putExtra("mStartRecordTime", this.mStartRecordTime);
        intent.putExtra("isRecording", this.mRecordingState == 2);
        intent.putExtra("isNeedReOpenListen", this.mIsListenTrans);
        intent.putExtra("isListenPause", this.mVoiceIsTran);
        setResult(-1, intent);
        finish();
    }

    public void handIOCTRLSuccess(Message message, final MyCamera myCamera) {
        LinearLayout linearLayout;
        String string;
        byte[] byteArray = message.getData().getByteArray("data");
        int i = message.arg1;
        if (i == 4097) {
            HiLogcatUtil.e("" + this.mIsSwitchResolution + ":" + this.firstInChangeStream + "::" + this.quality);
            this.monitor_width = Packet.byteArrayToInt_Little(byteArray, 4);
            int byteArrayToInt_Little = Packet.byteArrayToInt_Little(byteArray, 8);
            this.monitor_height = byteArrayToInt_Little;
            int i2 = this.monitor_width;
            if (i2 <= 0 || byteArrayToInt_Little <= 0 || i2 > 5000 || byteArrayToInt_Little > 5000) {
                finish();
                MyToast.showToast(this, getString(R.string.tips_open_video_fail));
                return;
            }
            if (this.firstInChangeStream && this.quality == 1) {
                this.firstInChangeStream = false;
                HiLogcatUtil.eTag("==test55", this.mIsSwitchResolution + "");
                this.mIsSwitchResolution = false;
                this.isCountDown = false;
                this.iv_recording.removeCallbacks(this.runnable);
                if (!this.mIsTalking && this.mIsListening) {
                    this.iv_landscape_listen.setSelected(true);
                    clickListen();
                }
                if (this.mIsTalking && !this.mIsListening) {
                    handTalkingNew();
                }
                if (this.mIsRecording) {
                    this.isFirst = false;
                    clickRecording();
                    this.mStartRecordTime = getIntent().getIntExtra("mStartRecordTime", 0);
                }
                this.myCamera.setVideoQuality(this.quality);
                this.myCamera.updateInDatabase(this);
                this.tv_landscape_video_quality.setText(getString(this.quality == 0 ? R.string.high_definition : R.string.fluent));
                return;
            }
            return;
        }
        if (i == 12807) {
            dismissLoadingView();
            this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_GET_DISPLAY_PARAM, new byte[0]);
            return;
        }
        if (i == 16678) {
            if (this.lightModel != 2) {
                return;
            }
            this.light_info = new HiChipDefines.HI_P2P_WHITE_LIGHT_INFO(byteArray);
            if (this.mMonitor.getmIsFullScreen() == 1) {
                showPupLight();
                return;
            }
            return;
        }
        if (i == 16682) {
            if (this.lightModel != 1) {
                return;
            }
            this.light_info_ext = new HiChipDefines.HI_P2P_WHITE_LIGHT_INFO_EXT(byteArray);
            if (this.mMonitor.getmIsFullScreen() == 1) {
                showPupLight();
                return;
            }
            return;
        }
        if (i == 16766) {
            if (this.lightModel != 3) {
                return;
            }
            this.abs_light = new HiChipDefines.ABSOLUTE_LIGHT_TYPE(byteArray);
            if (this.mMonitor.getmIsFullScreen() == 1) {
                showPupLight();
                return;
            }
            return;
        }
        if (i == 16790) {
            this.audible_visual_alarm_type = new ConstantCommand.HI_P2P_S_AUDIBLE_VISUAL_ALARM_TYPE(byteArray);
            if (this.mMonitor.getmIsFullScreen() == 1) {
                showPupLight();
                return;
            }
            return;
        }
        if (i == 16841) {
            if (this.lightModel != 5) {
                return;
            }
            this.mGarden_lamp_info = new ConstantCommand.HI_P2P_Garden_Lamp_INFO(byteArray);
            HiLog.e("HI_P2P_GET_Garden_Lamp" + this.myCamera.getUid() + "" + this.mGarden_lamp_info.u32Enable + ":::" + this.mGarden_lamp_info.u32State);
            if (this.lightModel == 5 && this.mMonitor.getmIsFullScreen() == 1) {
                showPupLight();
                return;
            }
            return;
        }
        if (i == 33027) {
            if (this.mFlagPreset == 1) {
                MyToast.showToast(this, getString(R.string.tips_preset_set_btn));
                return;
            }
            return;
        }
        if (i == 61446) {
            if (this.receiveHumanParams) {
                EventBus.getDefault().post(byteArray);
                return;
            }
            return;
        }
        if (i == 12549) {
            if (byteArray == null) {
                return;
            }
            this.display_param = new HiChipDefines.HI_P2P_S_DISPLAY(byteArray);
            if (this.ll_pup_main == null || (linearLayout = this.ll_pup_content) == null) {
                return;
            }
            if (this.mIsTXTJ) {
                if (linearLayout.getChildCount() > 0) {
                    SeekBar seekBar = this.sb_brightness;
                    if (seekBar != null) {
                        seekBar.setProgress(this.display_param.u32Brightness);
                    }
                    TextView textView = this.tv_brightness;
                    if (textView != null) {
                        textView.setText(this.display_param.u32Brightness + "");
                    }
                    SeekBar seekBar2 = this.sb_contrast;
                    if (seekBar2 != null) {
                        seekBar2.setProgress(this.display_param.u32Contrast);
                    }
                    TextView textView2 = this.tv_contrast;
                    if (textView2 != null) {
                        textView2.setText(this.display_param.u32Contrast + "");
                    }
                    SeekBar seekBar3 = this.sb_saturation;
                    if (seekBar3 != null) {
                        seekBar3.setProgress(this.display_param.u32Saturation);
                    }
                    TextView textView3 = this.tv_saturation;
                    if (textView3 != null) {
                        textView3.setText(this.display_param.u32Saturation + "");
                        return;
                    }
                    return;
                }
                View inflate = View.inflate(this, R.layout.view_land_txtj, null);
                handLandShowContent(inflate);
                SeekBar seekBar4 = (SeekBar) inflate.findViewById(R.id.sb_brightness);
                this.sb_brightness = seekBar4;
                seekBar4.setMax(this.myCamera.brightness);
                this.sb_brightness.setProgress(this.display_param.u32Brightness);
                this.sb_brightness.setOnSeekBarChangeListener(this);
                TextView textView4 = (TextView) inflate.findViewById(R.id.tv_brightness);
                this.tv_brightness = textView4;
                textView4.setText(this.display_param.u32Brightness + "");
                SeekBar seekBar5 = (SeekBar) inflate.findViewById(R.id.sb_contrast);
                this.sb_contrast = seekBar5;
                seekBar5.setMax(this.myCamera.contrast);
                this.sb_contrast.setProgress(this.display_param.u32Contrast);
                this.sb_contrast.setOnSeekBarChangeListener(this);
                TextView textView5 = (TextView) inflate.findViewById(R.id.tv_contrast);
                this.tv_contrast = textView5;
                textView5.setText(this.display_param.u32Contrast + "");
                SeekBar seekBar6 = (SeekBar) inflate.findViewById(R.id.sb_saturation);
                this.sb_saturation = seekBar6;
                seekBar6.setMax(this.myCamera.saturation);
                this.sb_saturation.setProgress(this.display_param.u32Saturation);
                this.sb_saturation.setOnSeekBarChangeListener(this);
                TextView textView6 = (TextView) inflate.findViewById(R.id.tv_saturation);
                this.tv_saturation = textView6;
                textView6.setText(this.display_param.u32Saturation + "");
                ((TextView) inflate.findViewById(R.id.tv_restore_default)).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        LandLiveSpliceActivity.this.showLoadingView();
                        myCamera.sendIOCtrl(HiChipDefines.HI_P2P_DEF_DISPLAY_PARAM, new byte[0]);
                    }
                });
                return;
            }
            View inflate2 = View.inflate(this, R.layout.view_land_mirror_flip, null);
            handLandShowContent(inflate2);
            handMirrorFlip(inflate2);
            return;
        }
        if (i != 12550) {
            if (i == 12561) {
                HiChipDefines.HI_P2P_S_AUDIO_ATTR hi_p2p_s_audio_attr = new HiChipDefines.HI_P2P_S_AUDIO_ATTR(byteArray);
                this.audio_attr = hi_p2p_s_audio_attr;
                if (hi_p2p_s_audio_attr.u32InMode == 0) {
                    this.mInputMethod = 0;
                } else if (this.audio_attr.u32InMode == 1) {
                    this.mInputMethod = 1;
                }
                View inflate3 = View.inflate(this, R.layout.view_land_volume, null);
                handLandShowContent(inflate3);
                if (this.myCamera.getChipVersion() == 1) {
                    this.maxInputValue = 16;
                    this.maxOutputValue = 13;
                }
                this.seekBar_input = (SeekBar) inflate3.findViewById(R.id.seekbar_input);
                final TextView textView7 = (TextView) inflate3.findViewById(R.id.txt_input_value);
                HiChipDefines.HI_P2P_S_AUDIO_ATTR hi_p2p_s_audio_attr2 = this.audio_attr;
                if (hi_p2p_s_audio_attr2 != null) {
                    this.seekBar_input.setProgress(hi_p2p_s_audio_attr2.u32InVol - 1);
                    textView7.setText(String.valueOf(this.audio_attr.u32InVol));
                }
                this.seekBar_input.setMax(this.maxInputValue - 1);
                this.seekBar_input.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                    @Override
                    public void onStartTrackingTouch(SeekBar seekBar7) {
                    }

                    @Override
                    public void onProgressChanged(SeekBar seekBar7, int i3, boolean z) {
                        textView7.setText(String.valueOf(seekBar7.getProgress() + 1));
                    }

                    @Override
                    public void onStopTrackingTouch(SeekBar seekBar7) {
                        LandLiveSpliceActivity.this.sendToDevice();
                    }
                });
                this.seekBar_output = (SeekBar) inflate3.findViewById(R.id.seekbar_output);
                final TextView textView8 = (TextView) inflate3.findViewById(R.id.txt_output_value);
                HiChipDefines.HI_P2P_S_AUDIO_ATTR hi_p2p_s_audio_attr3 = this.audio_attr;
                if (hi_p2p_s_audio_attr3 != null) {
                    this.seekBar_output.setProgress(hi_p2p_s_audio_attr3.u32OutVol - 1);
                    textView8.setText(String.valueOf(this.audio_attr.u32OutVol));
                }
                this.seekBar_output.setMax(this.maxOutputValue - 1);
                this.seekBar_output.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                    @Override
                    public void onStartTrackingTouch(SeekBar seekBar7) {
                    }

                    @Override
                    public void onProgressChanged(SeekBar seekBar7, int i3, boolean z) {
                        textView8.setText(String.valueOf(seekBar7.getProgress() + 1));
                    }

                    @Override
                    public void onStopTrackingTouch(SeekBar seekBar7) {
                        LandLiveSpliceActivity.this.sendToDevice();
                    }
                });
                return;
            }
            if (i != 12562) {
                if (i != 16805) {
                    if (i != 16806) {
                        return;
                    }
                    ConstantCommand.HI_P2P_S_SIGNAL_OPERATOR_EXT hi_p2p_s_signal_operator_ext = new ConstantCommand.HI_P2P_S_SIGNAL_OPERATOR_EXT(byteArray);
                    if (hi_p2p_s_signal_operator_ext.s32ShowSignal == 1 || hi_p2p_s_signal_operator_ext.s32ShowName == 1) {
                        this.ll_4g_signal.setVisibility(0);
                    } else {
                        this.ll_4g_signal.setVisibility(8);
                    }
                    if (hi_p2p_s_signal_operator_ext.s32ShowSignal == 1 && hi_p2p_s_signal_operator_ext.s32SignalQuality > 0) {
                        this.ll_signal.setVisibility(0);
                        if (hi_p2p_s_signal_operator_ext.s32SignalQuality >= 0 && hi_p2p_s_signal_operator_ext.s32SignalQuality <= 40) {
                            this.iv_signal.setImageResource(R.mipmap.signal_2);
                        } else if (hi_p2p_s_signal_operator_ext.s32SignalQuality > 40 && hi_p2p_s_signal_operator_ext.s32SignalQuality <= 60) {
                            this.iv_signal.setImageResource(R.mipmap.signal_3);
                        } else if (hi_p2p_s_signal_operator_ext.s32SignalQuality > 60 && hi_p2p_s_signal_operator_ext.s32SignalQuality <= 80) {
                            this.iv_signal.setImageResource(R.mipmap.signal_4);
                        } else {
                            this.iv_signal.setImageResource(R.mipmap.signal_5);
                        }
                    }
                    String trim = new String(hi_p2p_s_signal_operator_ext.s32OperatorName).trim();
                    if (trim.equals("") || TextUtils.isEmpty(trim)) {
                        trim = "unknown";
                    }
                    this.tv_brand.setVisibility(0);
                    this.tv_brand.setText(trim);
                    if (trim.equals("unknown")) {
                        getOneMoreTime();
                        return;
                    }
                    return;
                }
                ConstantCommand.HI_P2P_S_SIGNAL_OPERATOR hi_p2p_s_signal_operator = new ConstantCommand.HI_P2P_S_SIGNAL_OPERATOR(byteArray);
                if (hi_p2p_s_signal_operator.s32ShowSignal == 1 || hi_p2p_s_signal_operator.s32ShowName == 1) {
                    this.ll_4g_signal.setVisibility(0);
                } else {
                    this.ll_4g_signal.setVisibility(8);
                }
                if (hi_p2p_s_signal_operator.s32ShowSignal == 1 && hi_p2p_s_signal_operator.s32SignalQuality > 0) {
                    this.ll_signal.setVisibility(0);
                    if (hi_p2p_s_signal_operator.s32SignalQuality >= 0 && hi_p2p_s_signal_operator.s32SignalQuality <= 40) {
                        this.iv_signal.setImageResource(R.mipmap.signal_2);
                    } else if (hi_p2p_s_signal_operator.s32SignalQuality > 40 && hi_p2p_s_signal_operator.s32SignalQuality <= 60) {
                        this.iv_signal.setImageResource(R.mipmap.signal_3);
                    } else if (hi_p2p_s_signal_operator.s32SignalQuality > 60 && hi_p2p_s_signal_operator.s32SignalQuality <= 80) {
                        this.iv_signal.setImageResource(R.mipmap.signal_4);
                    } else {
                        this.iv_signal.setImageResource(R.mipmap.signal_5);
                    }
                }
                if (hi_p2p_s_signal_operator.s32ShowName == 1) {
                    this.tv_brand.setVisibility(0);
                    int i3 = hi_p2p_s_signal_operator.s32OperatorName;
                    if (i3 == 0) {
                        string = getString(R.string.cmcc);
                    } else if (i3 == 1) {
                        string = getString(R.string.cucc);
                    } else if (i3 == 2) {
                        string = getString(R.string.ctcc);
                    } else {
                        string = getString(R.string.none);
                        getOneMoreTime();
                    }
                    this.tv_brand.setText(string);
                    return;
                }
                return;
            }
        }
        dismissLoadingView();
    }

    private void showPupLight() {
        View inflate = View.inflate(this, R.layout.view_land_night_model, null);
        TextView textView = (TextView) inflate.findViewById(R.id.title);
        if (this.lightModel == 4) {
            textView.setText(R.string.light_and_sound_alarm);
        } else if (this.myCamera.appGetCommandFunction(ConstantCommand.HI_P2P_Garden_Lamp)) {
            textView.setText(R.string.gardenlight);
        }
        handLandShowContent(inflate);
        handWork(inflate);
    }

    private void handWork(View view) {
        final RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.live_view_ext_layout);
        RadioGroup radioGroup2 = (RadioGroup) view.findViewById(R.id.live_view_nor_layout);
        RadioGroup radioGroup3 = (RadioGroup) view.findViewById(R.id.live_view_abs_light_layout);
        RadioGroup radioGroup4 = (RadioGroup) view.findViewById(R.id.live_view_light_and_sound);
        RadioButton[] radioButtonArr = {(RadioButton) view.findViewById(R.id.live_view_ext_btn_normal), (RadioButton) view.findViewById(R.id.live_view_ext_btn_color), (RadioButton) view.findViewById(R.id.live_view_ext_btn_auto)};
        RadioButton[] radioButtonArr2 = {(RadioButton) view.findViewById(R.id.live_view_nor_btn_open), (RadioButton) view.findViewById(R.id.live_view_nor_btn_close)};
        RadioButton[] radioButtonArr3 = {(RadioButton) view.findViewById(R.id.light_and_sound_close), (RadioButton) view.findViewById(R.id.light_and_sound_open), (RadioButton) view.findViewById(R.id.light_and_sound_auto)};
        int i = this.lightModel;
        if (i == 2) {
            radioGroup.setVisibility(8);
            radioGroup3.setVisibility(8);
            radioGroup2.setVisibility(0);
            radioGroup4.setVisibility(8);
            HiChipDefines.HI_P2P_WHITE_LIGHT_INFO hi_p2p_white_light_info = this.light_info;
            if (hi_p2p_white_light_info != null && hi_p2p_white_light_info.u32State < 2) {
                radioButtonArr2[this.light_info.u32State].setChecked(true);
            }
        } else if (i == 1 || i == 5) {
            radioGroup.setVisibility(0);
            radioGroup2.setVisibility(8);
            radioGroup3.setVisibility(8);
            radioGroup4.setVisibility(8);
            ConstantCommand.HI_P2P_Garden_Lamp_INFO hI_P2P_Garden_Lamp_INFO = this.mGarden_lamp_info;
            if (hI_P2P_Garden_Lamp_INFO != null && hI_P2P_Garden_Lamp_INFO.u32State < 3) {
                ((RadioButton) radioGroup.getChildAt(this.mGarden_lamp_info.u32State)).setChecked(true);
            }
            HiChipDefines.HI_P2P_WHITE_LIGHT_INFO_EXT hi_p2p_white_light_info_ext = this.light_info_ext;
            if (hi_p2p_white_light_info_ext != null && hi_p2p_white_light_info_ext.u32State < 3) {
                radioButtonArr[this.light_info_ext.u32State].setChecked(true);
            }
        } else if (i == 3) {
            radioGroup3.setVisibility(0);
            radioGroup.setVisibility(8);
            radioGroup2.setVisibility(8);
            radioGroup4.setVisibility(8);
            HiChipDefines.ABSOLUTE_LIGHT_TYPE absolute_light_type = this.abs_light;
            if (absolute_light_type != null && absolute_light_type.s32State < 3) {
                ((RadioButton) radioGroup3.getChildAt(this.abs_light.s32State)).setChecked(true);
            }
        } else {
            radioGroup3.setVisibility(8);
            radioGroup.setVisibility(8);
            radioGroup2.setVisibility(8);
            radioGroup4.setVisibility(0);
            ConstantCommand.HI_P2P_S_AUDIBLE_VISUAL_ALARM_TYPE hi_p2p_s_audible_visual_alarm_type = this.audible_visual_alarm_type;
            if (hi_p2p_s_audible_visual_alarm_type != null && hi_p2p_s_audible_visual_alarm_type.u32State < 3) {
                radioButtonArr3[this.audible_visual_alarm_type.u32State].setChecked(true);
            }
        }
        radioGroup4.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup5, int i2) {
                if (LandLiveSpliceActivity.this.audible_visual_alarm_type == null) {
                    return;
                }
                switch (i2) {
                    case R.id.light_and_sound_auto:
                        LandLiveSpliceActivity.this.audible_visual_alarm_type.u32State = 2;
                        break;
                    case R.id.light_and_sound_close:
                        LandLiveSpliceActivity.this.audible_visual_alarm_type.u32State = 0;
                        break;
                    case R.id.light_and_sound_open:
                        LandLiveSpliceActivity.this.audible_visual_alarm_type.u32State = 1;
                        break;
                }
                LandLiveSpliceActivity.this.myCamera.sendIOCtrl(16791, LandLiveSpliceActivity.this.audible_visual_alarm_type.parseContent());
            }
        });
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup5, int i2) {
                if (LandLiveSpliceActivity.this.lightModel == 1) {
                    if (LandLiveSpliceActivity.this.light_info_ext == null) {
                        return;
                    }
                    switch (i2) {
                        case R.id.live_view_ext_btn_auto:
                            LandLiveSpliceActivity.this.light_info_ext.u32State = 2;
                            break;
                        case R.id.live_view_ext_btn_color:
                            LandLiveSpliceActivity.this.light_info_ext.u32State = 1;
                            break;
                        case R.id.live_view_ext_btn_normal:
                            LandLiveSpliceActivity.this.light_info_ext.u32State = 0;
                            break;
                    }
                    LandLiveSpliceActivity.this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_WHITE_LIGHT_SET_EXT, HiChipDefines.HI_P2P_WHITE_LIGHT_INFO_EXT.parseContent(LandLiveSpliceActivity.this.light_info_ext.u32Chn, LandLiveSpliceActivity.this.light_info_ext.u32State));
                    return;
                }
                if (LandLiveSpliceActivity.this.lightModel != 5 || LandLiveSpliceActivity.this.mGarden_lamp_info == null) {
                    return;
                }
                if (LandLiveSpliceActivity.this.mGarden_set_cancel) {
                    LandLiveSpliceActivity.this.mGarden_set_cancel = false;
                    return;
                }
                switch (i2) {
                    case R.id.live_view_ext_btn_auto:
                        LandLiveSpliceActivity.this.msaveGardenstate = 2;
                        break;
                    case R.id.live_view_ext_btn_color:
                        LandLiveSpliceActivity.this.msaveGardenstate = 1;
                        break;
                    case R.id.live_view_ext_btn_normal:
                        LandLiveSpliceActivity.this.msaveGardenstate = 0;
                        break;
                }
                if (LandLiveSpliceActivity.this.mGarden_lamp_info.u32Enable != 1) {
                    LandLiveSpliceActivity.this.mGarden_lamp_info.u32State = LandLiveSpliceActivity.this.msaveGardenstate;
                    LandLiveSpliceActivity.this.myCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_Garden_Lamp, LandLiveSpliceActivity.this.mGarden_lamp_info.parseContent());
                    return;
                }
                final NiftyDialogBuilder niftyDialogBuilder = NiftyDialogBuilder.getInstance(LandLiveSpliceActivity.this);
                niftyDialogBuilder.withMessageLayoutHWrapW(HiTools.dip2px(LandLiveSpliceActivity.this, 280.0f));
                niftyDialogBuilder.withTitle(LandLiveSpliceActivity.this.getString(R.string.tip_hint)).withMessage(LandLiveSpliceActivity.this.getString(R.string.tipoff_tinglight));
                niftyDialogBuilder.withButton1Text(LandLiveSpliceActivity.this.getString(R.string.cancel)).withButton2Text(LandLiveSpliceActivity.this.getString(R.string.sure));
                niftyDialogBuilder.setButton1Click(new View.OnClickListener() {
                    @Override
                    public void onClick(View view2) {
                        niftyDialogBuilder.dismiss();
                        LandLiveSpliceActivity.this.mGarden_set_cancel = true;
                        ((RadioButton) radioGroup.getChildAt(LandLiveSpliceActivity.this.mGarden_lamp_info.u32State)).setChecked(true);
                    }
                });
                niftyDialogBuilder.setButton2Click(new View.OnClickListener() {
                    @Override
                    public void onClick(View view2) {
                        niftyDialogBuilder.dismiss();
                        MyToast.showToast(LandLiveSpliceActivity.this, LandLiveSpliceActivity.this.getString(R.string.ting_light_off));
                        LandLiveSpliceActivity.this.mGarden_lamp_info.u32Enable = 0;
                        LandLiveSpliceActivity.this.mGarden_lamp_info.u32State = LandLiveSpliceActivity.this.msaveGardenstate;
                        LandLiveSpliceActivity.this.myCamera.sendIOCtrl(ConstantCommand.HI_P2P_SET_Garden_Lamp, LandLiveSpliceActivity.this.mGarden_lamp_info.parseContent());
                    }
                });
                niftyDialogBuilder.isCancelableOnTouchOutside(false);
                niftyDialogBuilder.show();
            }
        });
        radioGroup2.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup5, int i2) {
                if (LandLiveSpliceActivity.this.light_info == null) {
                    return;
                }
                switch (i2) {
                    case R.id.live_view_nor_btn_close:
                        LandLiveSpliceActivity.this.light_info.u32State = 1;
                        break;
                    case R.id.live_view_nor_btn_open:
                        LandLiveSpliceActivity.this.light_info.u32State = 0;
                        break;
                }
                LandLiveSpliceActivity.this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_WHITE_LIGHT_SET, HiChipDefines.HI_P2P_WHITE_LIGHT_INFO.parseContent(LandLiveSpliceActivity.this.light_info.u32Chn, LandLiveSpliceActivity.this.light_info.u32State));
            }
        });
        radioGroup3.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup5, int i2) {
                if (LandLiveSpliceActivity.this.lightModel != 3 || LandLiveSpliceActivity.this.abs_light == null) {
                    return;
                }
                switch (i2) {
                    case R.id.abs_light_auto:
                        LandLiveSpliceActivity.this.abs_light.s32State = 0;
                        break;
                    case R.id.abs_light_close:
                        LandLiveSpliceActivity.this.abs_light.s32State = 2;
                        break;
                    case R.id.abs_light_open:
                        LandLiveSpliceActivity.this.abs_light.s32State = 1;
                        break;
                }
                LandLiveSpliceActivity.this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_ABSOLUTE_LIGHT_TYPE, HiChipDefines.ABSOLUTE_LIGHT_TYPE.parseContent(LandLiveSpliceActivity.this.abs_light.s32State));
            }
        });
    }

    private void getOneMoreTime() {
        if (this.reGetSignal) {
            return;
        }
        this.reGetSignal = true;
        Handler handler = this.mHandler;
        if (handler != null) {
            handler.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    LandLiveSpliceActivity.this.getSignalOperator();
                }
            }, 10000L);
        }
    }

    public void getSignalOperator() {
        if (this.myCamera.appGetCommandFunction(ConstantCommand.HI_P2P_SUPPORT_4G) || this.myCamera.appGetCommandFunction(ConstantCommand.HI_P2P_SUPPORT_5G)) {
            String language = Locale.getDefault().getLanguage();
            String country = Locale.getDefault().getCountry();
            if (language.equals("zh") && country.equals("CN")) {
                this.myCamera.sendIOCtrl(ConstantCommand.HI_P2P_GET_SIGNAL_OPERATOR, new byte[0]);
            } else {
                this.myCamera.sendIOCtrl(ConstantCommand.HI_P2P_GET_SIGNAL_OPERATOR_EXT, new byte[0]);
            }
        }
    }

    public void sendToDevice() {
        if (this.audio_attr == null) {
            return;
        }
        int progress = this.seekBar_input.getProgress() + 1;
        int progress2 = this.seekBar_output.getProgress() + 1;
        showLoadingView();
        this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_AUDIO_ATTR, HiChipDefines.HI_P2P_S_AUDIO_ATTR.parseContent(0, this.audio_attr.u32Enable, this.audio_attr.u32Stream, this.audio_attr.u32AudioType, this.mInputMethod, (!this.myCamera.isIs88VoiceDev() || progress <= 88) ? progress : 88, progress2));
    }

    private void handMirrorFlip(View view) {
        if (this.display_param == null) {
            return;
        }
        SwitchButton switchButton = (SwitchButton) view.findViewById(R.id.switch_btn_mirror);
        switchButton.setChecked(this.display_param.u32Mirror == 1);
        switchButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
                LandLiveSpliceActivity.this.mirrorChecked = z ? 1 : 0;
                LandLiveSpliceActivity.this.display_param.u32Mirror = LandLiveSpliceActivity.this.mirrorChecked;
                LandLiveSpliceActivity.this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_DISPLAY_PARAM, LandLiveSpliceActivity.this.display_param.parseContent());
                LandLiveSpliceActivity.this.showLoadingView();
            }
        });
        SwitchButton switchButton2 = (SwitchButton) view.findViewById(R.id.switch_btn_flip);
        switchButton2.setChecked(this.display_param.u32Flip == 1);
        switchButton2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
                LandLiveSpliceActivity.this.flipChecked = z ? 1 : 0;
                LandLiveSpliceActivity.this.display_param.u32Flip = LandLiveSpliceActivity.this.flipChecked;
                LandLiveSpliceActivity.this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_DISPLAY_PARAM, LandLiveSpliceActivity.this.display_param.parseContent());
                LandLiveSpliceActivity.this.showLoadingView();
            }
        });
    }

    public void handSessionState(Message message, MyCamera myCamera) {
        int i = message.arg1;
        if (i != 0) {
            if (i != 4) {
                return;
            }
            HiLogcatUtil.eTag("==test8888", this.mIsSwitchResolution + "");
            this.mIsSwitchResolution = false;
            this.myCamera.startLiveShow(this.quality, this.mMonitor);
            this.tv_landscape_video_quality.setText(getString(this.quality == 0 ? R.string.high_definition : R.string.fluent));
            return;
        }
        this.isReceiveDisconnect = true;
        MyToast.showToast(getApplicationContext(), getString(R.string.netword_abnormal));
        Intent intent = new Intent();
        intent.putExtra("position", this.cameraPosition);
        intent.putExtra("isListening", false);
        intent.putExtra("isTalking", false);
        intent.putExtra("mStartRecordTime", 0);
        intent.putExtra("isRecording", false);
        intent.putExtra("isNeedReOpenListen", false);
        intent.putExtra("isListenPause", false);
        setResult(-1, intent);
        finish();
    }

    public void handMsgPlayState(Message message) {
        Bundle data = message.getData();
        int i = data.getInt(a.k);
        data.getString(HiDataValue.EXTRAS_KEY_UID);
        String string = data.getString(TTDownloadField.TT_FILE_NAME);
        if (i != 0) {
            if (i != 3) {
                if (i != 6) {
                    return;
                }
                finish();
                MyToast.showToast(this, getString(R.string.video_exception));
                return;
            }
            if (TextUtils.isEmpty(string) || this.mRecordingState != 2) {
                return;
            }
            grabRecordSnapshot(string);
            return;
        }
        Handler handler = this.mHandler;
        if (handler != null) {
            handler.sendEmptyMessageDelayed(2384, 0L);
        }
        if (this.iv_bg.getVisibility() == 0) {
            this.iv_bg.setVisibility(8);
        }
        HiLogcatUtil.d("单画面 收到播放开始 PLAY_STATE_START");
        dismissLoadingView();
        this.receiveHumanParams = true;
        setViewWhetherClick(true);
        if (this.firstInChangeStream) {
            this.firstInChangeStream = false;
            this.isCountDown = false;
            this.iv_recording.removeCallbacks(this.runnable);
            if (!this.mIsTalking && this.mIsListening) {
                this.iv_landscape_listen.setSelected(true);
                clickListen();
            }
            if (this.mIsTalking && !this.mIsListening) {
                handTalkingNew();
            }
            if (this.mIsRecording) {
                this.isFirst = false;
                clickRecording();
            }
        } else if (this.myCamera != null && this.mIsSwitchResolution) {
            if (this.mRecordingState == 2) {
                this.mStartRecordTime = 0;
                Timer timer = this.timer;
                if (timer != null) {
                    timer.cancel();
                    this.timer = null;
                }
                TimerTask timerTask = this.timerTask;
                if (timerTask != null) {
                    timerTask.cancel();
                    this.timerTask = null;
                }
                continueRecording();
            }
            this.myCamera.setVideoQuality(this.quality);
            this.myCamera.updateInDatabase(this);
            this.tv_landscape_video_quality.setText(getString(this.quality == 0 ? R.string.high_definition : R.string.fluent));
        }
        HiLogcatUtil.eTag("==test99999", this.mIsSwitchResolution + "");
        this.mIsSwitchResolution = false;
    }

    private void grabRecordSnapshot(String str) {
        MyCamera myCamera = this.myCamera;
        Bitmap snapshot_EXT = myCamera != null ? myCamera.getSnapshot_EXT(1, 640, 352) : null;
        if (snapshot_EXT != null) {
            saveRecordSnapshot(snapshot_EXT, str);
        }
    }

    private void saveRecordSnapshot(final Bitmap bitmap, final String str) {
        new AsyncTask<Void, Void, Void>() {
            @Override
            public void onPostExecute(Void r1) {
            }

            @Override
            public Void doInBackground(Void... voidArr) {
                if (!Environment.getExternalStorageState().equals("mounted")) {
                    return null;
                }
                File file = new File(HiDataValue.getPathCameraLocalRecordSnapShot(LandLiveSpliceActivity.this.myCamera.getUid(), LandLiveSpliceActivity.this));
                if (!file.exists()) {
                    file.mkdirs();
                }
                if (TextUtils.isEmpty(str)) {
                    return null;
                }
                String[] split = new File(str).getName().split("\\.");
                HiTools.saveBitmap(bitmap, file.getAbsolutePath() + "/" + split[0]);
                return null;
            }
        }.execute(new Void[0]);
    }

    private void continueRecording() {
        HiLogcatUtil.d("continueRecording()");
        Timer timer = this.timer;
        if (timer != null) {
            timer.cancel();
            this.timer = null;
        }
        TimerTask timerTask = this.timerTask;
        if (timerTask != null) {
            timerTask.cancel();
            this.timerTask = null;
        }
        final File file = new File(HiDataValue.getPathCameraVideoLocalRecord(this.myCamera.getUid(), this));
        if (!file.exists()) {
            file.mkdirs();
        }
        this.timer = new Timer();
        TimerTask timerTask2 = new TimerTask() {
            @Override
            public void run() {
                HiLogcatUtil.d("continueRecording run()");
                if (LandLiveSpliceActivity.this.mRecordingState == 2) {
                    HiLogcatUtil.d("continueRecording stopRecording()");
                    LandLiveSpliceActivity.this.myCamera.stopRecording();
                }
                if (LandLiveSpliceActivity.this.myCamera.getdevDual()) {
                    boolean z = LandLiveSpliceActivity.this.myCamera.getdevDual();
                    LandLiveSpliceActivity.this.recordFile = file.getAbsoluteFile() + "/" + HiTools.getFileNameWithTimeExt(1, z ? 1 : 0);
                    int i = LandLiveSpliceActivity.this.myCamera.getdevDual() ? 2 : z ? 1 : 0;
                    LandLiveSpliceActivity.this.record2File = file.getAbsoluteFile() + "/" + HiTools.getFileNameWithTimeExt(1, i);
                } else {
                    LandLiveSpliceActivity.this.recordFile = file.getAbsoluteFile() + "/" + HiTools.getFileNameWithTime(1);
                }
                long availableSize = HiTools.getAvailableSize();
                if (availableSize >= 100 || availableSize <= 0) {
                    LandLiveSpliceActivity.this.mHandler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            HiLogcatUtil.d("continueRecording startRecording()");
                            if (!LandLiveSpliceActivity.this.myCamera.getdevDual()) {
                                LandLiveSpliceActivity.this.myCamera.startRecording(LandLiveSpliceActivity.this.recordFile);
                            } else {
                                LandLiveSpliceActivity.this.myCamera.startRecordingExt(LandLiveSpliceActivity.this.recordFile, LandLiveSpliceActivity.this.record2File);
                            }
                        }
                    }, 1000L);
                } else {
                    LandLiveSpliceActivity.this.mHandler.sendEmptyMessage(WiFiSettingActivity.SET_WIFI_END);
                }
            }
        };
        this.timerTask = timerTask2;
        this.timer.schedule(timerTask2, TTAdConstant.AD_MAX_EVENT_TIME, TTAdConstant.AD_MAX_EVENT_TIME);
    }

    public void showLoadingView() {
        ImageView imageView = this.mIvLoading2;
        if (imageView == null || imageView.getVisibility() != 8) {
            return;
        }
        Animation loadAnimation = AnimationUtils.loadAnimation(this, R.anim.rotate);
        this.mIvLoading2.setVisibility(0);
        this.mIvLoading2.startAnimation(loadAnimation);
    }

    public void dismissLoadingView() {
        ImageView imageView = this.mIvLoading2;
        if (imageView == null || imageView.getVisibility() != 0) {
            return;
        }
        this.mIvLoading2.clearAnimation();
        this.mIvLoading2.setVisibility(8);
    }

    @Override
    public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
        switch (seekBar.getId()) {
            case R.id.sb_brightness:
                TextView textView = this.tv_brightness;
                if (textView != null) {
                    textView.setText(seekBar.getProgress() + "");
                    return;
                }
                return;
            case R.id.sb_contrast:
                TextView textView2 = this.tv_contrast;
                if (textView2 != null) {
                    textView2.setText(seekBar.getProgress() + "");
                    return;
                }
                return;
            case R.id.sb_saturation:
                TextView textView3 = this.tv_saturation;
                if (textView3 != null) {
                    textView3.setText(seekBar.getProgress() + "");
                    return;
                }
                return;
            default:
                return;
        }
    }

    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {
        switch (seekBar.getId()) {
            case R.id.sb_brightness:
                this.display_param.u32Brightness = seekBar.getProgress();
                showLoadingView();
                this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_DISPLAY_PARAM, this.display_param.parseContent());
                return;
            case R.id.sb_contrast:
                this.display_param.u32Contrast = seekBar.getProgress();
                showLoadingView();
                this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_DISPLAY_PARAM, this.display_param.parseContent());
                return;
            case R.id.sb_saturation:
                this.display_param.u32Saturation = seekBar.getProgress();
                showLoadingView();
                this.myCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_DISPLAY_PARAM, this.display_param.parseContent());
                return;
            default:
                return;
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (this.mHandler_lockScreen != null) {
            this.root_lock_screen.setVisibility(8);
            this.mHandler_lockScreen.removeCallbacksAndMessages(null);
        }
        OrientationWatchDog orientationWatchDog = this.mOrientationWatchDog;
        if (orientationWatchDog != null) {
            orientationWatchDog.stopWatch();
        }
        MyCamera myCamera = this.myCamera;
        if (myCamera != null) {
            myCamera.clearMonitor(this.mMonitor);
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void receiveHumanParams(byte[] bArr) {
        if (this.preHumanTime == 0) {
            this.mTimer.schedule(this.mTask, 0L, 1000L);
        }
        this.preHumanTime = System.currentTimeMillis();
        SpliceViewGLMonitor spliceViewGLMonitor = this.mMonitor;
        if (spliceViewGLMonitor == null || spliceViewGLMonitor.getState() == 1) {
            return;
        }
        ConstantCommand.HI_P2P_SMART_HSR_AREA hi_p2p_smart_hsr_area = new ConstantCommand.HI_P2P_SMART_HSR_AREA(bArr);
        if (hi_p2p_smart_hsr_area.u32Num == 0) {
            return;
        }
        Message message = new Message();
        message.what = 10010;
        message.obj = bArr;
        message.arg1 = hi_p2p_smart_hsr_area.u32Num;
        this.humanRectHandler.sendMessage(message);
    }

    @Override
    public void changedScreenDirection(int i) {
        if (this.isReadyPlay) {
            if (i == 90) {
                this.isLeft = false;
                handLandScape();
                setRequestedOrientation(8);
                if (!this.isFirstRevolveLand) {
                    this.isFirstRevolveLand = true;
                }
                if (this.root_lock_screen.getVisibility() == 0) {
                    this.mHandler_lockScreen.removeCallbacksAndMessages(null);
                    this.mHandler_lockScreen.sendEmptyMessageDelayed(1, 3000L);
                    return;
                } else {
                    this.mHandler_lockScreen.removeCallbacksAndMessages(null);
                    this.mHandler_lockScreen.sendEmptyMessageDelayed(0, 3000L);
                    return;
                }
            }
            if (i == 270) {
                this.isLeft = true;
                handLandScape();
                setRequestedOrientation(0);
                if (!this.isFirstRevolveLand) {
                    this.isFirstRevolveLand = true;
                } else if (this.root_lock_screen.getVisibility() == 0) {
                    this.mHandler_lockScreen.removeCallbacksAndMessages(null);
                    this.mHandler_lockScreen.sendEmptyMessageDelayed(1, 3000L);
                } else {
                    this.mHandler_lockScreen.removeCallbacksAndMessages(null);
                    this.mHandler_lockScreen.sendEmptyMessageDelayed(0, 3000L);
                }
            }
        }
    }

    @Override
    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        super.onRequestPermissionsResult(i, strArr, iArr);
        boolean z = true;
        HiLogcatUtil.e("" + i);
        int length = strArr.length;
        for (int i2 = 0; i2 < length; i2++) {
            HiLogcatUtil.e(strArr.length + Constants.COLON_SEPARATOR + strArr[i2]);
        }
        for (int i3 : iArr) {
            HiLogcatUtil.e(iArr.length + Constants.COLON_SEPARATOR + i3);
        }
        if (i == MY_PERMISSION_REQUEST_CODE) {
            int length2 = iArr.length;
            int i4 = 0;
            while (true) {
                if (i4 >= length2) {
                    break;
                }
                if (iArr[i4] != 0) {
                    z = false;
                    break;
                }
                i4++;
            }
            if (z) {
                return;
            }
            this.mIsOnpause = false;
            HiTools.Hi_GoToSetting(strArr, this, this);
        }
    }
}