RemoteRecordingListActivity.java 源代码
package activity.video;
import activity.FishEye.FishPlaybackOnlineActivity;
import activity.LocalFile.LocalFileActivity2;
import activity.WallMounted.WallMountedOnlineActivity;
import activity.video.adapter.VideoOnlineListAdapter;
import android.animation.ObjectAnimator;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.drawable.ColorDrawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.design.widget.FloatingActionButton;
import android.text.Html;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.TextView;
import base.HiActivity;
import bean.MyCamera;
import com.hichip.callback.ICameraDownloadCallback;
import com.hichip.callback.ICameraIOSessionCallback;
import com.hichip.campro.R;
import com.hichip.content.HiChipDefines;
import com.hichip.control.HiCamera;
import com.xiaomi.mipush.sdk.Constants;
import common.ConstantCommand;
import common.HiDataValue;
import custom.CircleProgressBar;
import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import liteos.OSPlaybackFastOnlineDualActivity;
import org.apache.http.cookie.ClientCookie;
import utils.HiLogcatUtil;
import utils.HiTools;
import utils.MyToast;
import utils.SharePreUtils;
import utils.TimeUtil;
public class RemoteRecordingListActivity extends HiActivity implements AdapterView.OnItemClickListener, ICameraIOSessionCallback, ICameraDownloadCallback, View.OnClickListener {
public static final int HANDLE_MESSAGE_NETWORK_CHANGED = 1048577;
private static final int MY_PERMISSION_REQUEST_CODE = 10025;
public static final String SEARCH_ACTIVITY_END_TIME = "END TIME";
public static final int SEARCH_ACTIVITY_RESULT = 1;
public static final String SEARCH_ACTIVITY_START_TIME = "START TIME";
public static final String VIDEO_PLAYBACK_END_TIME = "VIDEO END TIME";
public static final String VIDEO_PLAYBACK_START_TIME = "VIDEO START TIME";
private static final SimpleDateFormat sdf = new SimpleDateFormat("00:mm:ss");
private VideoOnlineListAdapter adapter;
FloatingActionButton btn_floatingaction;
ImageView btn_return;
private CircleProgressBar circleprogressbar;
private long currentMills;
private PopupWindow downloadPopupWindow;
private String download_path;
private ConstantCommand.HI_P2P_FILE_INFO evt;
private String fileName;
private boolean isClickCancel;
private ImageView iv_arrow;
private View layoutView;
ListView list_video_online;
private MyCamera mCamera;
private ConnectionChangeReceiver myReceiver;
private String path;
private TextView popu_tips_down;
private HiChipDefines.HI_P2P_S_SD_INFO sd_info;
private TextView tv_cancel_downloading_video;
private TextView tv_goto_downloading_video;
TextView tv_not_online;
TextView tv_nothing;
private TextView tv_one;
private TextView tv_sort;
private TextView tv_two;
TextView tv_uid;
private View searchTimeView = null;
private View loadingView = null;
private List<ConstantCommand.HI_P2P_FILE_INFO> file_list = Collections.synchronizedList(new ArrayList());
private boolean isDownloading = false;
private int mType = 0;
private boolean mIsVisible = true;
private boolean mIsDataReceveEnd = false;
private boolean mIsDown = true;
private Handler handler = new Handler() {
@Override
public void handleMessage(Message message) {
String string;
switch (message.what) {
case HiDataValue.HANDLE_MESSAGE_SESSION_STATE:
if (message.arg1 != 0) {
return;
}
if (RemoteRecordingListActivity.this.isDownloading && !TextUtils.isEmpty(RemoteRecordingListActivity.this.path)) {
File file = new File(RemoteRecordingListActivity.this.path);
if (file.isFile() && file.exists()) {
file.delete();
}
}
RemoteRecordingListActivity.this.dismissjuHuaDialog();
if (RemoteRecordingListActivity.this.mIsVisible) {
RemoteRecordingListActivity remoteRecordingListActivity = RemoteRecordingListActivity.this;
MyToast.showToast(remoteRecordingListActivity, remoteRecordingListActivity.getString(R.string.disconnect));
RemoteRecordingListActivity.this.finish();
return;
}
return;
case HiDataValue.HANDLE_MESSAGE_RECEIVE_IOCTRL:
if (message.arg2 == -1) {
RemoteRecordingListActivity remoteRecordingListActivity2 = RemoteRecordingListActivity.this;
MyToast.showToast(remoteRecordingListActivity2, remoteRecordingListActivity2.getString(R.string.tips_update_system_failed));
RemoteRecordingListActivity.this.dismissLoadDialog();
return;
}
if (message.arg2 == 0) {
byte[] byteArray = message.getData().getByteArray("data");
int i = message.arg1;
if (i == 8193 || i == 16729) {
if (byteArray.length >= 12) {
byte b = byteArray[8];
byte b2 = byteArray[9];
if (b2 > 0) {
for (int i2 = 0; i2 < b2; i2++) {
byte[] bArr = new byte[24];
int sizeof = (HiChipDefines.HI_P2P_FILE_INFO.sizeof() * i2) + 12;
if (byteArray.length >= sizeof + 24) {
System.arraycopy(byteArray, sizeof, bArr, 0, 24);
ConstantCommand.HI_P2P_FILE_INFO hi_p2p_file_info = new ConstantCommand.HI_P2P_FILE_INFO(bArr);
long timeInMillis2 = hi_p2p_file_info.sEndTime.getTimeInMillis2() - hi_p2p_file_info.sStartTime.getTimeInMillis2();
if (timeInMillis2 <= 1500000 && timeInMillis2 > 0) {
hi_p2p_file_info.fileLength = RemoteRecordingListActivity.sdf.format(new Date(timeInMillis2 + 1));
RemoteRecordingListActivity.this.file_list.add(hi_p2p_file_info);
}
}
}
}
if (b == 1) {
RemoteRecordingListActivity.this.dismissjuHuaDialog();
RemoteRecordingListActivity.this.mIsDataReceveEnd = true;
RemoteRecordingListActivity.this.list_video_online.removeFooterView(RemoteRecordingListActivity.this.loadingView);
if (RemoteRecordingListActivity.this.file_list == null) {
return;
}
if (RemoteRecordingListActivity.this.file_list.size() <= 0) {
if (RemoteRecordingListActivity.this.mCamera.appGetCommandFunction(HiChipDefines.HI_P2P_GET_SD_INFO)) {
RemoteRecordingListActivity.this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_GET_SD_INFO, new byte[0]);
return;
}
return;
} else {
RemoteRecordingListActivity.this.btn_floatingaction.setVisibility(0);
Collections.reverse(RemoteRecordingListActivity.this.file_list);
RemoteRecordingListActivity.this.adapter.notifyDataSetChanged();
return;
}
}
return;
}
return;
}
if (i == 28946 && byteArray != null) {
RemoteRecordingListActivity.this.sd_info = new HiChipDefines.HI_P2P_S_SD_INFO(byteArray);
boolean z = RemoteRecordingListActivity.this.sd_info.u32Status == 1;
RemoteRecordingListActivity.this.list_video_online.removeHeaderView(RemoteRecordingListActivity.this.searchTimeView);
RemoteRecordingListActivity.this.list_video_online.setVisibility(8);
RemoteRecordingListActivity.this.tv_nothing.setVisibility(0);
if (z) {
RemoteRecordingListActivity.this.btn_floatingaction.setVisibility(0);
int i3 = RemoteRecordingListActivity.this.mType;
if (i3 == 0) {
string = "<font color='#45A7E6'>" + RemoteRecordingListActivity.this.getString(R.string.six_hours) + "</font><font color='#666666'/>" + RemoteRecordingListActivity.this.getString(R.string.click_right_corner) + "</font>";
} else if (i3 == 1) {
string = "<font color='#45A7E6'>" + RemoteRecordingListActivity.this.getString(R.string.one_hours) + "</font><font color='#666666'/>" + RemoteRecordingListActivity.this.getString(R.string.click_right_corner) + "</font>";
} else if (i3 == 2) {
string = "<font color='#45A7E6'>" + RemoteRecordingListActivity.this.getString(R.string.half_day) + "</font><font color='#666666'/>" + RemoteRecordingListActivity.this.getString(R.string.click_right_corner) + "</font>";
} else if (i3 == 3) {
string = "<font color='#45A7E6'>" + RemoteRecordingListActivity.this.getString(R.string.one_day) + "</font><font color='#666666'/>" + RemoteRecordingListActivity.this.getString(R.string.click_right_corner) + "</font>";
} else if (i3 == 4) {
string = "<font color='#45A7E6'>" + RemoteRecordingListActivity.this.getString(R.string.one_week) + "</font><font color='#666666'/>" + RemoteRecordingListActivity.this.getString(R.string.click_right_corner) + "</font>";
} else if (i3 != 5) {
string = "";
} else {
string = "<font color='#45A7E6'>" + RemoteRecordingListActivity.this.getString(R.string.constom_time) + "</font><font color='#666666'/>" + RemoteRecordingListActivity.this.getString(R.string.click_right_corner) + "</font>";
}
} else {
string = RemoteRecordingListActivity.this.getString(R.string.no_sdcard);
RemoteRecordingListActivity.this.btn_floatingaction.setVisibility(8);
}
RemoteRecordingListActivity.this.tv_nothing.setText(Html.fromHtml(string));
return;
}
return;
}
return;
case HiDataValue.HANDLE_MESSAGE_DOWNLOAD_STATE:
RemoteRecordingListActivity.this.handDownLoad(message);
return;
case 1048577:
RemoteRecordingListActivity.this.handNETWORK_CHANGED();
return;
default:
return;
}
}
};
@Override
public void callbackDownloadSnapData(HiCamera hiCamera, int i, byte[] bArr, int i2, int i3) {
}
@Override
protected int setLayoutId() {
return R.layout.activity_remote_recording_list;
}
@Override
protected void init(Bundle bundle) {
getIntentData();
if (HiTools.cameraWhetherNull(this.mCamera, this)) {
return;
}
initView();
setOnLiserners();
searchVideo();
}
private void getIntentData() {
String stringExtra = getIntent().getStringExtra(HiDataValue.EXTRAS_KEY_UID);
if (TextUtils.isEmpty(stringExtra)) {
return;
}
for (MyCamera myCamera : HiDataValue.CameraList) {
if (stringExtra.equals(myCamera.getUid())) {
this.mCamera = myCamera;
return;
}
}
}
private void setOnLiserners() {
this.btn_floatingaction.setOnClickListener(this);
this.btn_return.setOnClickListener(this);
this.tv_uid.setOnClickListener(this);
}
private void initView() {
this.tv_uid.setText(this.mCamera.getUid());
if (this.mCamera.getConnectState() != 4) {
this.list_video_online.setVisibility(8);
this.tv_not_online.setVisibility(0);
}
this.searchTimeView = getLayoutInflater().inflate(R.layout.search_event_result, (ViewGroup) null);
this.loadingView = getLayoutInflater().inflate(R.layout.loading_events, (ViewGroup) null);
((LinearLayout) this.searchTimeView.findViewById(R.id.ll_sort)).setOnClickListener(this);
this.tv_sort = (TextView) this.searchTimeView.findViewById(R.id.tv_sort);
this.iv_arrow = (ImageView) this.searchTimeView.findViewById(R.id.iv_arrow);
}
private void searchVideo() {
long beforeHourTime = getBeforeHourTime(6);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(TimeUtil.FORMAT_DATE_TIME_FULL);
this.list_video_online.addFooterView(this.loadingView);
if (this.list_video_online.getHeaderViewsCount() == 0) {
this.list_video_online.addHeaderView(this.searchTimeView);
}
this.adapter = new VideoOnlineListAdapter(this, this.file_list);
MyCamera myCamera = this.mCamera;
if (myCamera != null) {
myCamera.getConnectState();
}
this.list_video_online.setAdapter((ListAdapter) this.adapter);
this.list_video_online.setOnItemClickListener(this);
((TextView) this.searchTimeView.findViewById(R.id.txtSearchTimeDuration)).setText(simpleDateFormat.format(new Date(beforeHourTime)) + " - " + HiTools.sdfTimeSec(System.currentTimeMillis()));
MyCamera myCamera2 = this.mCamera;
if (myCamera2 != null) {
if (myCamera2.appGetCommandFunction(HiChipDefines.HI_P2P_PB_QUERY_START_NODST)) {
this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_PB_QUERY_START_NODST, HiChipDefines.HI_P2P_S_PB_LIST_REQ.parseContent(0, beforeHourTime, System.currentTimeMillis(), (byte) 0, 0));
return;
}
if (this.mCamera.appGetCommandFunction(HiChipDefines.HI_P2P_PB_QUERY_START_NEW)) {
this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_PB_QUERY_START_NEW, HiChipDefines.HI_P2P_S_PB_LIST_REQ.parseContent(0, beforeHourTime, System.currentTimeMillis(), (byte) 0, 1));
} else if (this.mCamera.appGetCommandFunction(HiChipDefines.HI_P2P_PB_QUERY_START_EXT)) {
this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_PB_QUERY_START_EXT, HiChipDefines.HI_P2P_S_PB_LIST_REQ.parseContent(0, beforeHourTime, System.currentTimeMillis(), (byte) 0, 1));
} else {
this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_PB_QUERY_START, HiChipDefines.HI_P2P_S_PB_LIST_REQ.parseContent(0, beforeHourTime, System.currentTimeMillis(), (byte) 0, 1));
}
}
}
public long getBeforeHourTime(int i) {
Calendar calendar = Calendar.getInstance();
calendar.set(11, calendar.get(11) - i);
return calendar.getTimeInMillis();
}
@Override
public void onResume() {
super.onResume();
registerCompent();
if (this.mCamera == null) {
finish();
}
}
@Override
public void onPause() {
PopupWindow popupWindow;
super.onPause();
unregisterCompent();
if (this.isDownloading && (popupWindow = this.downloadPopupWindow) != null && popupWindow.isShowing()) {
this.downloadPopupWindow.dismiss();
deleteLoadingFile();
}
}
@Override
public void onDestroy() {
super.onDestroy();
this.isDownloading = false;
Handler handler = this.handler;
if (handler != null) {
handler.removeCallbacksAndMessages(null);
}
dismissLoadDialog();
}
private void unregisterCompent() {
MyCamera myCamera = this.mCamera;
if (myCamera != null) {
myCamera.unregisterIOSessionListener(this);
}
ConnectionChangeReceiver connectionChangeReceiver = this.myReceiver;
if (connectionChangeReceiver != null) {
try {
unregisterReceiver(connectionChangeReceiver);
} catch (Exception unused) {
}
}
}
private void registerCompent() {
MyCamera myCamera = this.mCamera;
if (myCamera != null) {
myCamera.registerIOSessionListener(this);
this.mCamera.registerDownloadListener(this);
}
IntentFilter intentFilter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
ConnectionChangeReceiver connectionChangeReceiver = new ConnectionChangeReceiver();
this.myReceiver = connectionChangeReceiver;
registerReceiver(connectionChangeReceiver, intentFilter);
}
@Override
public void onClick(View view) {
int id = view.getId();
if (id == R.id.btn_floatingaction) {
if (System.currentTimeMillis() - this.currentMills < 500) {
return;
}
this.currentMills = System.currentTimeMillis();
if (!this.mIsDataReceveEnd) {
MyToast.showToast(this, getString(R.string.data_get_wait));
return;
}
Intent intent = new Intent(this, (Class<?>) SearchSDCardVideoActivity.class);
intent.putExtra(HiDataValue.EXTRAS_KEY_UID, this.mCamera.getUid());
startActivityForResult(intent, 1);
overridePendingTransition(R.anim.in_from_right, R.anim.out_to_left);
return;
}
if (id == R.id.btn_return) {
finish();
return;
}
if (id != R.id.ll_sort) {
return;
}
if (this.mIsDataReceveEnd) {
TextView textView = this.tv_sort;
if (textView == null || this.iv_arrow == null) {
return;
}
textView.setText(getString(this.mIsDown ? R.string.asce : R.string.desc));
this.iv_arrow.animate().rotation(this.mIsDown ? 180.0f : 0.0f).setDuration(400L).start();
Collections.reverse(this.file_list);
this.adapter.setClickItemPosition(-10);
this.adapter.notifyDataSetChanged();
this.mIsDown = !this.mIsDown;
return;
}
MyToast.showToast(this, getString(R.string.data_get_wait));
}
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() || !RemoteRecordingListActivity.this.isDownloading) {
return;
}
RemoteRecordingListActivity.this.handler.sendEmptyMessage(1048577);
}
}
@Override
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long j) {
if (System.currentTimeMillis() - this.currentMills < 500) {
return;
}
this.currentMills = System.currentTimeMillis();
int i2 = i - 1;
if (i2 >= 0) {
this.adapter.setClickItemPosition(i2);
this.adapter.notifyDataSetChanged();
}
if (HiTools.isCustomFastClick(1000)) {
return;
}
this.list_video_online.postDelayed(new Runnable() {
@Override
public final void run() {
RemoteRecordingListActivity.this.lambda$onItemClick$0$RemoteRecordingListActivity(i);
}
}, 150L);
}
public void lambda$onItemClick$0$RemoteRecordingListActivity(int i) {
final int headerViewsCount = i - this.list_video_online.getHeaderViewsCount();
if (headerViewsCount < 0) {
return;
}
View inflate = View.inflate(this, R.layout.popview_video_online, null);
final PopupWindow popupWindow = new PopupWindow(inflate);
popupWindow.setBackgroundDrawable(new ColorDrawable(0));
popupWindow.setWidth(-1);
popupWindow.setHeight(-1);
popupWindow.setFocusable(true);
popupWindow.showAtLocation(inflate, 17, 0, 0);
this.evt = this.file_list.get(headerViewsCount);
TextView textView = (TextView) inflate.findViewById(R.id.pup_vo_item_tv_state);
String[] stringArray = getResources().getStringArray(R.array.online_recording_type);
if (this.evt.EventType <= 3 && this.evt.EventType >= 0) {
textView.setText(stringArray[this.evt.EventType]);
}
TextView textView2 = (TextView) inflate.findViewById(R.id.pup_vo_item_tv_time);
String[] split = this.evt.sStartTime.toString().split(" ");
textView2.setText(split[0] + " " + split[1] + " - " + this.evt.sEndTime.toString().split(" ")[1]);
((TextView) inflate.findViewById(R.id.tv_play_video_online)).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
RemoteRecordingListActivity.this.lambda$popupMethod$2$RemoteRecordingListActivity(popupWindow, headerViewsCount, view);
}
});
((TextView) inflate.findViewById(R.id.tv_downlinad_video_online)).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
RemoteRecordingListActivity.this.lambda$popupMethod$3$RemoteRecordingListActivity(popupWindow, headerViewsCount, view);
}
});
((TextView) inflate.findViewById(R.id.tv_downlinad_video_cancel)).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
popupWindow.dismiss();
}
});
}
public void lambda$popupMethod$2$RemoteRecordingListActivity(PopupWindow popupWindow, final int i, View view) {
popupWindow.dismiss();
this.list_video_online.postDelayed(new Runnable() {
@Override
public final void run() {
RemoteRecordingListActivity.this.lambda$popupMethod$1$RemoteRecordingListActivity(i);
}
}, 100L);
}
public void lambda$popupMethod$3$RemoteRecordingListActivity(PopupWindow popupWindow, int i, View view) {
popupWindow.dismiss();
if (HiTools.HiPermission(this, this, 1, MY_PERMISSION_REQUEST_CODE)) {
return;
}
downloadRecording(i, this.evt);
}
public void lambda$popupMethod$1$RemoteRecordingListActivity(int i) {
if (this.mCamera == null) {
return;
}
ConstantCommand.HI_P2P_FILE_INFO hi_p2p_file_info = this.file_list.get(i);
Bundle bundle = new Bundle();
bundle.putString(HiDataValue.EXTRAS_KEY_UID, this.mCamera.getUid());
bundle.putByteArray("st", hi_p2p_file_info.sStartTime.parseContent());
bundle.putByteArray("end", hi_p2p_file_info.sEndTime.parseContent());
long timeInMillis2 = hi_p2p_file_info.sStartTime.getTimeInMillis2();
long timeInMillis22 = hi_p2p_file_info.sEndTime.getTimeInMillis2();
bundle.putLong("VIDEO START TIME", timeInMillis2);
bundle.putLong("VIDEO END TIME", timeInMillis22);
String[] split = hi_p2p_file_info.sEndTime.toString().split(" ");
String[] split2 = hi_p2p_file_info.sStartTime.toString().split(" ");
bundle.putString("title", split2[0] + " " + split2[1] + Constants.ACCEPT_TIME_SEPARATOR_SERVER + split[1]);
Intent intent = new Intent();
intent.putExtras(bundle);
if (this.mCamera.isWallMounted) {
intent.setClass(this, WallMountedOnlineActivity.class);
startActivity(intent);
return;
}
if (this.mCamera.isFishEye()) {
intent.setClass(this, FishPlaybackOnlineActivity.class);
} else if (!this.mCamera.getdevDual()) {
if (!this.mCamera.getdevSplice()) {
intent.setClass(this, PlaybackOnlineActivity.class);
} else {
intent.setClass(this, PlaybackOnlineSpliceActivity.class);
}
} else if (!this.mCamera.getIsLiteOs()) {
if (this.mCamera.getIs_ThreeEyes()) {
intent.setClass(this, PlaybackOnlineDualActivity_ThreeEyes.class);
} else {
intent.setClass(this, PlaybackOnlineDualActivity.class);
}
} else {
intent.setClass(this, OSPlaybackFastOnlineDualActivity.class);
}
startActivity(intent);
}
private void downloadRecording(int i, final ConstantCommand.HI_P2P_FILE_INFO hi_p2p_file_info) {
if (HiTools.isSDCardValid()) {
File file = new File(HiDataValue.getPathCameraVideoOnLineDownLoad(this.mCamera.getUid(), this));
if (!file.exists()) {
file.mkdirs();
}
this.download_path = file.getAbsoluteFile() + "/";
this.fileName = splitFileName(hi_p2p_file_info.sStartTime.toString());
File file2 = new File(this.download_path + this.fileName + ".avi");
File file3 = new File(this.download_path + this.fileName + ".mp4");
File file4 = new File(this.download_path + this.fileName + ".h264");
File file5 = new File(this.download_path + this.fileName + ".h265");
if (file2.exists() || file3.exists() || file4.exists() || file5.exists()) {
View inflate = View.inflate(this, R.layout.popuwindow_aleary_down, null);
final PopupWindow popupWindow = new PopupWindow(inflate);
popupWindow.setBackgroundDrawable(new ColorDrawable(0));
popupWindow.setFocusable(true);
popupWindow.setWidth(-1);
popupWindow.setHeight(-1);
popupWindow.showAtLocation(inflate, 17, 0, 0);
((TextView) inflate.findViewById(R.id.item_tv_know)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
popupWindow.dismiss();
}
});
return;
}
showLoadDialog(getString(R.string.tips_loading) + "...", false, false);
new Thread() {
@Override
public void run() {
RemoteRecordingListActivity.this.mCamera.startDownloadRecording2(hi_p2p_file_info.sStartTime, RemoteRecordingListActivity.this.download_path, RemoteRecordingListActivity.this.fileName, 2);
}
}.start();
return;
}
MyToast.showToast(this, getText(R.string.tips_no_sdcard).toString());
}
private String splitFileName(String str) {
long j;
try {
j = new SimpleDateFormat(TimeUtil.FORMAT_DATE_TIME_FULL).parse(str).getTime();
} catch (ParseException e) {
e.printStackTrace();
j = 0;
}
return new SimpleDateFormat(TimeUtil.FORMAT_DATE_TIME_NEW2).format(Long.valueOf(j));
}
@Override
public void receiveSessionState(HiCamera hiCamera, int i) {
Message obtainMessage = this.handler.obtainMessage();
obtainMessage.what = HiDataValue.HANDLE_MESSAGE_SESSION_STATE;
obtainMessage.arg1 = i;
obtainMessage.obj = hiCamera;
this.handler.sendMessage(obtainMessage);
}
@Override
public void receiveIOCtrlData(HiCamera hiCamera, int i, byte[] bArr, int i2) {
Bundle bundle = new Bundle();
bundle.putByteArray("data", bArr);
Message obtainMessage = this.handler.obtainMessage();
obtainMessage.what = HiDataValue.HANDLE_MESSAGE_RECEIVE_IOCTRL;
obtainMessage.obj = hiCamera;
obtainMessage.arg1 = i;
obtainMessage.arg2 = i2;
obtainMessage.setData(bundle);
this.handler.sendMessage(obtainMessage);
}
@Override
public void callbackDownloadState(HiCamera hiCamera, int i, int i2, int i3, String str) {
if (hiCamera != this.mCamera) {
return;
}
Bundle bundle = new Bundle();
bundle.putLong("total", i);
bundle.putLong("curSize", i2);
bundle.putString(ClientCookie.PATH_ATTR, str);
Message obtainMessage = this.handler.obtainMessage();
obtainMessage.what = HiDataValue.HANDLE_MESSAGE_DOWNLOAD_STATE;
obtainMessage.arg1 = i3;
obtainMessage.setData(bundle);
this.handler.sendMessage(obtainMessage);
}
public void handNETWORK_CHANGED() {
if (this.isDownloading) {
this.isDownloading = false;
MyCamera myCamera = this.mCamera;
if (myCamera != null) {
myCamera.stopDownloadRecording();
if (!TextUtils.isEmpty(this.path)) {
File file = new File(this.path);
if (file.isFile() && file.exists()) {
file.delete();
}
}
}
MyToast.showToast(this, getString(R.string.tips_network_disconnect));
}
}
public void handDownLoad(Message message) {
float f;
Bundle data = message.getData();
int i = message.arg1;
if (i == 0) {
dismissLoadDialog();
showPopPupProgress();
this.isDownloading = true;
this.path = data.getString(ClientCookie.PATH_ATTR);
return;
}
if (i == 1) {
if (this.isDownloading) {
long j = data.getLong("total");
if (j == 0) {
f = (float) ((data.getLong("curSize") * 100) / 1048576);
} else {
f = (float) ((data.getLong("curSize") * 100) / j);
}
if (f >= 100.0f) {
f = 99.0f;
}
int i2 = (int) f;
CircleProgressBar circleProgressBar = this.circleprogressbar;
if (circleProgressBar != null) {
circleProgressBar.setProgress(i2);
return;
}
return;
}
return;
}
if (i != 2) {
if (i == 3) {
MyToast.showToast(this, getString(R.string.tips_wifi_connect_failed));
dismissLoadDialog();
return;
}
if (i != 4) {
return;
}
MyCamera myCamera = this.mCamera;
if (myCamera != null && this.isDownloading) {
myCamera.stopDownloadRecording();
this.isDownloading = false;
this.mCamera.disconnect(1);
this.mCamera.connect();
if (!TextUtils.isEmpty(this.path)) {
File file = new File(this.path);
if (file.isFile() && file.exists()) {
file.delete();
}
}
}
dismissLoadDialog();
return;
}
ConstantCommand.HI_P2P_FILE_INFO hi_p2p_file_info = this.evt;
if (hi_p2p_file_info != null) {
SharePreUtils.putInt(HiDataValue.CACHE, this, this.fileName, hi_p2p_file_info.EventType);
}
CircleProgressBar circleProgressBar2 = this.circleprogressbar;
if (circleProgressBar2 != null) {
circleProgressBar2.setProgress(100);
}
this.isDownloading = false;
TextView textView = this.tv_cancel_downloading_video;
if (textView != null) {
textView.setText(R.string.continue_down);
}
TextView textView2 = this.tv_goto_downloading_video;
if (textView2 != null) {
textView2.setVisibility(0);
}
TextView textView3 = this.popu_tips_down;
if (textView3 != null) {
textView3.setText(getString(R.string.download_done));
}
CircleProgressBar circleProgressBar3 = this.circleprogressbar;
if (circleProgressBar3 != null) {
circleProgressBar3.setVisibility(8);
}
TextView textView4 = this.tv_one;
if (textView4 != null) {
textView4.setVisibility(0);
}
TextView textView5 = this.tv_two;
if (textView5 != null) {
textView5.setVisibility(0);
}
ObjectAnimator ofFloat = ObjectAnimator.ofFloat(this.tv_one, "Alpha", 0.0f, 1.0f);
ofFloat.setDuration(300L);
ofFloat.start();
ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(this.tv_two, "Alpha", 0.0f, 1.0f);
ofFloat2.setDuration(300L);
ofFloat2.start();
}
private void showPopPupProgress() {
View inflate = getLayoutInflater().inflate(R.layout.pup_loading_video, (ViewGroup) null, false);
this.downloadPopupWindow = new PopupWindow(inflate);
this.downloadPopupWindow.setBackgroundDrawable(new ColorDrawable(0));
this.downloadPopupWindow.setFocusable(true);
this.downloadPopupWindow.setWidth(-1);
this.downloadPopupWindow.setHeight(-1);
this.circleprogressbar = (CircleProgressBar) inflate.findViewById(R.id.circleprogressbar);
this.popu_tips_down = (TextView) inflate.findViewById(R.id.popu_tips_down);
this.tv_one = (TextView) inflate.findViewById(R.id.tv_one);
this.tv_two = (TextView) inflate.findViewById(R.id.tv_two);
if (isFinishing()) {
return;
}
this.downloadPopupWindow.showAtLocation(inflate, 17, 0, 0);
String[] stringArray = getResources().getStringArray(R.array.online_recording_type);
if (this.evt.EventType <= 3 && this.evt.EventType >= 0) {
this.popu_tips_down.setText(stringArray[this.evt.EventType]);
}
this.downloadPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
RemoteRecordingListActivity.this.isDownloading = false;
if (RemoteRecordingListActivity.this.mCamera != null) {
RemoteRecordingListActivity.this.mCamera.stopDownloadRecording();
}
if (!RemoteRecordingListActivity.this.isClickCancel && !RemoteRecordingListActivity.this.getString(R.string.continue_down).equals(RemoteRecordingListActivity.this.tv_cancel_downloading_video.getText().toString().trim())) {
RemoteRecordingListActivity.this.deleteLoadingFile();
}
RemoteRecordingListActivity.this.isClickCancel = false;
}
});
TextView textView = (TextView) inflate.findViewById(R.id.tv_cancel_downloading_video);
this.tv_cancel_downloading_video = textView;
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (RemoteRecordingListActivity.this.getString(R.string.continue_down).equals(RemoteRecordingListActivity.this.tv_cancel_downloading_video.getText().toString().trim())) {
RemoteRecordingListActivity.this.isClickCancel = true;
RemoteRecordingListActivity.this.downloadPopupWindow.dismiss();
} else {
RemoteRecordingListActivity.this.isClickCancel = true;
RemoteRecordingListActivity.this.downloadPopupWindow.dismiss();
RemoteRecordingListActivity.this.deleteLoadingFile();
}
}
});
TextView textView2 = (TextView) inflate.findViewById(R.id.tv_goto_downloading_video);
this.tv_goto_downloading_video = textView2;
textView2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
RemoteRecordingListActivity.this.isClickCancel = true;
RemoteRecordingListActivity.this.downloadPopupWindow.dismiss();
Intent intent = new Intent(RemoteRecordingListActivity.this, (Class<?>) LocalFileActivity2.class);
intent.putExtra(HiDataValue.EXTRAS_KEY_UID, RemoteRecordingListActivity.this.mCamera.getUid());
RemoteRecordingListActivity.this.startActivity(intent);
}
});
}
public void deleteLoadingFile() {
new File(this.path).delete();
}
@Override
public void onActivityResult(int i, int i2, Intent intent) {
super.onActivityResult(i, i2, intent);
if (i2 == -1) {
this.tv_sort.setText(getString(R.string.desc));
this.mIsDown = true;
this.iv_arrow.animate().rotation(0.0f).setDuration(0L).start();
Bundle bundleExtra = intent.getBundleExtra("data");
long j = bundleExtra.getLong("START TIME");
long j2 = bundleExtra.getLong("END TIME");
this.mType = intent.getIntExtra("type", 5);
this.file_list.clear();
this.adapter.setClickItemPosition(-10);
this.adapter.notifyDataSetChanged();
MyCamera myCamera = this.mCamera;
if (myCamera != null) {
this.mIsDataReceveEnd = false;
if (myCamera.appGetCommandFunction(HiChipDefines.HI_P2P_PB_QUERY_START_NODST)) {
this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_PB_QUERY_START_NODST, HiChipDefines.HI_P2P_S_PB_LIST_REQ.parseContent(0, j, j2, (byte) 0, 0));
} else if (this.mCamera.appGetCommandFunction(HiChipDefines.HI_P2P_PB_QUERY_START_NEW)) {
this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_PB_QUERY_START_NEW, HiChipDefines.HI_P2P_S_PB_LIST_REQ.parseContent(0, j, j2, (byte) 0, 1));
} else if (this.mCamera.appGetCommandFunction(HiChipDefines.HI_P2P_PB_QUERY_START_EXT)) {
this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_PB_QUERY_START_EXT, HiChipDefines.HI_P2P_S_PB_LIST_REQ.parseContent(0, j, j2, (byte) 0, 1));
} else {
this.mCamera.sendIOCtrl(HiChipDefines.HI_P2P_PB_QUERY_START, HiChipDefines.HI_P2P_S_PB_LIST_REQ.parseContent(0, j, j2, (byte) 0, 1));
}
}
this.list_video_online.setVisibility(0);
this.tv_nothing.setVisibility(8);
if (this.list_video_online.getHeaderViewsCount() == 0) {
this.list_video_online.addHeaderView(this.searchTimeView);
}
if (this.list_video_online.getFooterViewsCount() == 0) {
this.list_video_online.addFooterView(this.loadingView);
}
((TextView) this.searchTimeView.findViewById(R.id.txtSearchTimeDuration)).setText(HiTools.sdfTimeSec(j) + " - " + HiTools.sdfTimeSec(j2));
this.mCamera.registerIOSessionListener(this);
}
}
@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;
}
HiTools.Hi_GoToSetting(strArr, this, this);
}
}
}