WallMountedActivity.java 源代码
package activity.WallMounted;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.AsyncTask;
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.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;
import base.HiActivity;
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.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.HiDataValue;
import common.MyLiveViewGLMonitor;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import org.apache.poi.xwpf.converter.xhtml.internal.styles.CSSStylePropertyConstants;
import utils.BitmapUtils;
import utils.HiLogcatUtil;
import utils.HiTools;
import utils.MyToast;
import utils.OrientationWatchDog;
import utils.SharePreUtils;
import utils.TimeUtil;
public class WallMountedActivity extends HiActivity implements ICameraPlayStateCallback, ICameraIOSessionCallback, View.OnTouchListener, View.OnClickListener, OrientationWatchDog.OnOrientationListener {
private static final int MY_PERMISSION_REQUEST_CODE = 10002;
private static final int RECORDING_STATUS_ING = 2;
private static final int RECORDING_STATUS_LOADING = 1;
private static final int RECORDING_STATUS_NONE = 0;
protected HiChipDefines.ABSOLUTE_LIGHT_TYPE abs_light;
private float action_down_X;
private float action_down_Y;
private ImageView btn_live_listen;
private ImageView btn_live_record;
private ImageView btn_live_snapshot;
private ImageView btn_microphone;
private ImageView btn_return;
private boolean hideUIMenu;
private ImageView iv_cruise;
private ImageView iv_loading2;
ImageView iv_recording;
public ImageView iv_white_light;
public int lightModel;
protected HiChipDefines.HI_P2P_WHITE_LIGHT_INFO light_info;
protected HiChipDefines.HI_P2P_WHITE_LIGHT_INFO_EXT light_info_ext;
public LinearLayout ll_bottom;
LinearLayout ll_recording;
public LinearLayout ll_top;
private LinearLayout ll_white_light;
private MyCamera mCamera;
private MyLiveViewGLMonitor mMonitor;
private OrientationWatchDog mOrientationWatchDog;
protected boolean mWhiteLightSele;
int moveX;
int moveY;
private float move_X;
private float move_Y;
private double nLenStart;
private long oldClickTime;
protected String recordFile;
public LinearLayout root_lock_screen;
private Timer timer;
private TimerTask timerTask;
TextView tv_record_time;
private TextView tv_timezone;
private String uid;
private int xlenOld;
private int ylenOld;
public boolean mIsCruise = false;
private int mRecordingState = 0;
private boolean isListening = false;
private boolean isTalking = false;
private Handler monitorHandler = new Handler();
public boolean mIsOnpause = false;
private List<Toast> toastList = new ArrayList();
private boolean isLeft = true;
private boolean isFirstRevolveLand = false;
private boolean isReadyPlay = false;
private SimpleDateFormat sdf = new SimpleDateFormat(TimeUtil.FORMAT_DATE_TIME_FULL);
private Handler timeHandler = new Handler() {
@Override
public void handleMessage(Message message) {
if (message.what != 281) {
return;
}
WallMountedActivity.this.setTime();
}
};
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message message) {
int i = message.what;
if (i == -2147483647) {
WallMountedActivity.this.handCameraPlayState(message.getData());
return;
}
if (i != -1879048191) {
if (i == -1879048189 && message.arg2 == 0) {
byte[] byteArray = message.getData().getByteArray("data");
int i2 = message.arg1;
if (i2 == 4097) {
int byteArrayToInt_Little = Packet.byteArrayToInt_Little(byteArray, 4);
int byteArrayToInt_Little2 = Packet.byteArrayToInt_Little(byteArray, 8);
if (byteArrayToInt_Little <= 0 || byteArrayToInt_Little2 <= 0 || byteArrayToInt_Little > 5000 || byteArrayToInt_Little2 > 5000) {
WallMountedActivity.this.finish();
WallMountedActivity wallMountedActivity = WallMountedActivity.this;
MyToast.showToast(wallMountedActivity, wallMountedActivity.getString(R.string.tips_open_video_fail));
return;
}
return;
}
if (i2 != 16678) {
if (i2 == 16682) {
if (WallMountedActivity.this.lightModel != 1) {
return;
}
WallMountedActivity.this.light_info_ext = new HiChipDefines.HI_P2P_WHITE_LIGHT_INFO_EXT(byteArray);
return;
}
if (i2 == 16766 && WallMountedActivity.this.lightModel == 3) {
WallMountedActivity.this.abs_light = new HiChipDefines.ABSOLUTE_LIGHT_TYPE(byteArray);
return;
}
return;
}
if (WallMountedActivity.this.lightModel != 2) {
return;
}
WallMountedActivity.this.light_info = new HiChipDefines.HI_P2P_WHITE_LIGHT_INFO(byteArray);
if (WallMountedActivity.this.light_info == null || WallMountedActivity.this.light_info.u32State >= 2) {
return;
}
if (WallMountedActivity.this.light_info.u32State == 0) {
WallMountedActivity.this.iv_white_light.setSelected(true);
WallMountedActivity.this.mWhiteLightSele = true;
return;
} else {
WallMountedActivity.this.iv_white_light.setSelected(false);
WallMountedActivity.this.mWhiteLightSele = false;
return;
}
}
return;
}
WallMountedActivity.this.handCameraSessionState(message.arg1);
}
};
public int isLarge = 0;
private boolean mVoiceIsTran = false;
public long mStartRecoedTime = 0;
private SimpleDateFormat sdf_mmss = new SimpleDateFormat("mm:ss");
private Handler handler = new Handler() {
@Override
public void handleMessage(Message message) {
int i = message.what;
if (i != 110) {
if (i != 288) {
return;
}
WallMountedActivity.this.endRecording();
WallMountedActivity wallMountedActivity = WallMountedActivity.this;
MyToast.showToast(wallMountedActivity, wallMountedActivity.getString(R.string.failed_recording));
return;
}
if (WallMountedActivity.this.iv_recording.getVisibility() == 4) {
WallMountedActivity.this.iv_recording.setVisibility(0);
} else {
WallMountedActivity.this.iv_recording.setVisibility(4);
}
WallMountedActivity.this.mStartRecoedTime += 1000;
WallMountedActivity.this.tv_record_time.setText(WallMountedActivity.this.sdf_mmss.format(new Date(WallMountedActivity.this.mStartRecoedTime)));
WallMountedActivity.this.handler.sendEmptyMessageDelayed(110, 1000L);
}
};
private Handler mHandler_lockScreen = new Handler() {
@Override
public void handleMessage(Message message) {
if (message.what == 0) {
WallMountedActivity.this.root_lock_screen.setVisibility(0);
WallMountedActivity.this.mHandler_lockScreen.sendEmptyMessageDelayed(1, 3000L);
} else {
WallMountedActivity.this.root_lock_screen.setVisibility(8);
WallMountedActivity.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 callbackRecordStateDual(HiCamera hiCamera, int i, int i2, int i3, int i4, String str) {
}
@Override
public void callbackStateDual(HiCamera hiCamera, int i, int i2, int i3, int i4) {
}
@Override
protected int setLayoutId() {
return R.layout.activity_wall_mounted;
}
@Override
protected void initWindow() {
this.hideUIMenu = hideBottomUIMenu();
}
@Override
protected void init(Bundle bundle) {
getWindow().addFlags(128);
getWindow().setFlags(1024, 1024);
getIntentData();
getLightModel();
if (HiTools.cameraWhetherNull(this.mCamera, this)) {
return;
}
initView();
setListeners();
this.mCamera.registerIOSessionListener(this);
this.mCamera.registerPlayStateListener(this);
showLoadingView();
if (this.mCamera != null) {
new Thread() {
@Override
public void run() {
WallMountedActivity.this.mCamera.startLiveShow(WallMountedActivity.this.mCamera.getVideoQuality(), WallMountedActivity.this.mMonitor);
}
}.start();
}
OrientationWatchDog orientationWatchDog = new OrientationWatchDog(this);
this.mOrientationWatchDog = orientationWatchDog;
orientationWatchDog.setOnOrientationListener(this);
this.mOrientationWatchDog.startWatch();
}
private void getLightModel() {
if (this.mCamera.appGetCommandFunction(HiChipDefines.HI_P2P_GET_ABSOLUTE_LIGHT_TYPE)) {
this.lightModel = 3;
this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_GET_ABSOLUTE_LIGHT_TYPE, null);
} else if (this.mCamera.appGetCommandFunction(HiChipDefines.HI_P2P_WHITE_LIGHT_GET_EXT)) {
this.lightModel = 1;
this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_WHITE_LIGHT_GET_EXT, null);
} else if (this.mCamera.appGetCommandFunction(HiChipDefines.HI_P2P_WHITE_LIGHT_GET)) {
this.lightModel = 2;
this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_WHITE_LIGHT_GET, null);
}
}
private void setListeners() {
this.mMonitor.setOnTouchListener(this);
this.btn_return.setOnClickListener(this);
this.btn_live_listen.setOnClickListener(this);
this.btn_live_snapshot.setOnClickListener(this);
this.btn_live_record.setOnClickListener(this);
this.iv_cruise.setOnClickListener(this);
this.iv_white_light.setOnClickListener(this);
this.root_lock_screen.setOnClickListener(this);
}
@Override
public void onResume() {
super.onResume();
this.mCamera.registerIOSessionListener(this);
this.mCamera.registerPlayStateListener(this);
this.mIsOnpause = false;
}
@Override
public void onPause() {
super.onPause();
if (this.mIsOnpause) {
return;
}
cancelToast(this.toastList);
this.mVoiceIsTran = false;
Timer timer = this.timer;
if (timer != null) {
timer.cancel();
this.timer = null;
}
TimerTask timerTask = this.timerTask;
if (timerTask != null) {
timerTask.cancel();
this.timerTask = null;
}
MyCamera myCamera = this.mCamera;
if (myCamera != null) {
myCamera.stopLiveShow();
this.mCamera.unregisterIOSessionListener(this);
this.mCamera.unregisterPlayStateListener(this);
}
setRequestedOrientation(1);
finish();
}
private void cancelToast(List<Toast> list) {
if (list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
if (list.get(i) != null) {
list.get(i).cancel();
}
}
}
}
@Override
public void onDestroy() {
super.onDestroy();
Handler handler = this.mHandler;
if (handler != null) {
handler.removeCallbacksAndMessages(null);
}
Handler handler2 = this.handler;
if (handler2 != null) {
handler2.removeCallbacksAndMessages(null);
}
Handler handler3 = this.monitorHandler;
if (handler3 != null) {
handler3.removeCallbacksAndMessages(null);
}
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.mCamera;
if (myCamera != null) {
myCamera.clearMonitor(this.mMonitor);
}
}
private void initView() {
this.mMonitor = (MyLiveViewGLMonitor) findViewById(R.id.monitor_wall_mounted);
this.mCamera.setVideoQuality(0);
this.mMonitor.SetCirInfo(SharePreUtils.getFloat(HiDataValue.CACHE, this, this.mCamera.getUid() + "xcircle"), SharePreUtils.getFloat(HiDataValue.CACHE, this, this.mCamera.getUid() + "ycircle"), SharePreUtils.getFloat(HiDataValue.CACHE, this, this.mCamera.getUid() + "rcircle"));
this.mMonitor.SetViewType_EXT(1, this.mCamera.getFishModType());
this.mMonitor.SetShowScreenMode(2, 1);
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
this.mMonitor.screen_height = displayMetrics.heightPixels;
if (this.hideUIMenu) {
this.mMonitor.screen_width = displayMetrics.widthPixels + HiTools.getNavigationBarHeight(this);
} else {
this.mMonitor.screen_width = displayMetrics.widthPixels;
}
MyLiveViewGLMonitor myLiveViewGLMonitor = this.mMonitor;
myLiveViewGLMonitor.SetScreenSize(myLiveViewGLMonitor.screen_width, this.mMonitor.screen_height);
this.mMonitor.setCamera(this.mCamera);
this.mCamera.setLiveShowMonitor(this.mMonitor);
this.iv_white_light = (ImageView) findViewById(R.id.iv_white_light);
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.ll_white_light);
this.ll_white_light = linearLayout;
linearLayout.setVisibility(this.lightModel == 0 ? 8 : 0);
this.iv_loading2 = (ImageView) findViewById(R.id.iv_loading2);
this.ll_top = (LinearLayout) findViewById(R.id.ll_top);
this.ll_bottom = (LinearLayout) findViewById(R.id.ll_bottom);
this.btn_return = (ImageView) findViewById(R.id.btn_return);
this.btn_live_listen = (ImageView) findViewById(R.id.btn_live_listen);
ImageView imageView = (ImageView) findViewById(R.id.btn_microphone);
this.btn_microphone = imageView;
imageView.setOnTouchListener(this);
this.btn_microphone.setVisibility(8);
this.btn_live_snapshot = (ImageView) findViewById(R.id.btn_live_snapshot);
this.btn_live_record = (ImageView) findViewById(R.id.btn_live_record);
this.iv_cruise = (ImageView) findViewById(R.id.iv_cruise);
this.tv_timezone = (TextView) findViewById(R.id.tv_timezone);
}
public void setTime() {
this.tv_timezone.setText(this.sdf.format(new Date()));
this.timeHandler.sendEmptyMessage(281);
}
private void getIntentData() {
this.uid = getIntent().getStringExtra(HiDataValue.EXTRAS_KEY_UID);
for (MyCamera myCamera : HiDataValue.CameraList) {
if (myCamera.getUid().equalsIgnoreCase(this.uid)) {
this.mCamera = myCamera;
return;
}
}
}
private void showLoadingView() {
ImageView imageView = this.iv_loading2;
if (imageView == null || imageView.getVisibility() != 8) {
return;
}
Animation loadAnimation = AnimationUtils.loadAnimation(this, R.anim.rotate);
this.iv_loading2.setVisibility(0);
this.iv_loading2.startAnimation(loadAnimation);
}
private void dismissLoadingView() {
ImageView imageView = this.iv_loading2;
if (imageView == null || imageView.getVisibility() != 0) {
return;
}
this.iv_loading2.clearAnimation();
this.iv_loading2.setVisibility(8);
}
@Override
public void callbackState(HiCamera hiCamera, int i, int i2, int i3) {
if (this.mCamera != hiCamera) {
return;
}
Bundle bundle = new Bundle();
bundle.putInt(a.k, i);
bundle.putInt(CSSStylePropertyConstants.WIDTH, i2);
bundle.putInt(CSSStylePropertyConstants.HEIGHT, i3);
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) {
if (this.mCamera != hiCamera) {
return;
}
HiLogcatUtil.d("command-> " + i);
Bundle bundle = new Bundle();
bundle.putInt(a.k, i);
bundle.putInt(CSSStylePropertyConstants.WIDTH, i2);
bundle.putInt(CSSStylePropertyConstants.HEIGHT, i3);
bundle.putString(TTDownloadField.TT_FILE_NAME, str);
Message obtainMessage = this.mHandler.obtainMessage();
obtainMessage.what = HiDataValue.HANDLE_MESSAGE_PLAY_STATE;
obtainMessage.setData(bundle);
this.mHandler.sendMessage(obtainMessage);
}
@Override
public void receiveIOCtrlData(HiCamera hiCamera, int i, byte[] bArr, int i2) {
if (hiCamera != this.mCamera) {
return;
}
Bundle bundle = new Bundle();
bundle.putByteArray("data", bArr);
Message obtainMessage = this.mHandler.obtainMessage();
obtainMessage.what = HiDataValue.HANDLE_MESSAGE_RECEIVE_IOCTRL;
obtainMessage.obj = hiCamera;
obtainMessage.arg1 = i;
obtainMessage.arg2 = i2;
obtainMessage.setData(bundle);
this.mHandler.sendMessage(obtainMessage);
}
@Override
public void receiveSessionState(HiCamera hiCamera, int i) {
if (this.mCamera != hiCamera) {
return;
}
Message obtainMessage = this.mHandler.obtainMessage();
obtainMessage.what = HiDataValue.HANDLE_MESSAGE_SESSION_STATE;
obtainMessage.obj = hiCamera;
obtainMessage.arg1 = i;
this.mHandler.sendMessage(obtainMessage);
}
protected void handCameraPlayState(Bundle bundle) {
int i = bundle.getInt(a.k);
String string = bundle.getString(TTDownloadField.TT_FILE_NAME);
if (i == 0) {
this.isReadyPlay = true;
setTime();
dismissLoadingView();
MyCamera myCamera = this.mCamera;
Bitmap snapshot_EXT = myCamera != null ? myCamera.getSnapshot_EXT(1, 640, 352) : null;
if (snapshot_EXT != null) {
HiTools.saveSnapshot(BitmapUtils.ImageCrop(snapshot_EXT), this.mCamera, this);
return;
}
return;
}
if (i == 3) {
if (TextUtils.isEmpty(string) || this.mRecordingState != 2) {
return;
}
grabRecordSnapshot(string);
return;
}
if ((i == 4 || i == 5) && !TextUtils.isEmpty(this.recordFile)) {
File file = new File(this.recordFile);
if (file.length() <= 1024 && file.isFile() && file.exists()) {
file.delete();
}
}
}
private void grabRecordSnapshot(String str) {
MyCamera myCamera = this.mCamera;
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(WallMountedActivity.this.mCamera.getUid(), WallMountedActivity.this));
if (!file.exists()) {
file.mkdirs();
}
String[] split = new File(str).getName().split("\\.");
HiTools.saveBitmap(bitmap, file.getAbsolutePath() + "/" + split[0]);
return null;
}
}.execute(new Void[0]);
}
protected void handCameraSessionState(int i) {
MyCamera myCamera;
if (i != 0) {
if (i == 5 && (myCamera = this.mCamera) != null) {
myCamera.stopLiveShow();
this.mCamera.disconnect(1);
if (this.isListening) {
this.isListening = false;
this.btn_live_listen.setImageResource(R.mipmap.camhi_live_normal_speaker);
this.btn_microphone.setVisibility(8);
return;
}
return;
}
return;
}
finish();
setViewWhetherClick(false);
showLoadingView();
MyCamera myCamera2 = this.mCamera;
if (myCamera2 != null) {
myCamera2.stopLiveShow();
if (this.isListening) {
this.isListening = false;
this.btn_live_listen.setImageResource(R.mipmap.camhi_live_normal_speaker);
this.btn_microphone.setVisibility(8);
}
}
}
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (view.getId() == R.id.monitor_wall_mounted) {
int pointerCount = motionEvent.getPointerCount();
if ((motionEvent.getAction() & 255) == 5 && 2 == pointerCount) {
this.mMonitor.setTouchMove(2);
for (int i = 0; i < pointerCount; i++) {
motionEvent.getX(i);
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++) {
motionEvent.getX(i3);
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 < 10 && abs5 < 10) {
return true;
}
if (sqrt > this.nLenStart) {
resetMonitorSize(true, sqrt);
} else {
resetMonitorSize(false, sqrt);
}
this.xlenOld = abs2;
this.ylenOld = abs3;
this.nLenStart = sqrt;
return true;
}
if (motionEvent.getAction() == 1) {
this.mMonitor.setTouchMove(0);
} else if (pointerCount == 1) {
int action = motionEvent.getAction();
if (action == 0) {
motionEvent.getRawX();
motionEvent.getRawY();
this.action_down_X = motionEvent.getRawX();
this.action_down_Y = motionEvent.getRawY();
this.monitorHandler.removeCallbacksAndMessages(null);
this.mMonitor.setTouchMove(0);
} else if (action != 1) {
if (action == 2) {
this.mMonitor.getTouchMove();
}
} else if (this.mIsCruise) {
this.monitorHandler.postDelayed(new Runnable() {
@Override
public void run() {
WallMountedActivity.this.mMonitor.SetCruise(WallMountedActivity.this.mIsCruise);
}
}, 2000L);
}
}
}
} else if (view.getId() == R.id.btn_microphone) {
int action2 = motionEvent.getAction();
if (action2 == 0) {
if (HiTools.HiPermission(this, this, 2, 10002)) {
this.mIsOnpause = true;
return true;
}
OrientationWatchDog orientationWatchDog = this.mOrientationWatchDog;
if (orientationWatchDog != null) {
orientationWatchDog.setCloseOrientation(true);
}
this.btn_live_listen.setClickable(false);
this.btn_live_listen.setImageResource(R.mipmap.camhi_live_normal_speaker);
if (System.currentTimeMillis() - this.oldClickTime >= 1000) {
this.oldClickTime = System.currentTimeMillis();
if (this.mRecordingState == 2) {
this.mCamera.PausePlayAudio();
} else {
this.mCamera.stopListening();
this.mVoiceIsTran = false;
}
this.mCamera.startTalk();
this.btn_microphone.setImageResource(R.mipmap.camhi_live_select_micphone);
this.isTalking = true;
}
} else if (action2 == 1) {
OrientationWatchDog orientationWatchDog2 = this.mOrientationWatchDog;
if (orientationWatchDog2 != null) {
orientationWatchDog2.setCloseOrientation(false);
}
this.btn_live_listen.setClickable(true);
this.btn_live_listen.setImageResource(R.mipmap.camhi_live_select_speaker);
this.mCamera.stopTalk();
if (this.mRecordingState == 2) {
this.mCamera.ResumePlayAudio();
} else {
this.mCamera.startListening();
this.mVoiceIsTran = true;
}
this.btn_microphone.setImageResource(R.mipmap.camhi_live_normal_micphone);
this.isTalking = false;
}
}
return true;
}
public void resetMonitorSize(boolean z, double d) {
this.isLarge = z ? 1 : 2;
if (this.mMonitor.height == 0 && this.mMonitor.width == 0) {
initMatrix(this.mMonitor.screen_width, this.mMonitor.screen_height);
}
this.moveX = (int) (d / 2.0d);
this.moveY = (int) (((d * this.mMonitor.screen_height) / this.mMonitor.screen_width) / 2.0d);
if (z) {
if (this.mMonitor.width <= this.mMonitor.screen_width * 4 && this.mMonitor.height <= this.mMonitor.screen_height * 4) {
this.mMonitor.left -= this.moveX / 2;
this.mMonitor.bottom -= this.moveY / 2;
this.mMonitor.width += this.moveX;
this.mMonitor.height += this.moveY;
}
} 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) {
MyLiveViewGLMonitor myLiveViewGLMonitor = this.mMonitor;
myLiveViewGLMonitor.bottom = myLiveViewGLMonitor.screen_height - this.mMonitor.height;
}
if (this.mMonitor.left + this.mMonitor.width < this.mMonitor.screen_width) {
MyLiveViewGLMonitor myLiveViewGLMonitor2 = this.mMonitor;
myLiveViewGLMonitor2.left = myLiveViewGLMonitor2.screen_width - this.mMonitor.width;
}
}
if (this.mMonitor.left > 0 || this.mMonitor.width < this.mMonitor.screen_width || this.mMonitor.height < this.mMonitor.screen_height || this.mMonitor.bottom > 0) {
initMatrix(this.mMonitor.screen_width, this.mMonitor.screen_height);
}
if (this.mMonitor.width > this.mMonitor.screen_width) {
this.mMonitor.setState(1);
} else {
this.mMonitor.setState(0);
}
MyLiveViewGLMonitor myLiveViewGLMonitor3 = this.mMonitor;
myLiveViewGLMonitor3.setMatrix(myLiveViewGLMonitor3.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 onClick(View view) {
switch (view.getId()) {
case R.id.btn_live_listen:
clickListen((ImageView) view);
return;
case R.id.btn_live_record:
if (HiTools.HiPermission(this, this, 1, 10002)) {
this.mIsOnpause = true;
return;
} else {
clickRecording((ImageView) view);
return;
}
case R.id.btn_live_snapshot:
if (HiTools.HiPermission(this, this, 1, 10002)) {
this.mIsOnpause = true;
return;
} else {
clickSnapshot();
return;
}
case R.id.btn_return:
finish();
return;
case R.id.iv_cruise:
setCruise();
return;
case R.id.iv_white_light:
if (this.lightModel == 3) {
handAbsWhiteLight(0, this.iv_white_light);
return;
} else {
handWhiteLight(0, this.iv_white_light);
return;
}
case R.id.rl_wall_mounted_guide:
SharePreUtils.putBoolean(HiDataValue.CACHE, this, this.mCamera.getUid() + "pb", true);
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;
default:
return;
}
}
public void clickSnapshot() {
if (this.mCamera != null) {
if (HiTools.isSDCardValid()) {
File file = new File(HiDataValue.getPathCameraSnapshot(this.mCamera.getUid(), this));
if (!file.exists()) {
file.mkdirs();
}
String fileNameWithTime = HiTools.getFileNameWithTime(0);
String str = file.getAbsoluteFile() + "/" + fileNameWithTime;
MyCamera myCamera = this.mCamera;
Bitmap snapshot = myCamera != null ? myCamera.getSnapshot() : null;
if (snapshot != null && HiTools.saveImage(str, snapshot)) {
SaveToPhone(str, fileNameWithTime);
Toast makeText = Toast.makeText(this, getText(R.string.tips_snapshot_success), 0);
makeText.show();
this.toastList.add(makeText);
return;
}
Toast makeText2 = Toast.makeText(this, getText(R.string.tips_snapshot_failed), 0);
makeText2.show();
this.toastList.add(makeText2);
return;
}
Toast makeText3 = Toast.makeText(this, getText(R.string.tips_no_sdcard).toString(), 0);
makeText3.show();
this.toastList.add(makeText3);
}
}
private void SaveToPhone(final String str, final String str2) {
new Thread(new Runnable() {
@Override
public void run() {
try {
MediaStore.Images.Media.insertImage(WallMountedActivity.this.getContentResolver(), str, str2, (String) null);
} catch (Exception e) {
e.printStackTrace();
}
WallMountedActivity.this.sendBroadcast(new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE", Uri.parse("file://" + str)));
}
}).start();
}
public void setCruise() {
this.iv_cruise.setSelected(!this.mIsCruise);
if (this.mMonitor.GetFishLager() == 0.0f) {
this.mMonitor.SetPosition(true, 8);
}
initMatrix(this.mMonitor.screen_width, this.mMonitor.screen_height);
MyLiveViewGLMonitor myLiveViewGLMonitor = this.mMonitor;
myLiveViewGLMonitor.setMatrix(myLiveViewGLMonitor.left, this.mMonitor.bottom, this.mMonitor.width, this.mMonitor.height);
MyLiveViewGLMonitor myLiveViewGLMonitor2 = this.mMonitor;
boolean z = !this.mIsCruise;
this.mIsCruise = z;
myLiveViewGLMonitor2.SetCruise(z);
}
private void handAbsWhiteLight(int i, final ImageView imageView) {
boolean z = !this.mWhiteLightSele;
this.mWhiteLightSele = z;
imageView.setSelected(z);
View inflate = View.inflate(this, R.layout.pup_abs_white_light, null);
PopupWindow popupWindow = new PopupWindow(inflate);
popupWindow.setBackgroundDrawable(new ColorDrawable(0));
popupWindow.setOutsideTouchable(true);
popupWindow.setFocusable(false);
popupWindow.setWidth(-2);
popupWindow.setHeight(-2);
popupWindow.showAtLocation(this.iv_white_light, 17, 0, i);
final ImageView imageView2 = (ImageView) inflate.findViewById(R.id.iv_auto);
final ImageView imageView3 = (ImageView) inflate.findViewById(R.id.iv_open);
final ImageView imageView4 = (ImageView) inflate.findViewById(R.id.iv_close);
HiChipDefines.ABSOLUTE_LIGHT_TYPE absolute_light_type = this.abs_light;
if (absolute_light_type != null && absolute_light_type.s32State < 3) {
if (this.abs_light.s32State == 0) {
imageView2.setImageResource(R.mipmap.finish);
imageView3.setImageResource(0);
imageView4.setImageResource(0);
} else if (this.abs_light.s32State == 1) {
imageView2.setImageResource(0);
imageView3.setImageResource(R.mipmap.finish);
imageView4.setImageResource(0);
} else if (this.abs_light.s32State == 2) {
imageView2.setImageResource(0);
imageView3.setImageResource(0);
imageView4.setImageResource(R.mipmap.finish);
}
}
((LinearLayout) inflate.findViewById(R.id.ll_auto)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (WallMountedActivity.this.abs_light != null) {
WallMountedActivity.this.abs_light.s32State = 0;
imageView2.setImageResource(R.mipmap.finish);
imageView3.setImageResource(0);
imageView4.setImageResource(0);
WallMountedActivity.this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_ABSOLUTE_LIGHT_TYPE, HiChipDefines.ABSOLUTE_LIGHT_TYPE.parseContent(WallMountedActivity.this.abs_light.s32State));
}
}
});
((LinearLayout) inflate.findViewById(R.id.ll_open)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (WallMountedActivity.this.abs_light != null) {
WallMountedActivity.this.abs_light.s32State = 1;
imageView2.setImageResource(0);
imageView3.setImageResource(R.mipmap.finish);
imageView4.setImageResource(0);
WallMountedActivity.this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_ABSOLUTE_LIGHT_TYPE, HiChipDefines.ABSOLUTE_LIGHT_TYPE.parseContent(WallMountedActivity.this.abs_light.s32State));
}
}
});
((LinearLayout) inflate.findViewById(R.id.ll_close)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (WallMountedActivity.this.abs_light != null) {
WallMountedActivity.this.abs_light.s32State = 2;
imageView2.setImageResource(0);
imageView3.setImageResource(0);
imageView4.setImageResource(R.mipmap.finish);
WallMountedActivity.this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_SET_ABSOLUTE_LIGHT_TYPE, HiChipDefines.ABSOLUTE_LIGHT_TYPE.parseContent(WallMountedActivity.this.abs_light.s32State));
}
}
});
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
imageView.setSelected(false);
}
});
imageView.setSelected(true);
}
private void handWhiteLight(int i, final ImageView imageView) {
HiChipDefines.HI_P2P_WHITE_LIGHT_INFO hi_p2p_white_light_info;
int i2 = this.lightModel;
if (i2 != 1) {
if (i2 != 2 || (hi_p2p_white_light_info = this.light_info) == null) {
return;
}
if (this.mWhiteLightSele) {
hi_p2p_white_light_info.u32State = 1;
this.mWhiteLightSele = false;
} else {
hi_p2p_white_light_info.u32State = 0;
this.mWhiteLightSele = true;
}
this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_WHITE_LIGHT_SET, HiChipDefines.HI_P2P_WHITE_LIGHT_INFO.parseContent(this.light_info.u32Chn, this.light_info.u32State));
this.iv_white_light.setSelected(this.mWhiteLightSele);
return;
}
boolean z = !this.mWhiteLightSele;
this.mWhiteLightSele = z;
imageView.setSelected(z);
View inflate = View.inflate(this, R.layout.pup_white_light, null);
PopupWindow popupWindow = new PopupWindow(inflate);
popupWindow.setBackgroundDrawable(new ColorDrawable(0));
popupWindow.setOutsideTouchable(true);
popupWindow.setFocusable(false);
popupWindow.setWidth(-2);
popupWindow.setHeight(-2);
popupWindow.showAtLocation(this.iv_white_light, 17, 0, i);
final ImageView imageView2 = (ImageView) inflate.findViewById(R.id.iv_infra);
final ImageView imageView3 = (ImageView) inflate.findViewById(R.id.iv_full_color);
final ImageView imageView4 = (ImageView) inflate.findViewById(R.id.iv_intell);
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) {
if (this.light_info_ext.u32State == 0) {
imageView2.setImageResource(R.mipmap.finish);
imageView3.setImageResource(0);
imageView4.setImageResource(0);
} else if (this.light_info_ext.u32State == 1) {
imageView2.setImageResource(0);
imageView3.setImageResource(R.mipmap.finish);
imageView4.setImageResource(0);
} else if (this.light_info_ext.u32State == 2) {
imageView2.setImageResource(0);
imageView3.setImageResource(0);
imageView4.setImageResource(R.mipmap.finish);
}
}
((LinearLayout) inflate.findViewById(R.id.ll_infrared_mode)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (WallMountedActivity.this.light_info_ext != null) {
WallMountedActivity.this.light_info_ext.u32State = 0;
imageView2.setImageResource(R.mipmap.finish);
imageView3.setImageResource(0);
imageView4.setImageResource(0);
WallMountedActivity.this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_WHITE_LIGHT_SET_EXT, HiChipDefines.HI_P2P_WHITE_LIGHT_INFO_EXT.parseContent(WallMountedActivity.this.light_info_ext.u32Chn, WallMountedActivity.this.light_info_ext.u32State));
}
}
});
((LinearLayout) inflate.findViewById(R.id.ll_full_color_mode)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (WallMountedActivity.this.light_info_ext != null) {
WallMountedActivity.this.light_info_ext.u32State = 1;
imageView2.setImageResource(0);
imageView3.setImageResource(R.mipmap.finish);
imageView4.setImageResource(0);
WallMountedActivity.this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_WHITE_LIGHT_SET_EXT, HiChipDefines.HI_P2P_WHITE_LIGHT_INFO_EXT.parseContent(WallMountedActivity.this.light_info_ext.u32Chn, WallMountedActivity.this.light_info_ext.u32State));
}
}
});
((LinearLayout) inflate.findViewById(R.id.ll_intelligence_mode)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (WallMountedActivity.this.light_info_ext != null) {
WallMountedActivity.this.light_info_ext.u32State = 2;
imageView2.setImageResource(0);
imageView3.setImageResource(0);
imageView4.setImageResource(R.mipmap.finish);
WallMountedActivity.this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_WHITE_LIGHT_SET_EXT, HiChipDefines.HI_P2P_WHITE_LIGHT_INFO_EXT.parseContent(WallMountedActivity.this.light_info_ext.u32Chn, WallMountedActivity.this.light_info_ext.u32State));
}
}
});
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
imageView.setSelected(false);
}
});
imageView.setSelected(true);
}
private void clickRecording(ImageView imageView) {
int i = this.mRecordingState;
if (i != 0) {
if (i == 2) {
endRecording();
}
} else {
this.mStartRecoedTime = 0L;
TimerRecording();
this.btn_live_record.setImageResource(R.mipmap.camhi_live_select_recording);
this.mRecordingState = 2;
this.ll_recording.setVisibility(0);
this.handler.sendEmptyMessage(110);
}
}
public void endRecording() {
this.mRecordingState = 1;
if (this.mVoiceIsTran && this.btn_microphone.getVisibility() == 8) {
this.mCamera.stopListening();
this.mVoiceIsTran = false;
}
this.mCamera.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.btn_live_record.setImageResource(R.mipmap.camhi_live_normal_recording);
this.mRecordingState = 0;
this.ll_recording.setVisibility(8);
this.handler.removeCallbacksAndMessages(null);
if (TextUtils.isEmpty(this.recordFile)) {
return;
}
File file = new File(this.recordFile);
if (file.length() <= 1024 && file.isFile() && file.exists()) {
file.delete();
}
}
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;
}
File file = new File(HiDataValue.getPathCameraVideoLocalRecord(this.mCamera.getUid(), this));
if (!file.exists()) {
file.mkdirs();
}
this.timer = new Timer();
AnonymousClass15 anonymousClass15 = new AnonymousClass15(file);
this.timerTask = anonymousClass15;
this.timer.schedule(anonymousClass15, 0L, TTAdConstant.AD_MAX_EVENT_TIME);
}
public class AnonymousClass15 extends TimerTask {
boolean isFirst = true;
final File val$cameraFolder;
AnonymousClass15(File file) {
this.val$cameraFolder = file;
}
@Override
public void run() {
if (WallMountedActivity.this.mRecordingState == 2) {
WallMountedActivity.this.mCamera.stopRecording();
}
WallMountedActivity.this.recordFile = this.val$cameraFolder.getAbsoluteFile() + "/" + HiTools.getFileNameWithTime(1);
long availableSize = HiTools.getAvailableSize();
if (availableSize < 100 && availableSize > 0) {
WallMountedActivity.this.handler.sendEmptyMessage(288);
} else if (this.isFirst) {
WallMountedActivity.this.mHandler.post(new Runnable() {
@Override
public void run() {
WallMountedActivity.this.mCamera.startRecording(WallMountedActivity.this.recordFile);
AnonymousClass15.this.isFirst = false;
}
});
} else {
WallMountedActivity.this.mHandler.postDelayed(new Runnable() {
@Override
public void run() {
WallMountedActivity.this.mCamera.startRecording(WallMountedActivity.this.recordFile);
}
}, 1000L);
}
}
}
private void clickListen(ImageView imageView) {
if (this.mRecordingState == 2) {
if (this.mVoiceIsTran) {
this.mCamera.PausePlayAudio();
} else {
this.mCamera.stopRecording();
this.mCamera.startListening();
this.mVoiceIsTran = true;
TimerRecording();
this.mStartRecoedTime = 0L;
}
if (this.isListening) {
imageView.setImageResource(R.mipmap.camhi_live_normal_speaker);
this.btn_microphone.setVisibility(8);
this.mCamera.stopListening();
} else {
imageView.setImageResource(R.mipmap.camhi_live_select_speaker);
this.btn_microphone.setVisibility(0);
this.mCamera.startListening();
}
} else if (this.isListening) {
imageView.setImageResource(R.mipmap.camhi_live_normal_speaker);
this.mCamera.stopListening();
this.mVoiceIsTran = false;
this.btn_microphone.setVisibility(8);
} else {
imageView.setImageResource(R.mipmap.camhi_live_select_speaker);
this.btn_microphone.setVisibility(0);
this.mCamera.startListening();
this.mVoiceIsTran = true;
}
this.isListening = !this.isListening;
}
private void showAlertDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(getString(R.string.tips_no_permission));
builder.setPositiveButton(getString(R.string.setting), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
WallMountedActivity.this.lambda$showAlertDialog$0$WallMountedActivity(dialogInterface, i);
}
});
builder.setNegativeButton(getString(R.string.cancel), (DialogInterface.OnClickListener) null);
builder.show();
}
public void lambda$showAlertDialog$0$WallMountedActivity(DialogInterface dialogInterface, int i) {
HiTools.toSelfSetting(this);
}
private void setViewWhetherClick(boolean z) {
this.btn_live_listen.setClickable(z);
this.btn_live_record.setClickable(z);
}
@Override
public void finish() {
MyLiveViewGLMonitor myLiveViewGLMonitor = this.mMonitor;
if (myLiveViewGLMonitor != null) {
myLiveViewGLMonitor.FreeMonitor();
this.mMonitor = null;
}
super.finish();
}
@Override
public void onBackPressed() {
MyLiveViewGLMonitor myLiveViewGLMonitor = this.mMonitor;
if (myLiveViewGLMonitor != null) {
myLiveViewGLMonitor.FreeMonitor();
this.mMonitor = null;
}
super.onBackPressed();
}
@Override
public void changedScreenDirection(int i) {
if (this.isReadyPlay) {
if (i == 90) {
this.isLeft = false;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (WallMountedActivity.this.isLarge == 1) {
WallMountedActivity wallMountedActivity = WallMountedActivity.this;
wallMountedActivity.resetMonitorSize(true, wallMountedActivity.nLenStart);
} else if (WallMountedActivity.this.isLarge == 2) {
WallMountedActivity wallMountedActivity2 = WallMountedActivity.this;
wallMountedActivity2.resetMonitorSize(false, wallMountedActivity2.nLenStart);
}
}
}, 200L);
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;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (WallMountedActivity.this.isLarge == 1) {
WallMountedActivity wallMountedActivity = WallMountedActivity.this;
wallMountedActivity.resetMonitorSize(true, wallMountedActivity.nLenStart);
} else if (WallMountedActivity.this.isLarge == 2) {
WallMountedActivity wallMountedActivity2 = WallMountedActivity.this;
wallMountedActivity2.resetMonitorSize(false, wallMountedActivity2.nLenStart);
}
}
}, 200L);
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 == 10002) {
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);
}
}
}