OSAlarmLogFragment.java 源代码
package liteos;
import activity.ImagePagerActivity;
import activity.LocalFile.LocalFileActivity2;
import activity.video.PlaybackOnlineActivity;
import android.animation.ObjectAnimator;
import android.app.ActionBar;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import base.HiFragment;
import bean.MyCamera;
import butterknife.ButterKnife;
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.hichip.tools.Packet;
import com.meizu.cloud.pushsdk.constants.PushConstants;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
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.List;
import java.util.Locale;
import java.util.Objects;
import liteos.adapter.AlarmLogAdapter;
import liteos.adapter.NormalDecoration;
import org.apache.http.cookie.ClientCookie;
import org.greenrobot.eventbus.EventBus;
import timeaxis.bean.MsyIsStop;
import utils.HiLogcatUtil;
import utils.HiTools;
import utils.MyToast;
import utils.SharePreUtils;
import utils.TimeUtil;
public class OSAlarmLogFragment extends HiFragment implements ICameraIOSessionCallback, AlarmLogAdapter.OnItemClickListener, AlarmLogAdapter.OnItemLongClickListener, ICameraDownloadCallback {
public static final int MY_PERMISSION_REQUEST_CODE = 10026;
private static final String newAddress = "http://iot.juzi1688.cn/dist/#/info?iccid=";
private static final String oldAddress = "http://m2m.zweitx.com/dist/#/info?iccid=";
private static final String oldAddressID = "&userId=1476846140417773568";
private CircleProgressBar circleprogressbar;
private long currentMills;
private NormalDecoration decoration;
private PopupWindow downloadPopupWindow;
private String download_path;
private ConstantCommand.HI_P2P_LOG_INFO evt;
private String fileName;
private View headView;
private boolean isClickCancel;
private boolean isDownloading;
private boolean isRefreshOrLoading;
private String logType;
private Activity mAct;
private AlarmLogAdapter mAdapter;
private String mHead;
private boolean mIsVisibleToUser;
private MyCamera mMyCamera;
private boolean not_hint;
private String path;
private TextView pop_tips_down;
RecyclerView recycler_view;
SmartRefreshLayout refreshLayout;
RelativeLayout rl_nothing;
private int sNextDate;
private TextView tv_cancel_downloading_video;
private TextView tv_goto_downloading_video;
private TextView tv_one;
private TextView tv_two;
private boolean mIsShowing = false;
private List<ConstantCommand.HI_P2P_LOG_INFO> mListLogInfos = new ArrayList();
private String flag = "";
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message message) {
int i = message.what;
if (i == -1879048191) {
OSAlarmLogFragment.this.handSessionState(message);
return;
}
if (i != -1879048189) {
if (i != -1879048185) {
return;
}
OSAlarmLogFragment.this.handDownLoad(message);
} else if (message.arg2 == 0) {
OSAlarmLogFragment.this.handIOCTRLSuccess(message);
} else {
OSAlarmLogFragment.this.handIOCTRLFail(message);
}
}
};
private List<String> mListTime = new ArrayList();
private List<String> mAllListTime = new ArrayList();
private List<ConstantCommand.HI_P2P_LOG_INFO> refreshData = new ArrayList();
private SimpleDateFormat sdf = new SimpleDateFormat(TimeUtil.FORMAT_STRING, Locale.getDefault());
@Override
public void callbackDownloadSnapData(HiCamera hiCamera, int i, byte[] bArr, int i2, int i3) {
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
this.mAct = (Activity) context;
}
@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
View inflate = layoutInflater.inflate(R.layout.fragment_os_alarm_log, (ViewGroup) null);
ButterKnife.bind(this, inflate);
getIntentData();
initView();
setListeners();
return inflate;
}
private void setListeners() {
this.mAdapter.setOnItemClickListener(this);
this.mAdapter.setOnItemLongClickListener(this);
this.refreshLayout.setOnRefreshListener(new OnRefreshListener() {
@Override
public final void onRefresh(RefreshLayout refreshLayout) {
OSAlarmLogFragment.this.lambda$setListeners$0$OSAlarmLogFragment(refreshLayout);
}
});
this.refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
@Override
public final void onLoadMore(RefreshLayout refreshLayout) {
OSAlarmLogFragment.this.lambda$setListeners$1$OSAlarmLogFragment(refreshLayout);
}
});
}
public void lambda$setListeners$0$OSAlarmLogFragment(RefreshLayout refreshLayout) {
this.isRefreshOrLoading = true;
requestRefresh();
}
public void lambda$setListeners$1$OSAlarmLogFragment(RefreshLayout refreshLayout) {
this.isRefreshOrLoading = true;
HiChipDefines.STimeDay sTimeDay = new HiChipDefines.STimeDay(new byte[0], 0);
HiChipDefines.STimeDay sTimeDay2 = new HiChipDefines.STimeDay(new byte[0], 0);
List<ConstantCommand.HI_P2P_LOG_INFO> list = this.mListLogInfos;
if (list != null && list.size() > 0) {
List<ConstantCommand.HI_P2P_LOG_INFO> list2 = this.mListLogInfos;
HiChipDefines.STimeDay sTimeDay3 = new HiChipDefines.STimeDay(list2.get(list2.size() - 1).sStartTime, 0);
sTimeDay2.year = sTimeDay3.year;
sTimeDay2.month = sTimeDay3.month;
sTimeDay2.day = sTimeDay3.day;
sTimeDay2.hour = sTimeDay3.hour;
sTimeDay2.minute = sTimeDay3.minute;
sTimeDay2.second = sTimeDay3.second;
sTimeDay2.wday = sTimeDay3.wday;
}
this.flag = "loadMore";
MyCamera myCamera = this.mMyCamera;
int i = this.sNextDate;
List<ConstantCommand.HI_P2P_LOG_INFO> list3 = this.mListLogInfos;
myCamera.sendIOCtrl(ConstantCommand.HI_P2P_LOG_QUERY, ConstantCommand.HI_P2P_S_LOG_LIST_REQ.parseContent(sTimeDay, sTimeDay2, 50, 0, 0, i, list3.get(list3.size() - 1).index, 2));
}
private void initView() {
NormalDecoration normalDecoration = new NormalDecoration() {
@Override
public String getHeaderName(int i) {
return (OSAlarmLogFragment.this.mListLogInfos == null || OSAlarmLogFragment.this.mListLogInfos.size() <= i) ? " " : ((ConstantCommand.HI_P2P_LOG_INFO) OSAlarmLogFragment.this.mListLogInfos.get(i)).getmHeaderName();
}
};
this.decoration = normalDecoration;
normalDecoration.setOnDecorationHeadDraw(new NormalDecoration.OnDecorationHeadDraw() {
@Override
public View getHeaderView(int i) {
String headerName = OSAlarmLogFragment.this.decoration.getHeaderName(i);
if (!headerName.equals(OSAlarmLogFragment.this.mHead)) {
OSAlarmLogFragment oSAlarmLogFragment = OSAlarmLogFragment.this;
oSAlarmLogFragment.headView = LayoutInflater.from(oSAlarmLogFragment.getContext()).inflate(R.layout.decoration_head_view, (ViewGroup) null);
OSAlarmLogFragment.this.mHead = headerName;
}
TextView textView = (TextView) OSAlarmLogFragment.this.headView.findViewById(R.id.tv_header_md);
TextView textView2 = (TextView) OSAlarmLogFragment.this.headView.findViewById(R.id.tv_header_y);
String[] split = headerName.split(Constants.ACCEPT_TIME_SEPARATOR_SERVER);
if (split.length > 2) {
textView.setText(split[1] + "." + split[2]);
textView2.setText(split[0]);
}
return OSAlarmLogFragment.this.headView;
}
});
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
this.recycler_view.addItemDecoration(this.decoration);
this.recycler_view.setLayoutManager(linearLayoutManager);
this.recycler_view.setHasFixedSize(true);
AlarmLogAdapter alarmLogAdapter = new AlarmLogAdapter(getContext(), this.mListLogInfos);
this.mAdapter = alarmLogAdapter;
this.recycler_view.setAdapter(alarmLogAdapter);
}
private void getIntentData() {
String string = getArguments().getString(HiDataValue.EXTRAS_KEY_UID);
if (TextUtils.isEmpty(string)) {
return;
}
for (MyCamera myCamera : HiDataValue.CameraList) {
if (string.equals(myCamera.getUid())) {
this.mMyCamera = myCamera;
return;
}
}
}
@Override
public void onResume() {
super.onResume();
MyCamera myCamera = this.mMyCamera;
if (myCamera != null) {
myCamera.registerIOSessionListener(this);
}
}
@Override
public void onPause() {
PopupWindow popupWindow;
super.onPause();
MyCamera myCamera = this.mMyCamera;
if (myCamera != null) {
myCamera.unregisterIOSessionListener(this);
}
Handler handler = this.mHandler;
if (handler != null) {
handler.removeCallbacksAndMessages(null);
}
if (this.isDownloading && (popupWindow = this.downloadPopupWindow) != null && popupWindow.isShowing()) {
this.downloadPopupWindow.dismiss();
deleteLoadingFile();
}
}
@Override
public void setUserVisibleHint(boolean z) {
super.setUserVisibleHint(z);
this.mIsVisibleToUser = z;
if (z) {
this.mMyCamera.registerDownloadListener(this);
this.mIsShowing = true;
if (this.flag.equals("")) {
requestLogData();
return;
}
return;
}
MyCamera myCamera = this.mMyCamera;
if (myCamera != null) {
myCamera.unregisterDownloadListener(this);
}
this.mIsShowing = false;
}
private void requestLogData() {
if (this.mMyCamera != null) {
HiChipDefines.STimeDay sTimeDay = new HiChipDefines.STimeDay(new byte[0], 0);
HiChipDefines.STimeDay sTimeDay2 = new HiChipDefines.STimeDay(new byte[0], 0);
Calendar calendar = Calendar.getInstance();
sTimeDay2.year = (short) calendar.get(1);
sTimeDay2.month = (byte) (calendar.get(2) + 1);
sTimeDay2.day = (byte) calendar.get(5);
sTimeDay2.hour = (byte) calendar.get(11);
sTimeDay2.minute = (byte) calendar.get(12);
sTimeDay2.second = (byte) calendar.get(13);
sTimeDay2.wday = (byte) calendar.get(7);
String str = calendar.get(1) + "";
String str2 = (calendar.get(2) + 1) + "";
String str3 = calendar.get(5) + "";
if (str2.length() == 1) {
str2 = PushConstants.PUSH_TYPE_NOTIFY + str2;
}
if (str3.length() == 1) {
str3 = PushConstants.PUSH_TYPE_NOTIFY + str3;
}
int parseInt = Integer.parseInt(str + str2 + str3);
List<ConstantCommand.HI_P2P_LOG_INFO> list = this.mListLogInfos;
if (list != null) {
list.clear();
}
List<String> list2 = this.mListTime;
if (list2 != null) {
list2.clear();
}
List<String> list3 = this.mAllListTime;
if (list3 != null) {
list3.clear();
}
showLoadDialog(getString(R.string.tips_loading), false, false);
this.flag = "firstIn";
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_LOG_QUERY, ConstantCommand.HI_P2P_S_LOG_LIST_REQ.parseContent(sTimeDay, sTimeDay2, 30, 0, 0, parseInt, 65535, 1));
}
}
private void requestRefresh() {
HiChipDefines.STimeDay sTimeDay = new HiChipDefines.STimeDay(new byte[0], 0);
List<ConstantCommand.HI_P2P_LOG_INFO> list = this.mListLogInfos;
if (list != null && list.size() > 0) {
HiChipDefines.STimeDay sTimeDay2 = new HiChipDefines.STimeDay(this.mListLogInfos.get(0).sStartTime, 0);
sTimeDay.year = sTimeDay2.year;
sTimeDay.month = sTimeDay2.month;
sTimeDay.day = sTimeDay2.day;
sTimeDay.hour = sTimeDay2.hour;
sTimeDay.minute = sTimeDay2.minute;
sTimeDay.second = sTimeDay2.second;
sTimeDay.wday = sTimeDay2.wday;
HiChipDefines.STimeDay sTimeDay3 = new HiChipDefines.STimeDay(new byte[0], 0);
Calendar calendar = Calendar.getInstance();
sTimeDay3.year = (short) calendar.get(1);
sTimeDay3.month = (byte) (calendar.get(2) + 1);
sTimeDay3.day = (byte) calendar.get(5);
sTimeDay3.hour = (byte) calendar.get(11);
sTimeDay3.minute = (byte) calendar.get(12);
sTimeDay3.second = (byte) calendar.get(13);
sTimeDay3.wday = (byte) calendar.get(7);
calendar.get(1);
String str = (calendar.get(2) + 1) + "";
String str2 = calendar.get(5) + "";
str.length();
str2.length();
String[] split = new HiChipDefines.STimeDay(this.mListLogInfos.get(0).sStartTime, 0).toString().split(" ")[0].split(Constants.ACCEPT_TIME_SEPARATOR_SERVER);
this.flag = "refresh";
this.mMyCamera.sendIOCtrl(ConstantCommand.HI_P2P_LOG_QUERY, ConstantCommand.HI_P2P_S_LOG_LIST_REQ.parseContent(sTimeDay, sTimeDay3, 30, 0, 0, Integer.parseInt(split[0] + split[1] + split[2]), this.mListLogInfos.get(0).index, 1));
return;
}
requestLogData();
}
@Override
public void receiveSessionState(HiCamera hiCamera, int i) {
Message obtainMessage = this.mHandler.obtainMessage();
obtainMessage.what = HiDataValue.HANDLE_MESSAGE_SESSION_STATE;
obtainMessage.arg1 = i;
obtainMessage.obj = hiCamera;
this.mHandler.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.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);
}
public void handDownLoad(Message message) {
float f;
Bundle data = message.getData();
int i = message.arg1;
if (i == -3) {
HiLogcatUtil.e("###### os log DOWNLOAD_ONLINE_STATE_ERROR #########");
MyCamera myCamera = this.mMyCamera;
if (myCamera != null) {
myCamera.stopDownloadRecording();
this.mMyCamera.setReconnectTimes(10);
}
if (getActivity() != null) {
Toast.makeText(getActivity(), getString(R.string.play_4k_sd_error), 1).show();
}
dismissLoadDialog();
Activity activity2 = this.mAct;
if (activity2 != null) {
activity2.finish();
return;
}
return;
}
if (i == 0) {
if (isAdded()) {
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.mAct, getString(R.string.tips_wifi_connect_failed));
dismissLoadDialog();
return;
}
if (i != 4) {
return;
}
MyCamera myCamera2 = this.mMyCamera;
if (myCamera2 != null && this.isDownloading) {
myCamera2.stopDownloadRecording();
this.isDownloading = false;
this.mMyCamera.disconnect(1);
if (!TextUtils.isEmpty(this.path)) {
File file = new File(this.path);
if (file.isFile() && file.exists()) {
file.delete();
}
}
}
dismissLoadDialog();
return;
}
if (this.evt != null) {
SharePreUtils.putInt(HiDataValue.CACHE, this.mAct, this.fileName, 2);
}
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);
}
if (this.pop_tips_down != null && isAdded()) {
this.pop_tips_down.setText(getString(R.string.download_done));
}
CircleProgressBar circleProgressBar3 = this.circleprogressbar;
if (circleProgressBar3 != null) {
circleProgressBar3.setVisibility(8);
}
TextView textView3 = this.tv_one;
if (textView3 != null) {
textView3.setVisibility(0);
}
TextView textView4 = this.tv_two;
if (textView4 != null) {
textView4.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() {
if (this.mAct != null && this.mIsVisibleToUser) {
HiLogcatUtil.dTag(HiLogcatUtil.TAG_Google, "showPopPupProgress");
View inflate = LayoutInflater.from(this.mAct).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.pop_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 (this.mAct.isFinishing()) {
return;
}
this.downloadPopupWindow.showAtLocation(inflate, 17, 0, 0);
getResources().getStringArray(R.array.online_recording_type);
if (this.evt == null) {
return;
}
this.pop_tips_down.setText(this.logType);
this.downloadPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
OSAlarmLogFragment.this.isDownloading = false;
if (OSAlarmLogFragment.this.mMyCamera != null) {
OSAlarmLogFragment.this.mMyCamera.stopDownloadRecording();
}
if (!OSAlarmLogFragment.this.isClickCancel && !OSAlarmLogFragment.this.getString(R.string.continue_down).equals(OSAlarmLogFragment.this.tv_cancel_downloading_video.getText().toString().trim())) {
OSAlarmLogFragment.this.deleteLoadingFile();
}
OSAlarmLogFragment.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 (OSAlarmLogFragment.this.getString(R.string.continue_down).equals(OSAlarmLogFragment.this.tv_cancel_downloading_video.getText().toString().trim())) {
OSAlarmLogFragment.this.isClickCancel = true;
OSAlarmLogFragment.this.downloadPopupWindow.dismiss();
} else {
OSAlarmLogFragment.this.downloadPopupWindow.dismiss();
OSAlarmLogFragment.this.isClickCancel = true;
OSAlarmLogFragment.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) {
OSAlarmLogFragment.this.isClickCancel = true;
OSAlarmLogFragment.this.downloadPopupWindow.dismiss();
if (!OSAlarmLogFragment.this.mMyCamera.getdevDual()) {
OSAlarmLogFragment.this.mMyCamera.stopPlaybackNew();
} else {
OSAlarmLogFragment.this.mMyCamera.stopPlaybackFast(true);
OSAlarmLogFragment.this.mMyCamera.isFirstPlayOsDual = true;
}
EventBus.getDefault().post(new MsyIsStop(true));
Intent intent = new Intent(OSAlarmLogFragment.this.mAct, (Class<?>) LocalFileActivity2.class);
intent.putExtra(HiDataValue.EXTRAS_KEY_UID, OSAlarmLogFragment.this.mMyCamera.getUid());
OSAlarmLogFragment.this.startActivity(intent);
}
});
}
}
public void deleteLoadingFile() {
new File(this.path).delete();
}
public void handSessionState(Message message) {
if (message.arg1 == 0 && this.mAct != null && this.mIsShowing) {
if (!this.mMyCamera.misshowgoRecharge && this.mMyCamera.mPreICCIDRecharge == 2) {
showgoRechargeHint(this.mMyCamera);
} else {
MyToast.showToast(this.mAct, getString(R.string.disconnect));
this.mAct.finish();
}
}
}
public void handIOCTRLFail(Message message) {
if (message.arg1 == 18460) {
dismissLoadDialog();
this.refreshLayout.finishRefresh();
this.refreshLayout.finishLoadMore();
MyToast.showToast(getContext(), getString(R.string.netword_abnormal));
return;
}
MyToast.showToast(this.mAct, getString(R.string.tips_update_system_failed));
dismissLoadDialog();
}
public void handIOCTRLSuccess(Message message) {
byte[] byteArray = message.getData().getByteArray("data");
if (message.arg1 != 18460) {
return;
}
ConstantCommand.HI_P2P_S_LOG_LIST_RESP hi_p2p_s_log_list_resp = new ConstantCommand.HI_P2P_S_LOG_LIST_RESP(byteArray);
this.sNextDate = hi_p2p_s_log_list_resp.sNextDate;
for (int i = 0; i < hi_p2p_s_log_list_resp.count; i++) {
byte[] bArr = new byte[56];
int i2 = (i * 56) + 24;
if (byteArray.length - i2 >= 56) {
System.arraycopy(byteArray, i2, bArr, 0, 56);
ConstantCommand.HI_P2P_LOG_INFO hi_p2p_log_info = new ConstantCommand.HI_P2P_LOG_INFO(bArr);
HiChipDefines.STimeDay sTimeDay = new HiChipDefines.STimeDay(hi_p2p_log_info.sStartTime, 0);
String str = sTimeDay.toString().split(" ")[0];
hi_p2p_log_info.setmHeaderName(str);
if (!this.mListTime.contains(str)) {
this.mListTime.add(str);
hi_p2p_log_info.isFirstTime = true;
}
if (this.flag.equals("refresh")) {
this.refreshData.add(0, hi_p2p_log_info);
} else {
this.mListLogInfos.add(hi_p2p_log_info);
}
this.mAllListTime.add(sTimeDay.toString());
}
}
if (hi_p2p_s_log_list_resp.endflag == 1) {
dismissLoadDialog();
List<ConstantCommand.HI_P2P_LOG_INFO> list = this.mListLogInfos;
if (list == null) {
return;
}
if (list.size() < 1) {
this.rl_nothing.setVisibility(0);
this.refreshLayout.setVisibility(8);
return;
}
if (this.flag.equals("refresh") && this.refreshData.size() > 0) {
for (int i3 = 0; i3 < this.refreshData.size(); i3++) {
this.mListLogInfos.add(0, this.refreshData.get(i3));
}
}
this.refreshData.clear();
this.mListTime.clear();
for (ConstantCommand.HI_P2P_LOG_INFO hi_p2p_log_info2 : this.mListLogInfos) {
String str2 = new HiChipDefines.STimeDay(hi_p2p_log_info2.sStartTime, 0).toString().split(" ")[0];
if (!this.mListTime.contains(str2)) {
this.mListTime.add(str2);
hi_p2p_log_info2.isFirstTime = true;
} else {
hi_p2p_log_info2.isFirstTime = false;
}
}
this.refreshLayout.finishRefresh();
this.refreshLayout.finishLoadMore();
if (this.flag.equals("loadMore") && hi_p2p_s_log_list_resp.count == 0) {
Toast.makeText(getActivity(), getString(R.string.no_more_log), 1).show();
}
this.isRefreshOrLoading = false;
if (this.flag.equals("refresh")) {
this.mHead = null;
this.headView = null;
this.decoration.reSet();
}
this.mAdapter.notifyDataSetChanged();
}
}
@Override
public void onItemClick(View view, int i) {
long j;
String longToString;
if (this.isRefreshOrLoading) {
return;
}
ConstantCommand.HI_P2P_LOG_INFO hi_p2p_log_info = this.mListLogInfos.get(i);
String string = Packet.getString(hi_p2p_log_info.sRecFileName);
if (TextUtils.isEmpty(string)) {
return;
}
Bundle bundle = new Bundle();
if (!TextUtils.isEmpty(string)) {
String[] split = string.substring(2, string.length()).split("_");
if (split.length > 2) {
String str = split[0] + split[1];
String str2 = split[0] + split[2].split("\\.")[0];
long j2 = 0;
try {
j = this.sdf.parse(str).getTime();
} catch (ParseException e) {
e = e;
j = 0;
}
try {
j2 = this.sdf.parse(str2).getTime();
} catch (ParseException e2) {
e = e2;
e.printStackTrace();
bundle.putLong("VIDEO START TIME", j);
bundle.putLong("VIDEO END TIME", j2);
longToString = TimeUtil.longToString(j2, TimeUtil.FORMAT_DATE_TIME_SPLIT);
if (longToString.contains(Constants.ACCEPT_TIME_SEPARATOR_SERVER)) {
}
if (i >= 0) {
}
if (this.mMyCamera.getdevDual()) {
}
EventBus.getDefault().post(new MsyIsStop(true));
Intent intent = new Intent();
if (this.mMyCamera.getdevDual()) {
}
bundle.putString(ImagePagerActivity.FILENAME, string);
bundle.putString(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
bundle.putByteArray("st", hi_p2p_log_info.sStartTime);
intent.putExtras(bundle);
startActivity(intent);
}
bundle.putLong("VIDEO START TIME", j);
bundle.putLong("VIDEO END TIME", j2);
longToString = TimeUtil.longToString(j2, TimeUtil.FORMAT_DATE_TIME_SPLIT);
if (longToString.contains(Constants.ACCEPT_TIME_SEPARATOR_SERVER)) {
String[] split2 = longToString.split(Constants.ACCEPT_TIME_SEPARATOR_SERVER);
if (split2.length > 0) {
byte[] bArr = new byte[8];
System.arraycopy(Packet.shortToByteArray_Little(Short.parseShort(split2[0])), 0, bArr, 0, 2);
if (split2.length > 1) {
bArr[2] = Byte.parseByte(split2[1]);
}
if (split2.length > 2) {
bArr[3] = Byte.parseByte(split2[2]);
}
if (split2.length > 3) {
bArr[4] = Byte.parseByte(split2[3]);
}
if (split2.length > 4) {
bArr[5] = Byte.parseByte(split2[4]);
}
if (split2.length > 5) {
bArr[6] = Byte.parseByte(split2[5]);
}
bArr[7] = Byte.parseByte(PushConstants.PUSH_TYPE_NOTIFY);
bundle.putByteArray("end", bArr);
}
}
}
}
if (i >= 0) {
this.mAdapter.setClickItemPosition(i);
this.mAdapter.notifyDataSetChanged();
}
if (this.mMyCamera.getdevDual()) {
this.mMyCamera.stopPlaybackNew();
} else {
this.mMyCamera.stopPlaybackFast(true);
this.mMyCamera.isFirstPlayOsDual = true;
}
EventBus.getDefault().post(new MsyIsStop(true));
Intent intent2 = new Intent();
if (this.mMyCamera.getdevDual()) {
intent2.setClass(getContext(), PlaybackOnlineActivity.class);
} else {
intent2.setClass(getContext(), OSPlaybackFastOnlineDualActivity.class);
}
bundle.putString(ImagePagerActivity.FILENAME, string);
bundle.putString(HiDataValue.EXTRAS_KEY_UID, this.mMyCamera.getUid());
bundle.putByteArray("st", hi_p2p_log_info.sStartTime);
intent2.putExtras(bundle);
startActivity(intent2);
}
@Override
public void onItemLongClick(View view, final int i) {
if (System.currentTimeMillis() - this.currentMills < 500) {
return;
}
this.currentMills = System.currentTimeMillis();
if (TextUtils.isEmpty(Packet.getString(this.mListLogInfos.get(i).sRecFileName))) {
return;
}
if (i >= 0) {
this.mAdapter.setClickItemPosition(i);
this.mAdapter.notifyDataSetChanged();
}
if (HiTools.isCustomFastClick(1000)) {
return;
}
this.mHandler.postDelayed(new Runnable() {
@Override
public final void run() {
OSAlarmLogFragment.this.lambda$onItemLongClick$2$OSAlarmLogFragment(i);
}
}, 150L);
}
public void lambda$onItemLongClick$2$OSAlarmLogFragment(final int i) {
Activity activity2 = this.mAct;
if (activity2 == null) {
return;
}
View inflate = View.inflate(activity2, 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);
ConstantCommand.HI_P2P_LOG_INFO hi_p2p_log_info = this.mListLogInfos.get(i);
this.evt = hi_p2p_log_info;
this.logType = handLogDescribe(hi_p2p_log_info);
String sTimeDay = new HiChipDefines.STimeDay(this.evt.sStartTime, 0).toString();
TextView textView = (TextView) inflate.findViewById(R.id.tv_play_video_online);
TextView textView2 = (TextView) inflate.findViewById(R.id.pup_vo_item_tv_state);
TextView textView3 = (TextView) inflate.findViewById(R.id.pup_vo_item_tv_time);
textView.setVisibility(8);
textView2.setText(this.logType);
textView3.setText(sTimeDay);
((TextView) inflate.findViewById(R.id.tv_downlinad_video_online)).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
OSAlarmLogFragment.this.lambda$popupMethod$3$OSAlarmLogFragment(popupWindow, i, 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$3$OSAlarmLogFragment(PopupWindow popupWindow, int i, View view) {
popupWindow.dismiss();
if (this.mAct == null || HiTools.HiPermission(getActivity(), getActivity(), 1, MY_PERMISSION_REQUEST_CODE)) {
return;
}
downloadRecording(i);
}
private void downloadRecording(int i) {
ConstantCommand.HI_P2P_LOG_INFO hi_p2p_log_info = this.mListLogInfos.get(i);
if (HiTools.isSDCardValid()) {
File file = new File(HiDataValue.getPathCameraVideoOnLineDownLoad(this.mMyCamera.getUid(), this.mAct));
if (!file.exists()) {
file.mkdirs();
}
this.download_path = file.getAbsoluteFile() + "/";
final HiChipDefines.STimeDay sTimeDay = new HiChipDefines.STimeDay(hi_p2p_log_info.sStartTime, 0);
this.fileName = splitFileName(sTimeDay.toString());
HiLogcatUtil.dTag(HiLogcatUtil.TAG_Google, "fileName: " + this.fileName);
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.mAct, 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);
if (!this.mMyCamera.getdevDual()) {
this.mMyCamera.stopPlaybackNew();
} else {
this.mMyCamera.stopPlaybackFast(true);
this.mMyCamera.isFirstPlayOsDual = true;
}
new Thread() {
@Override
public void run() {
OSAlarmLogFragment.this.mMyCamera.startDownloadRecording2(sTimeDay, OSAlarmLogFragment.this.download_path, OSAlarmLogFragment.this.fileName, 2);
}
}.start();
EventBus.getDefault().post(new MsyIsStop(true));
return;
}
Toast.makeText(this.mAct, getText(R.string.tips_no_sdcard).toString(), 0).show();
}
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));
}
private String handLogDescribe(ConstantCommand.HI_P2P_LOG_INFO hi_p2p_log_info) {
if (getContext() == null) {
return "";
}
String[] stringArray = getContext().getResources().getStringArray(R.array.liteos_logValue);
int i = hi_p2p_log_info.logVlaue;
if (i == 2) {
return stringArray[1];
}
if (i == 3) {
return stringArray[2];
}
if (i == 4) {
return stringArray[3];
}
if (i == 5) {
return stringArray[4];
}
switch (i) {
case 49:
return stringArray[5];
case 50:
return stringArray[6];
case 51:
return stringArray[19];
default:
switch (i) {
case 97:
return stringArray[7];
case 98:
return stringArray[8];
case 99:
return stringArray[9];
case 100:
return stringArray[10];
case 101:
return stringArray[11];
case 102:
return stringArray[12];
case 103:
return stringArray[16];
case 104:
return stringArray[17];
case 105:
return stringArray[18];
default:
switch (i) {
case 129:
return stringArray[13];
case 130:
return stringArray[14];
case 131:
return stringArray[15];
default:
return stringArray[0];
}
}
}
}
@Override
public void callbackDownloadState(HiCamera hiCamera, int i, int i2, int i3, String str) {
if (hiCamera != this.mMyCamera) {
return;
}
Bundle bundle = new Bundle();
bundle.putLong("total", i);
bundle.putLong("curSize", i2);
bundle.putString(ClientCookie.PATH_ATTR, str);
Message obtainMessage = this.mHandler.obtainMessage();
obtainMessage.what = HiDataValue.HANDLE_MESSAGE_DOWNLOAD_STATE;
obtainMessage.arg1 = i3;
obtainMessage.setData(bundle);
this.mHandler.sendMessage(obtainMessage);
}
private void showgoRechargeHint(final MyCamera myCamera) {
if (myCamera.misshowgoRecharge) {
return;
}
this.not_hint = false;
final Dialog dialog = new Dialog(this.mAct, R.style.CustomDialog);
dialog.setCancelable(false);
View inflate = View.inflate(this.mAct, R.layout.dialog_recharge_hint, null);
TextView textView = (TextView) inflate.findViewById(R.id.rechage_tit);
final ImageView imageView = (ImageView) inflate.findViewById(R.id.iv);
TextView textView2 = (TextView) inflate.findViewById(R.id.rechage_name);
TextView textView3 = (TextView) inflate.findViewById(R.id.rechage_uid);
if (myCamera.mPreICCIDRecharge == 2) {
textView.setText(getString(R.string.recharge_hint_meg1));
}
textView2.setText(myCamera.getNikeName());
textView3.setText(myCamera.getUid());
inflate.findViewById(R.id.ll_not_hint_again).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
OSAlarmLogFragment.this.lambda$showgoRechargeHint$5$OSAlarmLogFragment(imageView, myCamera, view);
}
});
inflate.findViewById(R.id.tv_know).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
OSAlarmLogFragment.this.lambda$showgoRechargeHint$6$OSAlarmLogFragment(myCamera, dialog, view);
}
});
inflate.findViewById(R.id.tv_gorecharge).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
OSAlarmLogFragment.this.lambda$showgoRechargeHint$7$OSAlarmLogFragment(myCamera, dialog, view);
}
});
dialog.addContentView(inflate, new ActionBar.LayoutParams(-1, -2));
Window window = dialog.getWindow();
Objects.requireNonNull(window);
WindowManager.LayoutParams attributes = window.getAttributes();
attributes.width = (int) (getResources().getDisplayMetrics().widthPixels * 0.85d);
dialog.getWindow().setAttributes(attributes);
dialog.show();
}
public void lambda$showgoRechargeHint$5$OSAlarmLogFragment(ImageView imageView, MyCamera myCamera, View view) {
if (this.not_hint) {
this.not_hint = false;
imageView.setImageResource(R.mipmap.checkboc_unselect);
myCamera.setPreICCIDRecharge(1);
} else {
this.not_hint = true;
imageView.setImageResource(R.mipmap.checkbox_select);
myCamera.setPreICCIDRecharge(0);
}
}
public void lambda$showgoRechargeHint$6$OSAlarmLogFragment(MyCamera myCamera, Dialog dialog, View view) {
myCamera.misshowgoRecharge = true;
dialog.dismiss();
this.mAct.finish();
}
public void lambda$showgoRechargeHint$7$OSAlarmLogFragment(MyCamera myCamera, Dialog dialog, View view) {
Uri parse;
myCamera.misshowgoRecharge = true;
dialog.dismiss();
if (!TextUtils.isEmpty(myCamera.getICCID())) {
if (myCamera.getPreICCIDType() == 1) {
parse = Uri.parse(newAddress + myCamera.getICCID());
} else if (myCamera.getPreICCIDType() == 2 || myCamera.getPreICCIDType() == 3) {
parse = Uri.parse("https://www.wxkjwlw.com/wechat/cardDetail/" + myCamera.getICCID() + "?platformId=" + myCamera.getPreICCIDOperator() + "&gzhConfigId=77");
} else {
parse = Uri.parse(oldAddress + myCamera.getICCID() + oldAddressID);
}
startActivity(new Intent("android.intent.action.VIEW", parse));
}
this.mAct.finish();
}
@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 == 10026) {
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, getActivity(), getActivity());
}
}
}