PlaybackOnlineActivity.java 源代码
package activity.video;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.drawable.ColorDrawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
import android.util.DisplayMetrics;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import base.HiActivity;
import bean.MyCamera;
import com.hichip.base.HiThread;
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 common.HiDataValue;
import common.MyPlaybackGLMonitor;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import main.MainActivity;
import utils.HiLogcatUtil;
import utils.HiTools;
import utils.MyToast;
import utils.OrientationWatchDog;
import utils.SharePreUtils;
public class PlaybackOnlineActivity extends HiActivity implements ICameraIOSessionCallback, ICameraPlayStateCallback, View.OnTouchListener, View.OnClickListener, OrientationWatchDog.OnOrientationListener {
private static final int HANDLE_MESSAGE_PROGRESSBAR_RUN = -1879048190;
private static final int HANDLE_MESSAGE_SEEKBAR_RUN = -1879048189;
public static final short HI_P2P_PB_GETPOS = 5;
public static final short HI_P2P_PB_PAUSE = 3;
public static final short HI_P2P_PB_PLAY = 1;
public static final short HI_P2P_PB_SETPOS = 4;
public static final short HI_P2P_PB_STOP = 2;
private static final int PERMISSION_REQUEST_CODE_STORAGE = 10024;
private static final SimpleDateFormat sdf = new SimpleDateFormat("mm:ss");
private int PictureRealHeight;
private int PictureRealWidth;
private float action_down_x;
private float action_down_y;
public float bottom;
private long endTimeLong;
public float height;
private boolean hideUIMenu;
private ImageView img_shade;
private ImageView ivAdaption;
private ImageView ivSnapshot;
private ImageView ivSpeed;
private long lastClickTime;
float lastX;
float lastY;
public float left;
private MyCamera mCamera;
private LinearLayout mLlCurrPro;
private MyPlaybackGLMonitor mMonitor;
public OrientationWatchDog mOrientationWatchDog;
private PopupWindow mPopupWindow;
private TextView mTvCurrPro;
private TextView mTvEndTime;
private TextView mTvPrecent;
private TextView mTvStartTime;
private LinearLayout mllPlay;
private short model;
int moveX;
int moveY;
float move_x;
float move_y;
private ConnectionChangeReceiver myReceiver;
private byte[] oldStartTime;
long oldTime;
private ImageView play_btn_exit;
private ImageView play_btn_playback_online;
private long playback_time;
private RelativeLayout playback_view_screen;
private int progressTime;
private ProgressBar prs_loading;
private SeekBar prs_playing;
public LinearLayout root_lock_screen;
private byte[] startTime;
private long startTimeLong;
private TextView tvAdaption;
private TextView tvFill;
private TextView tvSpeed;
private int video_height;
private int video_width;
public float width;
int xlenOld;
int ylenOld;
private ProgressThread pthread = null;
private boolean mVisible = true;
private boolean visible = true;
private boolean isPlaying = false;
private boolean mIsDrag = false;
private boolean mIsEnd = false;
private int mSpeed = 0;
private int mPictureSize = 0;
private boolean isLeft = true;
private boolean isFirstRevolveLand = false;
private boolean isReadyPlay = false;
private boolean isDoPause = true;
private Handler handler = new Handler() {
@Override
public void handleMessage(Message message) {
int i = message.what;
if (i == -6) {
HiLogcatUtil.e("################# playbackonline PLAY_ONLINESTATE_ERROR ############## ");
PlaybackOnlineActivity playbackOnlineActivity = PlaybackOnlineActivity.this;
Toast.makeText(playbackOnlineActivity, playbackOnlineActivity.getString(R.string.play_4k_sd_error), 1).show();
PlaybackOnlineActivity.this.mCamera.stopPlayback();
PlaybackOnlineActivity.this.mCamera.SetPlaybackSpeed(false, 0, PlaybackOnlineActivity.this.startTime, 0, 0);
PlaybackOnlineActivity.this.mCamera.setReconnectTimes(10);
PlaybackOnlineActivity.this.startActivity(new Intent(PlaybackOnlineActivity.this, (Class<?>) MainActivity.class));
return;
}
if (i != 8195) {
if (i != 16677) {
if (i != 16733 && i != 16846 && i != 18461) {
if (i == 0) {
PlaybackOnlineActivity.this.isReadyPlay = true;
PlaybackOnlineActivity.this.prs_playing.setEnabled(true);
PlaybackOnlineActivity.this.play_btn_playback_online.setClickable(true);
PlaybackOnlineActivity.this.isPlaying = true;
PlaybackOnlineActivity.this.model = (short) 1;
PlaybackOnlineActivity.this.mIsEnd = false;
PlaybackOnlineActivity.this.play_btn_playback_online.setSelected(false);
PlaybackOnlineActivity.this.resetMonitorSize();
PlaybackOnlineActivity playbackOnlineActivity2 = PlaybackOnlineActivity.this;
playbackOnlineActivity2.handLandScape(playbackOnlineActivity2.mPictureSize);
return;
}
if (i == 1) {
PlaybackOnlineActivity.this.isPlaying = false;
PlaybackOnlineActivity.this.mIsEnd = true;
PlaybackOnlineActivity.this.model = (short) 2;
PlaybackOnlineActivity.this.play_btn_playback_online.setSelected(true);
PlaybackOnlineActivity.this.prs_playing.setProgress(PlaybackOnlineActivity.this.progressTime);
PlaybackOnlineActivity.this.mCamera.stopPlayback();
PlaybackOnlineActivity.this.mCamera.SetPlaybackSpeed(false, 0, PlaybackOnlineActivity.this.startTime, 0, 0);
PlaybackOnlineActivity.this.mSpeed = 0;
PlaybackOnlineActivity.this.tvSpeed.setText("");
PlaybackOnlineActivity playbackOnlineActivity3 = PlaybackOnlineActivity.this;
MyToast.showToast(playbackOnlineActivity3, playbackOnlineActivity3.getString(R.string.tips_stop_video));
return;
}
if (i != 16768) {
if (i != 16769) {
switch (i) {
case HiDataValue.HANDLE_MESSAGE_SESSION_STATE:
MyCamera myCamera = (MyCamera) message.obj;
int i2 = message.arg1;
if (i2 == 0 || i2 == 5) {
PlaybackOnlineActivity.this.prs_playing.setEnabled(true);
PlaybackOnlineActivity.this.play_btn_playback_online.setClickable(true);
if (myCamera != null) {
myCamera.stopPlayback();
}
PlaybackOnlineActivity playbackOnlineActivity4 = PlaybackOnlineActivity.this;
MyToast.showToast(playbackOnlineActivity4, playbackOnlineActivity4.getString(R.string.tips_network_disconnect));
PlaybackOnlineActivity.this.NetworkError();
return;
}
return;
case PlaybackOnlineActivity.HANDLE_MESSAGE_PROGRESSBAR_RUN:
int progress = PlaybackOnlineActivity.this.prs_loading.getProgress();
if (progress >= 100) {
PlaybackOnlineActivity.this.prs_loading.setProgress(10);
} else {
PlaybackOnlineActivity.this.prs_loading.setProgress(progress + 8);
}
PlaybackOnlineActivity.this.model = (short) 1;
return;
case -1879048189:
PlaybackOnlineActivity.this.play_btn_playback_online.setClickable(true);
if (PlaybackOnlineActivity.this.mIsDrag) {
return;
}
PlaybackOnlineActivity.this.prs_playing.setProgress(message.arg1);
PlaybackOnlineActivity.this.mTvStartTime.setText(PlaybackOnlineActivity.sdf.format(new Date(message.arg1 * 1000)));
return;
default:
return;
}
}
}
}
}
PlaybackOnlineActivity.this.model = (short) 1;
if (PlaybackOnlineActivity.this.mSpeed != 0 || PlaybackOnlineActivity.this.isPlaying || PlaybackOnlineActivity.this.mIsEnd) {
return;
}
PlaybackOnlineActivity.this.mCamera.SetPauseOnLine(false);
if (PlaybackOnlineActivity.this.mCamera.appGetCommandFunction(HiChipDefines.HI_P2P_PB_PLAY_CONTROL_NEW)) {
PlaybackOnlineActivity.this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_PB_PLAY_CONTROL_NEW, HiChipDefines.HI_P2P_S_PB_PLAY_REQ.parseContent(0, (short) 3, PlaybackOnlineActivity.this.startTime));
} else if (PlaybackOnlineActivity.this.mCamera.appGetCommandFunction(HiChipDefines.HI_P2P_PB_PLAY_CONTROL_EXT)) {
PlaybackOnlineActivity.this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_PB_PLAY_CONTROL_EXT, HiChipDefines.HI_P2P_S_PB_PLAY_REQ.parseContent(0, (short) 3, PlaybackOnlineActivity.this.startTime));
} else {
PlaybackOnlineActivity.this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_PB_PLAY_CONTROL, HiChipDefines.HI_P2P_S_PB_PLAY_REQ.parseContent(0, (short) 3, PlaybackOnlineActivity.this.startTime));
}
PlaybackOnlineActivity.this.play_btn_playback_online.setSelected(false);
PlaybackOnlineActivity.this.isPlaying = !r13.isPlaying;
return;
}
if (message.arg2 == 0) {
byte[] byteArray = message.getData().getByteArray("data");
int i3 = -1;
if (byteArray.length > 12) {
i3 = Packet.byteArrayToInt_Little(byteArray, 12);
} else if (byteArray.length == 12) {
i3 = 1;
}
if (i3 != 1) {
if (i3 == 3) {
PlaybackOnlineActivity.this.play_btn_playback_online.setClickable(true);
return;
}
return;
}
PlaybackOnlineActivity.this.video_width = Packet.byteArrayToInt_Little(byteArray, 0);
PlaybackOnlineActivity.this.video_height = Packet.byteArrayToInt_Little(byteArray, 4);
if (PlaybackOnlineActivity.this.video_width <= 0 || PlaybackOnlineActivity.this.video_height <= 0 || PlaybackOnlineActivity.this.video_height >= 5000 || PlaybackOnlineActivity.this.video_width >= 5000) {
PlaybackOnlineActivity.this.finish();
PlaybackOnlineActivity playbackOnlineActivity5 = PlaybackOnlineActivity.this;
MyToast.showToast(playbackOnlineActivity5, playbackOnlineActivity5.getString(R.string.tips_open_video_fail));
return;
}
return;
}
PlaybackOnlineActivity.this.finish();
PlaybackOnlineActivity playbackOnlineActivity6 = PlaybackOnlineActivity.this;
MyToast.showToast(playbackOnlineActivity6, playbackOnlineActivity6.getString(R.string.tips_open_video_fail));
}
};
double nLenStart = 0.0d;
public int isLarge = 0;
private Handler mHandler_lockScreen = new Handler() {
@Override
public void handleMessage(Message message) {
if (message.what == 0) {
PlaybackOnlineActivity.this.root_lock_screen.setVisibility(0);
PlaybackOnlineActivity.this.mHandler_lockScreen.sendEmptyMessageDelayed(1, 3000L);
} else {
PlaybackOnlineActivity.this.root_lock_screen.setVisibility(8);
PlaybackOnlineActivity.this.mHandler_lockScreen.removeCallbacksAndMessages(null);
}
}
};
@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 callbackRecordState(HiCamera hiCamera, int i, int i2, int i3, String str) {
}
@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 void initWindow() {
}
@Override
public void onStart() {
super.onStart();
IntentFilter intentFilter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
ConnectionChangeReceiver connectionChangeReceiver = new ConnectionChangeReceiver();
this.myReceiver = connectionChangeReceiver;
registerReceiver(connectionChangeReceiver, intentFilter);
}
@Override
protected int setLayoutId() {
getWindow().addFlags(128);
getWindow().setFlags(1024, 1024);
return R.layout.activity_playback_online_landscape;
}
@Override
protected void init(Bundle bundle) {
Bundle extras = getIntent().getExtras();
String string = extras.getString(HiDataValue.EXTRAS_KEY_UID);
byte[] byteArray = extras.getByteArray("st");
byte[] bArr = new byte[8];
this.oldStartTime = bArr;
System.arraycopy(byteArray, 0, bArr, 0, 8);
this.playback_time = extras.getLong("pb_time");
this.startTimeLong = extras.getLong("VIDEO START TIME");
this.endTimeLong = extras.getLong("VIDEO END TIME");
Iterator<MyCamera> it = HiDataValue.CameraList.iterator();
while (true) {
if (!it.hasNext()) {
break;
}
MyCamera next = it.next();
if (next.getUid().equals(string)) {
this.mCamera = next;
break;
}
}
int i = SharePreUtils.getInt(HiDataValue.CACHE, this, "pictureSize" + HiDataValue.userAccount + this.mCamera.getUid());
this.mPictureSize = i;
if (i == -1) {
this.mPictureSize = 0;
}
initView();
setListerners();
showLoadingShade();
this.mCamera.registerIOSessionListener(this);
this.mCamera.registerPlayStateListener(this);
if (this.mCamera.appGetCommandFunction(HiChipDefines.HI_P2P_PB_QUERY_START_NODST)) {
this.startTime = this.oldStartTime;
} else if (this.mCamera.getSummerTimer()) {
HiChipDefines.STimeDay sTimeDay = new HiChipDefines.STimeDay(this.oldStartTime, 0);
sTimeDay.resetData(-1);
this.startTime = sTimeDay.parseContent();
} else {
this.startTime = this.oldStartTime;
}
startPlayBack();
this.model = (short) 1;
OrientationWatchDog orientationWatchDog = new OrientationWatchDog(this);
this.mOrientationWatchDog = orientationWatchDog;
orientationWatchDog.setOnOrientationListener(this);
this.mOrientationWatchDog.startWatch();
}
private void setListerners() {
this.ivSnapshot.setOnClickListener(new $$Lambda$_9cdAMwgRMtYJ9DBH0AV6MaYoMM(this));
this.ivAdaption.setOnClickListener(this);
this.mMonitor.setOnTouchListener(this);
this.play_btn_exit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PlaybackOnlineActivity.this.finish();
}
});
this.mMonitor.setOnClickListener(this);
this.root_lock_screen.setOnClickListener(this);
}
public synchronized void startPlayBack() {
new Thread() {
@Override
public void run() {
super.run();
PlaybackOnlineActivity.this.mCamera.startPlayback(new HiChipDefines.STimeDay(PlaybackOnlineActivity.this.startTime, 0), PlaybackOnlineActivity.this.mMonitor);
PlaybackOnlineActivity.this.mCamera.SetPlaybackSeekbar(0, PlaybackOnlineActivity.this.progressTime);
PlaybackOnlineActivity.this.mCamera.SetPlaybackSpeed(false, PlaybackOnlineActivity.this.progressTime, PlaybackOnlineActivity.this.startTime, 0, 0);
}
}.start();
}
private void initView() {
this.ivSnapshot = (ImageView) findViewById(R.id.iv_snapshot);
this.ivAdaption = (ImageView) findViewById(R.id.iv_adaption);
MyPlaybackGLMonitor myPlaybackGLMonitor = (MyPlaybackGLMonitor) findViewById(R.id.monitor_playback_view);
this.mMonitor = myPlaybackGLMonitor;
myPlaybackGLMonitor.setCamera(this.mCamera);
this.mCamera.setLiveShowMonitor(this.mMonitor);
this.play_btn_exit = (ImageView) findViewById(R.id.play_btn_playback_exit);
this.prs_loading = (ProgressBar) findViewById(R.id.prs_loading);
this.img_shade = (ImageView) findViewById(R.id.img_shade);
this.mllPlay = (LinearLayout) findViewById(R.id.rl_play);
this.mTvStartTime = (TextView) findViewById(R.id.tv_start_time);
TextView textView = (TextView) findViewById(R.id.tv_end_time);
this.mTvEndTime = textView;
textView.setText(sdf.format(new Date(this.endTimeLong - this.startTimeLong)));
this.progressTime = (int) ((this.endTimeLong - this.startTimeLong) / 1000);
SeekBar seekBar = (SeekBar) findViewById(R.id.prs_playing);
this.prs_playing = seekBar;
seekBar.setMax(this.progressTime);
this.prs_playing.setProgress(0);
this.mLlCurrPro = (LinearLayout) findViewById(R.id.ll_cureent_progress);
this.mTvCurrPro = (TextView) findViewById(R.id.tv_current_pro);
this.mTvPrecent = (TextView) findViewById(R.id.tv_precent);
this.prs_playing.setEnabled(false);
this.prs_playing.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar2) {
if (PlaybackOnlineActivity.this.mIsEnd) {
PlaybackOnlineActivity.this.prs_playing.setEnabled(false);
PlaybackOnlineActivity.this.play_btn_playback_online.setClickable(false);
PlaybackOnlineActivity.this.mCamera.startPlayback(new HiChipDefines.STimeDay(PlaybackOnlineActivity.this.startTime, 0), PlaybackOnlineActivity.this.mMonitor);
}
int progress = seekBar2.getProgress();
int i = (progress * 100) / PlaybackOnlineActivity.this.progressTime;
if (PlaybackOnlineActivity.this.progressTime > 500) {
if (progress >= PlaybackOnlineActivity.this.progressTime * 0.98d) {
i = 98;
progress = (int) (PlaybackOnlineActivity.this.progressTime * 0.98d);
}
} else if (i >= 100.0d - (1000.0d / PlaybackOnlineActivity.this.progressTime)) {
i = (int) (100.0d - (1000.0d / PlaybackOnlineActivity.this.progressTime));
progress = (PlaybackOnlineActivity.this.progressTime * i) / 100;
}
if (i < 1) {
if (!PlaybackOnlineActivity.this.mIsEnd) {
PlaybackOnlineActivity.this.mCamera.stopPlayback();
PlaybackOnlineActivity.this.mCamera.SetPlaybackSpeed(false, 0, PlaybackOnlineActivity.this.startTime, 0, 0);
PlaybackOnlineActivity.this.startPlayBack();
}
} else {
if (PlaybackOnlineActivity.this.mCamera.appGetCommandFunction(HiChipDefines.HI_P2P_PB_POS_SET_NEW)) {
PlaybackOnlineActivity.this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_PB_POS_SET_NEW, HiChipDefines.HI_P2P_PB_SETPOS_REQ.parseContent(0, i, PlaybackOnlineActivity.this.startTime));
} else {
PlaybackOnlineActivity.this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_PB_POS_SET, HiChipDefines.HI_P2P_PB_SETPOS_REQ.parseContent(0, i, PlaybackOnlineActivity.this.startTime));
}
PlaybackOnlineActivity.this.mCamera.SetPlaybackSeekbar(progress, PlaybackOnlineActivity.this.progressTime);
}
PlaybackOnlineActivity.this.model = (short) 3;
PlaybackOnlineActivity.this.mIsDrag = false;
PlaybackOnlineActivity.this.mLlCurrPro.setVisibility(8);
PlaybackOnlineActivity.this.mSpeed = 0;
PlaybackOnlineActivity.this.tvSpeed.setText("");
PlaybackOnlineActivity.this.mCamera.SetPlaybackSpeed(false, 0, PlaybackOnlineActivity.this.startTime, 0, 0);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar2) {
PlaybackOnlineActivity.this.mIsDrag = true;
}
@Override
public void onProgressChanged(SeekBar seekBar2, int i, boolean z) {
if (PlaybackOnlineActivity.this.mIsDrag) {
PlaybackOnlineActivity.this.mLlCurrPro.setVisibility(0);
int round = (int) Math.round((i / PlaybackOnlineActivity.this.progressTime) * 100.0d);
PlaybackOnlineActivity.this.mTvPrecent.setText(round + "%");
PlaybackOnlineActivity.this.mTvStartTime.setText(PlaybackOnlineActivity.sdf.format(new Date((long) (i * 1000))));
return;
}
PlaybackOnlineActivity.this.mLlCurrPro.setVisibility(8);
}
});
RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.playback_view_screen);
this.playback_view_screen = relativeLayout;
relativeLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (PlaybackOnlineActivity.this.model == 0) {
return;
}
PlaybackOnlineActivity.this.visible = !r2.visible;
PlaybackOnlineActivity.this.mllPlay.setVisibility(PlaybackOnlineActivity.this.visible ? 0 : 8);
}
});
ImageView imageView = (ImageView) findViewById(R.id.play_btn_playback_online);
this.play_btn_playback_online = imageView;
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PlaybackOnlineActivity.this.setPauseOnline();
}
});
this.play_btn_playback_online.setClickable(false);
this.ivSpeed = (ImageView) findViewById(R.id.iv_speed);
this.tvSpeed = (TextView) findViewById(R.id.tv_speed);
this.ivSpeed.setOnClickListener(new $$Lambda$_9cdAMwgRMtYJ9DBH0AV6MaYoMM(this));
if (this.mCamera.getConnectMode() == 2 || this.mCamera.isLanConnect()) {
this.ivSpeed.setVisibility(0);
this.tvSpeed.setVisibility(0);
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
PopupWindow popupWindow = this.mPopupWindow;
if (popupWindow == null || !popupWindow.isShowing()) {
return;
}
this.mPopupWindow.dismiss();
}
public void setPauseOnline() {
if (this.mCamera.getConnectState() == 4) {
if (this.mIsEnd) {
this.play_btn_playback_online.setClickable(false);
this.prs_playing.setEnabled(false);
startPlayBack();
return;
}
if (this.isPlaying) {
this.mCamera.SetPauseOnLine(true);
this.play_btn_playback_online.setSelected(true);
} else {
this.mCamera.SetPauseOnLine(false);
this.play_btn_playback_online.setSelected(false);
}
this.isPlaying = !this.isPlaying;
if (this.mCamera.appGetCommandFunction(HiChipDefines.HI_P2P_PB_PLAY_CONTROL_NEW)) {
this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_PB_PLAY_CONTROL_NEW, HiChipDefines.HI_P2P_S_PB_PLAY_REQ.parseContent(0, (short) 3, this.startTime));
} else if (this.mCamera.appGetCommandFunction(HiChipDefines.HI_P2P_PB_PLAY_CONTROL_EXT)) {
this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_PB_PLAY_CONTROL_EXT, HiChipDefines.HI_P2P_S_PB_PLAY_REQ.parseContent(0, (short) 3, this.startTime));
} else {
this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_PB_PLAY_CONTROL, HiChipDefines.HI_P2P_S_PB_PLAY_REQ.parseContent(0, (short) 3, this.startTime));
}
}
}
private void setImageVisible(boolean z) {
if (z) {
this.prs_playing.setVisibility(0);
this.play_btn_playback_online.setVisibility(0);
} else {
this.play_btn_playback_online.setVisibility(8);
this.prs_playing.setVisibility(8);
}
}
private void showLoadingShade() {
this.prs_loading.setMax(100);
this.prs_loading.setProgress(10);
ProgressThread progressThread = new ProgressThread();
this.pthread = progressThread;
progressThread.startThread();
}
private void displayLoadingShade() {
ProgressThread progressThread = this.pthread;
if (progressThread != null) {
progressThread.stopThread();
}
this.pthread = null;
this.prs_loading.setVisibility(8);
this.img_shade.setVisibility(8);
this.visible = true;
setImageVisible(true);
}
@Override
public void onResume() {
super.onResume();
MyCamera myCamera = this.mCamera;
if (myCamera != null) {
myCamera.registerIOSessionListener(this);
this.mCamera.registerPlayStateListener(this);
}
}
@Override
public void onPause() {
super.onPause();
if (!this.isDoPause) {
this.isDoPause = true;
return;
}
MyCamera myCamera = this.mCamera;
if (myCamera != null) {
if (this.model != 0) {
this.model = (short) 0;
this.oldTime = 0L;
}
myCamera.stopPlayback();
this.mCamera.SetPlaybackSpeed(false, 0, this.startTime, 0, 0);
this.mCamera.unregisterIOSessionListener(this);
this.mCamera.unregisterPlayStateListener(this);
}
ProgressThread progressThread = this.pthread;
if (progressThread != null) {
progressThread.stopThread();
this.pthread = null;
}
setRequestedOrientation(1);
MyPlaybackGLMonitor myPlaybackGLMonitor = this.mMonitor;
if (myPlaybackGLMonitor != null) {
myPlaybackGLMonitor.FreeMonitor();
this.mMonitor = null;
}
finish();
}
@Override
public void onDestroy() {
super.onDestroy();
ConnectionChangeReceiver connectionChangeReceiver = this.myReceiver;
if (connectionChangeReceiver != null) {
unregisterReceiver(connectionChangeReceiver);
}
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);
}
}
public class ProgressThread extends HiThread {
private ProgressThread() {
}
@Override
public void run() {
while (this.isRunning) {
sleep(100);
Message obtainMessage = PlaybackOnlineActivity.this.handler.obtainMessage();
obtainMessage.what = PlaybackOnlineActivity.HANDLE_MESSAGE_PROGRESSBAR_RUN;
PlaybackOnlineActivity.this.handler.sendMessage(obtainMessage);
}
}
}
@Override
public void receiveIOCtrlData(HiCamera hiCamera, int i, byte[] bArr, int i2) {
if (this.mCamera != hiCamera) {
return;
}
Bundle bundle = new Bundle();
bundle.putByteArray("data", bArr);
Message obtainMessage = this.handler.obtainMessage();
obtainMessage.what = i;
obtainMessage.arg2 = i2;
obtainMessage.setData(bundle);
this.handler.sendMessage(obtainMessage);
}
@Override
public void receiveSessionState(HiCamera hiCamera, int i) {
MyCamera myCamera = this.mCamera;
if (hiCamera != myCamera || myCamera == null) {
return;
}
Message obtain = Message.obtain();
obtain.what = HiDataValue.HANDLE_MESSAGE_SESSION_STATE;
obtain.arg1 = i;
obtain.obj = hiCamera;
this.handler.sendMessage(obtain);
}
public void resetMonitorSize() {
RelativeLayout.LayoutParams layoutParams;
if (this.video_width == 0 || this.video_height == 0) {
return;
}
displayLoadingShade();
getWindow().setFlags(1024, 1024);
if (this.hideUIMenu) {
layoutParams = new RelativeLayout.LayoutParams(-1, -1);
} else {
layoutParams = new RelativeLayout.LayoutParams(getWindowManager().getDefaultDisplay().getWidth(), getWindowManager().getDefaultDisplay().getHeight());
}
this.mMonitor.setLayoutParams(layoutParams);
}
@Override
public void callbackPlayUTC(HiCamera hiCamera, int i) {
short s;
if (2 == this.mCamera.getConnectMode() || this.mCamera.isLanConnect() || this.mCamera != hiCamera || (s = this.model) == 3 || s == 0) {
return;
}
if (this.oldTime == 0) {
this.oldTime = i;
}
int i2 = (int) ((i - this.oldTime) / 1000);
Message obtainMessage = this.handler.obtainMessage();
obtainMessage.what = -1879048189;
obtainMessage.arg1 = i2;
this.handler.sendMessage(obtainMessage);
}
@Override
public void callbackPlayUTC2(HiCamera hiCamera, int i, int i2) {
short s;
if ((2 == this.mCamera.getConnectMode() || this.mCamera.isLanConnect()) && this.mCamera == hiCamera && (s = this.model) != 3 && s != 0) {
Message obtainMessage = this.handler.obtainMessage();
obtainMessage.what = -1879048189;
obtainMessage.arg1 = i2 / 1000;
this.handler.sendMessage(obtainMessage);
}
}
@Override
public void callbackState(HiCamera hiCamera, int i, int i2, int i3) {
if (this.mCamera != hiCamera) {
return;
}
Message obtainMessage = this.handler.obtainMessage();
obtainMessage.what = i;
obtainMessage.arg1 = i2;
obtainMessage.arg2 = i3;
this.handler.sendMessage(obtainMessage);
}
public void NetworkError() {
showAlertnew(null, null, getString(R.string.disconnect), getString(R.string.finish), null, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (i == -2) {
PlaybackOnlineActivity.this.finish();
} else {
if (i != -1) {
return;
}
PlaybackOnlineActivity.this.finish();
}
}
});
}
public class ConnectionChangeReceiver extends BroadcastReceiver {
public ConnectionChangeReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(0);
NetworkInfo networkInfo2 = connectivityManager.getNetworkInfo(1);
if (networkInfo == null || networkInfo.isConnected() || networkInfo2 == null || networkInfo2.isConnected()) {
return;
}
MyToast.showToast(context, PlaybackOnlineActivity.this.getString(R.string.tips_wifi_connect_failed));
if (PlaybackOnlineActivity.this.mCamera != null) {
PlaybackOnlineActivity.this.mCamera.stopPlayback();
PlaybackOnlineActivity.this.mCamera.SetPlaybackSpeed(false, 0, PlaybackOnlineActivity.this.startTime, 0, 0);
}
PlaybackOnlineActivity.this.NetworkError();
}
}
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (view.getId() == R.id.monitor_playback_view) {
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.mMonitor.setTouchMove(0);
if (this.model == 0) {
}
} else if (action == 2 && this.mMonitor.getTouchMove() == 0 && (Math.abs(this.move_x - this.action_down_x) > 40.0f || Math.abs(this.move_y - this.action_down_y) > 40.0f)) {
this.mMonitor.setTouchMove(1);
}
}
}
}
return false;
}
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 * 2 && this.mMonitor.height <= this.mMonitor.screen_height * 2) {
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) {
MyPlaybackGLMonitor myPlaybackGLMonitor = this.mMonitor;
myPlaybackGLMonitor.bottom = myPlaybackGLMonitor.screen_height - this.mMonitor.height;
}
if (this.mMonitor.left + this.mMonitor.width < this.mMonitor.screen_width) {
MyPlaybackGLMonitor myPlaybackGLMonitor2 = this.mMonitor;
myPlaybackGLMonitor2.left = myPlaybackGLMonitor2.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);
}
MyPlaybackGLMonitor myPlaybackGLMonitor3 = this.mMonitor;
myPlaybackGLMonitor3.setMatrix(myPlaybackGLMonitor3.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.iv_adaption:
handPictureSize();
return;
case R.id.iv_snapshot:
if (this.isPlaying && System.currentTimeMillis() - this.lastClickTime > 500) {
this.lastClickTime = System.currentTimeMillis();
if (HiTools.HiPermission(this, this, 1, PERMISSION_REQUEST_CODE_STORAGE)) {
return;
}
clickSnapshot();
return;
}
return;
case R.id.iv_speed:
handFast();
return;
case R.id.monitor_playback_view:
LinearLayout linearLayout = this.mllPlay;
linearLayout.setVisibility(linearLayout.getVisibility() == 0 ? 8 : 0);
ImageView imageView = this.ivAdaption;
imageView.setVisibility(imageView.getVisibility() != 0 ? 0 : 8);
this.ivSnapshot.setVisibility(this.mllPlay.getVisibility());
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;
}
}
private void handPictureSize() {
View inflate = View.inflate(this, R.layout.pup_landscape_adaption, null);
this.mPopupWindow = new PopupWindow(inflate);
this.mPopupWindow.setBackgroundDrawable(new ColorDrawable(0));
this.mPopupWindow.setOutsideTouchable(true);
this.mPopupWindow.setHeight(-1);
this.mPopupWindow.setWidth(HiTools.dip2px(this, 250.0f));
this.mPopupWindow.setAnimationStyle(R.style.AnimTopRight);
this.mPopupWindow.showAtLocation(inflate, 17, getWindowManager().getDefaultDisplay().getWidth(), 0);
this.tvFill = (TextView) inflate.findViewById(R.id.tv_fill);
this.tvAdaption = (TextView) inflate.findViewById(R.id.tv_adaption);
int i = this.mPictureSize;
if (i == 0) {
this.tvFill.setSelected(true);
this.tvAdaption.setSelected(false);
} else if (i == 1) {
this.tvFill.setSelected(false);
this.tvAdaption.setSelected(true);
}
this.tvFill.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PlaybackOnlineActivity.this.tvFill.setSelected(true);
PlaybackOnlineActivity.this.tvAdaption.setSelected(false);
if (PlaybackOnlineActivity.this.mCamera != null) {
SharePreUtils.putInt(HiDataValue.CACHE, PlaybackOnlineActivity.this, "pictureSize" + HiDataValue.userAccount + PlaybackOnlineActivity.this.mCamera.getUid(), 0);
}
PlaybackOnlineActivity.this.mPictureSize = 0;
PlaybackOnlineActivity playbackOnlineActivity = PlaybackOnlineActivity.this;
playbackOnlineActivity.handLandScape(playbackOnlineActivity.mPictureSize);
}
});
this.tvAdaption.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
PlaybackOnlineActivity.this.tvFill.setSelected(false);
PlaybackOnlineActivity.this.tvAdaption.setSelected(true);
if (PlaybackOnlineActivity.this.mCamera != null) {
SharePreUtils.putInt(HiDataValue.CACHE, PlaybackOnlineActivity.this, "pictureSize" + HiDataValue.userAccount + PlaybackOnlineActivity.this.mCamera.getUid(), 1);
}
PlaybackOnlineActivity.this.mPictureSize = 1;
PlaybackOnlineActivity playbackOnlineActivity = PlaybackOnlineActivity.this;
playbackOnlineActivity.handLandScape(playbackOnlineActivity.mPictureSize);
}
});
}
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(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(PlaybackOnlineActivity.this.getContentResolver(), str, str2, (String) null);
} catch (Exception e) {
e.printStackTrace();
}
PlaybackOnlineActivity.this.sendBroadcast(new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE", Uri.parse("file://" + str)));
}
}).start();
}
private void handFast() {
if (this.mIsEnd) {
return;
}
int i = this.mSpeed;
if (i == 0) {
this.mSpeed = 2;
this.tvSpeed.setText("X 2");
MyCamera myCamera = this.mCamera;
int i2 = this.progressTime;
myCamera.SetPlaybackSpeed(true, i2, this.startTime, HiTools.HiCountTwoITime(i2), HiTools.HiCountFourITime(this.progressTime));
return;
}
if (i == 2) {
this.mSpeed = 4;
this.tvSpeed.setText("X 4");
this.mCamera.SetPlaybackSpeed(true, this.progressTime, this.startTime, 2, 6);
} else {
if (i != 4) {
return;
}
this.mSpeed = 0;
this.tvSpeed.setText("");
this.mCamera.SetPlaybackSpeed(false, this.progressTime, this.startTime, 0, 0);
}
}
public void handLandScape(int i) {
RelativeLayout.LayoutParams layoutParams;
this.hideUIMenu = hideBottomUIMenu();
this.mMonitor.setmIsFullScreen(1);
getWindow().setFlags(1024, 1024);
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
MyPlaybackGLMonitor myPlaybackGLMonitor = this.mMonitor;
int i2 = displayMetrics.heightPixels;
myPlaybackGLMonitor.screen_height = i2;
this.PictureRealHeight = i2;
MyPlaybackGLMonitor myPlaybackGLMonitor2 = this.mMonitor;
int i3 = displayMetrics.widthPixels;
myPlaybackGLMonitor2.screen_width = i3;
this.PictureRealWidth = i3;
if (HiTools.isAllScreenDevice(this)) {
layoutParams = new RelativeLayout.LayoutParams(-1, -1);
if (this.hideUIMenu) {
MyPlaybackGLMonitor myPlaybackGLMonitor3 = this.mMonitor;
int navigationBarHeight = displayMetrics.widthPixels + HiTools.getNavigationBarHeight(this);
myPlaybackGLMonitor3.screen_width = navigationBarHeight;
this.PictureRealWidth = navigationBarHeight;
}
} else {
layoutParams = new RelativeLayout.LayoutParams(getWindowManager().getDefaultDisplay().getWidth(), getWindowManager().getDefaultDisplay().getHeight());
}
if (i == 1) {
int Getwh = HiTools.Getwh(this.PictureRealWidth, this.PictureRealHeight, this.video_width, this.video_height);
if (Getwh == 2) {
this.mMonitor.screen_height = HiTools.getVideoshowh(this.PictureRealWidth, this.PictureRealHeight, this.video_width, this.video_height);
layoutParams.setMargins(0, (this.PictureRealHeight - this.mMonitor.screen_height) / 2, 0, (this.PictureRealHeight - this.mMonitor.screen_height) / 2);
} else if (Getwh == 3) {
this.mMonitor.screen_width = HiTools.getVideoshoww(this.PictureRealWidth, this.PictureRealHeight, this.video_width, this.video_height);
layoutParams.setMargins((this.PictureRealWidth - this.mMonitor.screen_width) / 2, 0, (this.PictureRealWidth - this.mMonitor.screen_width) / 2, 0);
} else {
layoutParams.setMargins(0, 0, 0, 0);
}
}
this.mMonitor.setLayoutParams(layoutParams);
initMatrix(this.mMonitor.screen_width, this.mMonitor.screen_height);
this.mMonitor.setState(0);
MyPlaybackGLMonitor myPlaybackGLMonitor4 = this.mMonitor;
myPlaybackGLMonitor4.setMatrix(myPlaybackGLMonitor4.left, this.mMonitor.bottom, this.mMonitor.width, this.mMonitor.height);
}
@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 (PlaybackOnlineActivity.this.isLarge == 1) {
PlaybackOnlineActivity playbackOnlineActivity = PlaybackOnlineActivity.this;
playbackOnlineActivity.resetMonitorSize(true, playbackOnlineActivity.nLenStart);
} else if (PlaybackOnlineActivity.this.isLarge == 2) {
PlaybackOnlineActivity playbackOnlineActivity2 = PlaybackOnlineActivity.this;
playbackOnlineActivity2.resetMonitorSize(false, playbackOnlineActivity2.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 (PlaybackOnlineActivity.this.isLarge == 1) {
PlaybackOnlineActivity playbackOnlineActivity = PlaybackOnlineActivity.this;
playbackOnlineActivity.resetMonitorSize(true, playbackOnlineActivity.nLenStart);
} else if (PlaybackOnlineActivity.this.isLarge == 2) {
PlaybackOnlineActivity playbackOnlineActivity2 = PlaybackOnlineActivity.this;
playbackOnlineActivity2.resetMonitorSize(false, playbackOnlineActivity2.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);
if (i == PERMISSION_REQUEST_CODE_STORAGE) {
int length = iArr.length;
boolean z = false;
int i2 = 0;
while (true) {
if (i2 >= length) {
z = true;
break;
} else if (iArr[i2] != 0) {
break;
} else {
i2++;
}
}
if (z) {
return;
}
HiTools.Hi_GoToSetting(strArr, this, this);
}
}
public void setDoPause(boolean z) {
this.isDoPause = z;
}
}