NVRRecordingListActivity.java 源代码
package main.NVR.Video;
import activity.LocalFile.LocalFileActivity2;
import activity.video.SearchSDCardVideoActivity;
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.support.v4.view.ViewPager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
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.chad.library.adapter.base.BaseQuickAdapter;
import com.hichip.NVR.HiNVRDev;
import com.hichip.NVR.callback.INVRPlayStateCallback;
import com.hichip.NVR.callback.PlayLocalNVRFileCallback;
import com.hichip.NVR.content.HiChipNVRDefines;
import com.hichip.base.HiLog;
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.xiaomi.mipush.sdk.Constants;
import common.ConstantCommand;
import common.HiDataValue;
import custom.CircleProgressBar;
import custom.NoSlidingViewPager;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
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.Iterator;
import java.util.List;
import main.MainActivity;
import main.NVR.adapter.ChoosePupChannelListAdapter;
import org.apache.http.cookie.ClientCookie;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import timeaxis.bean.MsyIsStop;
import timeaxis.calender.MsgCalenderDay;
import timeaxis.calender.MyLinearLayout;
import timeaxis.calender.MyPagerAdapter;
import timeaxis.calender.TitleGridAdapter;
import utils.HiLogcatUtil;
import utils.HiTools;
import utils.MyToast;
import utils.SharePreUtils;
import utils.TimeUtil;
public class NVRRecordingListActivity extends HiActivity implements AdapterView.OnItemClickListener, ICameraIOSessionCallback, INVRPlayStateCallback, PlayLocalNVRFileCallback, 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";
public static int mMonth;
public static int mYear;
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 HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE evt;
private String fileName;
private boolean isCalenderChangedMonth;
private boolean isClickCancel;
private ImageView iv_arrow;
ImageView iv_choose_data;
ImageView iv_left;
ImageView iv_right;
private View layoutView;
ListView list_video_online;
private ChoosePupChannelListAdapter mAdapter;
private MyCamera mCamera;
private String mDownLoadPath;
HiChipNVRDefines.PLATFORM_S_MONTHPLAYBACKFILE_REP mMonthfile;
private ConnectionChangeReceiver myReceiver;
private MyPagerAdapter pagerAdapter;
private String path;
private TextView popu_tips_down;
MyLinearLayout rl_calendar;
private HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE savefile_infos;
private HiChipDefines.HI_P2P_S_SD_INFO sd_info;
LinearLayout stc_calendar_layout;
private GridView title_gView;
private TextView tv_cancel_downloading_video;
TextView tv_changechn;
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;
TextView tv_years_month;
NoSlidingViewPager viewpager;
private View searchTimeView = null;
private View loadingView = null;
private List<HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE> file_list = Collections.synchronizedList(new ArrayList());
private boolean isDownloading = false;
private int mType = 0;
private boolean mIsVisible = true;
private boolean mIsDataReceveEnd = false;
private boolean nvrsinglechn = false;
public int chn = 0;
private int currPager = 999;
private int perPager = 999;
private Calendar calStartDate = Calendar.getInstance();
String mstrdate = "";
String mstr2date = "";
private String saveStrdate = "";
private String curSelectMonth = "";
int mgetvideotype = 254;
int StreamType = 0;
private boolean isFirstEnter = true;
private List<String> mList = new ArrayList();
private boolean isChangeMonth = false;
private boolean mIsDown = true;
private boolean isCallDown = false;
private List<Integer> allHaveVideoDayList = new ArrayList();
private List<Integer> alreadyGetVideoDay = new ArrayList();
private int mSelectPosition = -1;
private Handler handler = new Handler() {
@Override
public void handleMessage(Message message) {
String str;
long j;
char c;
String str2;
int i = 0;
int i2 = 1;
switch (message.what) {
case HiDataValue.HANDLE_MESSAGE_SESSION_STATE:
if (message.arg1 != 0) {
return;
}
if (NVRRecordingListActivity.this.isDownloading && !TextUtils.isEmpty(NVRRecordingListActivity.this.path)) {
File file = new File(NVRRecordingListActivity.this.path);
if (file.isFile() && file.exists()) {
file.delete();
}
}
NVRRecordingListActivity.this.dismissjuHuaDialog();
if (NVRRecordingListActivity.this.mIsVisible) {
NVRRecordingListActivity nVRRecordingListActivity = NVRRecordingListActivity.this;
MyToast.showToast(nVRRecordingListActivity, nVRRecordingListActivity.getString(R.string.disconnect));
NVRRecordingListActivity.this.finish();
return;
}
return;
case HiDataValue.HANDLE_MESSAGE_RECEIVE_IOCTRL:
if (message.arg2 == 0) {
byte[] byteArray = message.getData().getByteArray("data");
int i3 = message.arg1;
if (i3 == 268435496) {
if (NVRRecordingListActivity.this.mCamera != null && byteArray.length > 4) {
byte b = byteArray[0];
HiLogcatUtil.e("HI_NVR_P2P_PLATFORM_GET_ONLINEDEVICE" + byteArray.length + "::::::::" + ((int) b));
NVRRecordingListActivity.this.mCamera.mIsDiskStatus = b;
if (b != 5) {
if (NVRRecordingListActivity.this.mCamera.mIsDiskStatus != 3) {
NVRRecordingListActivity.this.handler.sendEmptyMessageDelayed(ConstantCommand.HI_P2P_SET_DEVICE_WORKING_MODE, 1000L);
}
} else {
NVRRecordingListActivity.this.startActivity(new Intent(NVRRecordingListActivity.this, (Class<?>) MainActivity.class), true);
}
}
} else {
switch (i3) {
case HiChipNVRDefines.HI_NVR_P2P_PLATFORM_GET_PLAYBACKFILE:
HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE_LIST_REP platform_s_playbackfile_list_rep = new HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE_LIST_REP(byteArray);
StringBuilder sb = new StringBuilder();
sb.append(NVRRecordingListActivity.this.mCamera.getUid());
sb.append("HI_NVR_P2P_PLATFORM_GET_PLAYBACKFILE");
sb.append(platform_s_playbackfile_list_rep.total);
String str3 = "::";
sb.append("::");
sb.append(platform_s_playbackfile_list_rep.index);
sb.append("::");
sb.append(platform_s_playbackfile_list_rep.endflag);
sb.append("::");
sb.append(platform_s_playbackfile_list_rep.count);
sb.append("::");
sb.append(byteArray.length);
HiLogcatUtil.e(sb.toString());
if (platform_s_playbackfile_list_rep.endflag == 2) {
int i4 = 44;
byte[] bArr = new byte[8];
byte[] bArr2 = new byte[8];
byte[] bArr3 = new byte[44];
int i5 = 0;
while (i5 < platform_s_playbackfile_list_rep.count) {
int i6 = (i5 * 44) + 12;
if (byteArray.length >= i6 + 44) {
System.arraycopy(byteArray, i6, bArr3, i, i4);
HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE platform_s_playbackfile = new HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE(bArr3);
String[] strArr = new String[i2];
strArr[0] = NVRRecordingListActivity.this.mCamera.getUid() + "PLATFORM_GET_PLAYBACKFILE:" + platform_s_playbackfile.eAlarmType + ":u32StartTime:" + platform_s_playbackfile.u32StartTime + str3 + platform_s_playbackfile.u32StopTime + str3 + platform_s_playbackfile.u32StartTimefile + str3 + platform_s_playbackfile.u32StopTimefile + ":sFilePath:" + Packet.getString(platform_s_playbackfile.sFilePath) + ":u16Width:" + platform_s_playbackfile.u16Width[i] + str3 + platform_s_playbackfile.u16Width[1] + ":u16Height:" + platform_s_playbackfile.u16Height[i] + str3 + platform_s_playbackfile.u16Height[1] + ":u32StartPts:" + platform_s_playbackfile.u32StartPts[i] + str3 + platform_s_playbackfile.u32StartPts[1] + ":u32StopPts:" + platform_s_playbackfile.u32StopPts[0] + str3 + platform_s_playbackfile.u32StopPts[1] + str3 + platform_s_playbackfile.u8AFormat + ":u8StreamCode:" + ((int) platform_s_playbackfile.u8StreamCode[0]) + str3 + ((int) platform_s_playbackfile.u8StreamCode[1]);
HiLogcatUtil.e(strArr);
str = str3;
NVRRecordingListActivity.this.higetSTimeDay(platform_s_playbackfile.u32StartTime, platform_s_playbackfile.u32StopTime, bArr, bArr2);
long timeInMillis = new HiChipDefines.STimeDay(bArr2, 0).getTimeInMillis() - new HiChipDefines.STimeDay(bArr, 0).getTimeInMillis();
j = 0;
if (timeInMillis <= 2000000 && timeInMillis > 0) {
NVRRecordingListActivity.this.file_list.add(platform_s_playbackfile);
}
} else {
str = str3;
j = 0;
}
i5++;
i = 0;
i2 = 1;
i4 = 44;
str3 = str;
}
break;
} else if (platform_s_playbackfile_list_rep.endflag == 3) {
NVRRecordingListActivity.this.ShowNothing(2);
break;
}
break;
case HiChipNVRDefines.HI_NVR_P2P_PLATFORM_PLAYBACKFILE:
if (byteArray.length >= 8 && Packet.byteArrayToInt_Little(byteArray, 4) == 1) {
NVRRecordingListActivity.this.mSaveFristsec = 0L;
NVRRecordingListActivity.this.mCamera.mhiNvrdev.StopSingleLiveViewThread();
NVRRecordingListActivity.this.mCamera.mhiNvrdev.StartSingleLiveViewThread();
break;
}
break;
case HiChipNVRDefines.HI_NVR_P2P_PLATFORM_GET_MONTHPLAYBACKFILE:
if (NVRRecordingListActivity.this.file_list == null || NVRRecordingListActivity.this.adapter == null) {
NVRRecordingListActivity.this.ShowNothing(1);
return;
}
NVRRecordingListActivity.this.mMonthfile = new HiChipNVRDefines.PLATFORM_S_MONTHPLAYBACKFILE_REP(byteArray);
HiLogcatUtil.e(NVRRecordingListActivity.this.mCamera.getUid() + "HI_NVR_P2P_PLATFORM_GET_MONTHPLAYBACKFILE" + NVRRecordingListActivity.this.mMonthfile.szDay + Packet.getString(NVRRecordingListActivity.this.mMonthfile.szDay));
int i7 = 0;
while (true) {
if (i7 >= 32) {
c = 0;
} else if (NVRRecordingListActivity.this.mMonthfile.szDay[i7] == 1) {
c = 1;
} else {
i7++;
}
}
int i8 = -10;
if (c < 1) {
if (NVRRecordingListActivity.this.isFirstEnter) {
NVRRecordingListActivity.this.isFirstEnter = false;
HiLog.e("MsgCalenderDay:");
EventBus.getDefault().post(new MsgCalenderDay(NVRRecordingListActivity.this.allHaveVideoDayList, NVRRecordingListActivity.this.alreadyGetVideoDay, NVRRecordingListActivity.this.mSelectPosition, NVRRecordingListActivity.this.currPager));
NVRRecordingListActivity nVRRecordingListActivity2 = NVRRecordingListActivity.this;
MyToast.showToast(nVRRecordingListActivity2, nVRRecordingListActivity2.getString(R.string.current_moth_novideo));
NVRRecordingListActivity.this.ShowNothing(1);
return;
}
if (NVRRecordingListActivity.this.isModifyChn) {
NVRRecordingListActivity.this.isModifyChn = false;
HiLog.e("MsgCalenderDay:");
EventBus.getDefault().post(new MsgCalenderDay(NVRRecordingListActivity.this.allHaveVideoDayList, NVRRecordingListActivity.this.alreadyGetVideoDay, NVRRecordingListActivity.this.mSelectPosition, NVRRecordingListActivity.this.currPager));
NVRRecordingListActivity nVRRecordingListActivity3 = NVRRecordingListActivity.this;
MyToast.showToast(nVRRecordingListActivity3, nVRRecordingListActivity3.getString(R.string.current_moth_novideo));
NVRRecordingListActivity.this.ShowNothing(1);
return;
}
NVRRecordingListActivity.this.adapter.setClickItemPosition(-10);
NVRRecordingListActivity.this.adapter.notifyDataSetChanged();
return;
}
Calendar.getInstance().get(5);
NVRRecordingListActivity.this.allHaveVideoDayList.clear();
int i9 = 31;
while (i9 > -1) {
if (NVRRecordingListActivity.this.mMonthfile.szDay[i9] == 1 && (NVRRecordingListActivity.this.isFirstEnter || NVRRecordingListActivity.this.isModifyChn)) {
if (NVRRecordingListActivity.this.file_list == null || NVRRecordingListActivity.this.adapter == null) {
return;
}
NVRRecordingListActivity.this.file_list.clear();
NVRRecordingListActivity.this.adapter.SetList(NVRRecordingListActivity.this.file_list);
NVRRecordingListActivity.this.adapter.setClickItemPosition(i8);
NVRRecordingListActivity.this.btn_return.setEnabled(false);
HiLogcatUtil.e("--我去请求当天录像文件了 返回键禁掉--");
NVRRecordingListActivity.this.mIsDataReceveEnd = false;
String str4 = NVRRecordingListActivity.this.mstrdate;
if (i9 < 10) {
NVRRecordingListActivity.this.mstrdate = str4 + PushConstants.PUSH_TYPE_NOTIFY + i9;
} else {
NVRRecordingListActivity.this.mstrdate = str4 + i9;
}
if (NVRRecordingListActivity.this.mstr2date.length() > 8) {
NVRRecordingListActivity nVRRecordingListActivity4 = NVRRecordingListActivity.this;
nVRRecordingListActivity4.mstr2date = nVRRecordingListActivity4.mstr2date.substring(0, 7);
}
NVRRecordingListActivity.this.curSelectMonth = str4;
int i10 = i9 + 1;
if (i10 < 10) {
str2 = str4 + PushConstants.PUSH_TYPE_NOTIFY + i10;
if (NVRRecordingListActivity.this.mstr2date.length() < 8) {
NVRRecordingListActivity.this.mstr2date = NVRRecordingListActivity.this.mstr2date + "-0" + i10;
}
} else {
str2 = str4 + i10;
if (NVRRecordingListActivity.this.mstr2date.length() < 8) {
NVRRecordingListActivity.this.mstr2date = NVRRecordingListActivity.this.mstr2date + Constants.ACCEPT_TIME_SEPARATOR_SERVER + i10;
}
}
NVRRecordingListActivity nVRRecordingListActivity5 = NVRRecordingListActivity.this;
nVRRecordingListActivity5.mstrdate = str2;
nVRRecordingListActivity5.saveStrdate = str2;
if (NVRRecordingListActivity.this.adapter != null) {
NVRRecordingListActivity.this.adapter.Setdate(NVRRecordingListActivity.this.mstr2date);
}
((TextView) NVRRecordingListActivity.this.searchTimeView.findViewById(R.id.txtSearchTimeDuration)).setText(str2);
HiLogcatUtil.e("--sendIOCtrl(HiChipDefines.HI_NVR_P2P_PLATFORM_GET_PLAYBACKFILE 2222--:" + str2 + "::::" + NVRRecordingListActivity.this.mstrdate + ":::::" + NVRRecordingListActivity.this.mstr2date);
NVRRecordingListActivity.this.mCamera.sendIOCtrl(HiChipNVRDefines.HI_NVR_P2P_PLATFORM_GET_PLAYBACKFILE, HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE_LIST_REQ.parseContent(NVRRecordingListActivity.this.chn, NVRRecordingListActivity.this.mgetvideotype, str2.getBytes()));
if (NVRRecordingListActivity.this.isFirstEnter) {
NVRRecordingListActivity.this.isFirstEnter = false;
}
if (NVRRecordingListActivity.this.isModifyChn) {
NVRRecordingListActivity.this.isModifyChn = false;
}
}
if (NVRRecordingListActivity.this.mMonthfile.szDay[i9] == 1) {
NVRRecordingListActivity.this.allHaveVideoDayList.add(Integer.valueOf(i9 + 1));
}
i9--;
i8 = -10;
}
Collections.reverse(NVRRecordingListActivity.this.allHaveVideoDayList);
Iterator it = NVRRecordingListActivity.this.allHaveVideoDayList.iterator();
while (it.hasNext()) {
HiLogcatUtil.e("tedu", "--当月有录像的天数--:" + ((Integer) it.next()).intValue());
}
HiLog.e("MsgCalenderDay:");
if (NVRRecordingListActivity.this.isChangeMonth) {
EventBus.getDefault().post(new MsgCalenderDay(NVRRecordingListActivity.this.allHaveVideoDayList, NVRRecordingListActivity.this.alreadyGetVideoDay, -2, NVRRecordingListActivity.this.currPager));
} else {
EventBus.getDefault().post(new MsgCalenderDay(NVRRecordingListActivity.this.allHaveVideoDayList, NVRRecordingListActivity.this.alreadyGetVideoDay, NVRRecordingListActivity.this.mSelectPosition, NVRRecordingListActivity.this.currPager));
}
HiLog.e("-11-被观察者发出通知---allHaveVideoDayList-:" + NVRRecordingListActivity.this.allHaveVideoDayList.size() + "-alreadyGetVideoDay-:" + NVRRecordingListActivity.this.alreadyGetVideoDay.size() + "-mSelectPosition-:" + NVRRecordingListActivity.this.mSelectPosition + "-currPager-:" + NVRRecordingListActivity.this.currPager);
break;
break;
}
}
}
if (message.arg2 == -1) {
NVRRecordingListActivity.this.rl_calendar.setVisibility(8);
NVRRecordingListActivity.this.btn_return.setEnabled(true);
int i11 = message.arg1;
if (i11 == 268435469) {
NVRRecordingListActivity.this.ShowNothing(0);
} else if (i11 == 268435471) {
NVRRecordingListActivity.this.ShowNothing(1);
}
NVRRecordingListActivity.this.dismissLoadDialog();
return;
}
return;
case HiDataValue.HANDLE_MESSAGE_DOWNLOAD_STATE:
NVRRecordingListActivity.this.handDownLoad(message);
return;
case ConstantCommand.HI_P2P_SET_DEVICE_WORKING_MODE:
NVRRecordingListActivity.this.dismissjuHuaDialog();
NVRRecordingListActivity.this.dismissLoadDialog();
HiDataValue.isNeedkillNoMain = false;
NVRRecordingListActivity.this.startActivity(new Intent(NVRRecordingListActivity.this, (Class<?>) MainActivity.class), true);
return;
case 1048577:
NVRRecordingListActivity.this.handNETWORK_CHANGED();
return;
default:
return;
}
}
};
private long mSaveFristsec = 0;
private int total = 0;
private boolean isModifyChn = false;
public static void lambda$showChooseNVRChnType$5() {
}
@Override
public void callbackPlayUTC(HiNVRDev hiNVRDev, int i, int i2) {
}
@Override
public void callbackRecordState(HiNVRDev hiNVRDev, int i, int i2, int i3, int i4, String str) {
}
@Override
public void callbackState(HiNVRDev hiNVRDev, int i, int i2, int i3, int i4) {
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void getIsStop(MsyIsStop msyIsStop) {
}
@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;
}
HiLog.e("tedG--....onResume()....--");
EventBus.getDefault().register(this);
initView();
initViewPager();
setOnLiserners();
searchVideo();
this.iv_choose_data.setVisibility(0);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2);
layoutParams.height = HiTools.dip2px(this, 0.0f);
this.rl_calendar.setLayoutParams(layoutParams);
this.rl_calendar.setVisibility(4);
this.btn_return.setEnabled(false);
this.iv_choose_data.setEnabled(false);
this.tv_changechn.setEnabled(false);
}
@Subscribe(threadMode = ThreadMode.MAIN)
private void getIntentData() {
String stringExtra = getIntent().getStringExtra(HiDataValue.EXTRAS_KEY_UID);
this.chn = getIntent().getIntExtra("nvrposition", -1);
this.nvrsinglechn = getIntent().getBooleanExtra("nvrsinglechn", false);
if (TextUtils.isEmpty(stringExtra)) {
return;
}
Iterator<MyCamera> it = HiDataValue.CameraList.iterator();
while (true) {
if (!it.hasNext()) {
break;
}
MyCamera next = it.next();
if (stringExtra.equals(next.getUid())) {
this.mCamera = next;
break;
}
}
MyCamera myCamera = this.mCamera;
if (myCamera == null || !myCamera.getIsDevNVR() || this.nvrsinglechn) {
return;
}
this.tv_changechn.setText(getString(R.string.nvrchn) + "1");
}
private void setOnLiserners() {
this.btn_floatingaction.setOnClickListener(this);
this.btn_return.setOnClickListener(this);
this.tv_uid.setOnClickListener(this);
this.iv_choose_data.setOnClickListener(this);
this.iv_left.setOnClickListener(this);
this.iv_right.setOnClickListener(this);
this.tv_changechn.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);
if (this.nvrsinglechn) {
this.tv_changechn.setVisibility(8);
} else {
this.tv_changechn.setVisibility(0);
}
}
private void searchVideo() {
Calendar calendar = Calendar.getInstance();
mYear = calendar.get(1);
mMonth = calendar.get(2) + 1;
setYearMonth(calendar.getTimeInMillis() * 1000);
if (mMonth < 10) {
this.mstrdate = "" + mYear + PushConstants.PUSH_TYPE_NOTIFY + mMonth;
this.mstr2date = "" + mYear + "-0" + mMonth;
} else {
this.mstrdate = "" + mYear + mMonth;
this.mstr2date = "" + mYear + Constants.ACCEPT_TIME_SEPARATOR_SERVER + mMonth;
}
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((Context) this, true, 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);
simpleDateFormat.format(new Date(beforeHourTime));
HiTools.sdfTimeSec(System.currentTimeMillis());
((TextView) this.searchTimeView.findViewById(R.id.txtSearchTimeDuration)).setText(this.mstrdate);
this.mCamera.sendIOCtrl(HiChipNVRDefines.HI_NVR_P2P_PLATFORM_GET_MONTHPLAYBACKFILE, HiChipNVRDefines.PLATFORM_S_MONTHPLAYBACKFILE_REQ.parseContent(this.chn, this.mstrdate.getBytes()));
}
private void setYearMonth(long j) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(j / 1000);
if (calendar.get(2) < 9) {
this.tv_years_month.setText(calendar.get(1) + "-0" + (calendar.get(2) + 1));
return;
}
this.tv_years_month.setText(calendar.get(1) + Constants.ACCEPT_TIME_SEPARATOR_SERVER + (calendar.get(2) + 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();
EventBus.getDefault().unregister(this);
}
private void unregisterCompent() {
MyCamera myCamera = this.mCamera;
if (myCamera != null) {
myCamera.unregisterIOSessionListener(this);
if (this.mCamera.mhiNvrdev != null) {
this.mCamera.mhiNvrdev.unregisterPlayNVRStateListener(this);
this.mCamera.mhiNvrdev.unregisterPlayBackNVRStateListener(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);
if (this.mCamera.mhiNvrdev != null) {
this.mCamera.mhiNvrdev.SetHiCameraObj(this.mCamera);
this.mCamera.mhiNvrdev.registerPlayNVRStateListener(this);
this.mCamera.mhiNvrdev.registerPlayBackNVRStateListener(this);
}
}
IntentFilter intentFilter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
ConnectionChangeReceiver connectionChangeReceiver = new ConnectionChangeReceiver();
this.myReceiver = connectionChangeReceiver;
registerReceiver(connectionChangeReceiver, intentFilter);
}
private void initViewPager() {
MyPagerAdapter myPagerAdapter = new MyPagerAdapter(this, false);
this.pagerAdapter = myPagerAdapter;
this.viewpager.setAdapter(myPagerAdapter);
this.viewpager.setCurrentItem(999);
this.viewpager.setScanScroll(true);
setTitleGirdView();
this.stc_calendar_layout.addView(this.title_gView, new LinearLayout.LayoutParams(-1, -2));
this.pagerAdapter.setOnItemClickListenerPostion(new MyPagerAdapter.OnItemClickListenerPostion() {
@Override
public void onItemPostion(int i) {
boolean z;
String str;
if (HiTools.isCustomFastClick(1000)) {
return;
}
NVRRecordingListActivity.this.calStartDate.set(5, 1);
int i2 = NVRRecordingListActivity.this.calStartDate.get(7) - 1;
HiLogcatUtil.e(i + "::" + i2 + ":::" + (NVRRecordingListActivity.this.calStartDate.get(2) + 1));
int i3 = (i - i2) + 1;
HiLogcatUtil.e("" + i3 + ":::" + (NVRRecordingListActivity.this.calStartDate.get(2) + 1));
Iterator it = NVRRecordingListActivity.this.allHaveVideoDayList.iterator();
while (true) {
if (!it.hasNext()) {
z = false;
break;
} else if (((Integer) it.next()).intValue() == i3) {
z = true;
break;
}
}
if (!z || NVRRecordingListActivity.this.file_list == null || NVRRecordingListActivity.this.adapter == null) {
return;
}
NVRRecordingListActivity.this.file_list.clear();
NVRRecordingListActivity.this.adapter.SetList(NVRRecordingListActivity.this.file_list);
NVRRecordingListActivity.this.adapter.setClickItemPosition(-10);
NVRRecordingListActivity.this.list_video_online.setVisibility(0);
NVRRecordingListActivity.this.tv_nothing.setVisibility(8);
if (NVRRecordingListActivity.this.list_video_online.getHeaderViewsCount() == 0) {
NVRRecordingListActivity.this.list_video_online.addHeaderView(NVRRecordingListActivity.this.searchTimeView);
}
if (NVRRecordingListActivity.this.list_video_online.getFooterViewsCount() == 0) {
NVRRecordingListActivity.this.list_video_online.addFooterView(NVRRecordingListActivity.this.loadingView);
}
NVRRecordingListActivity.this.adapter.notifyDataSetChanged();
if (NVRRecordingListActivity.this.rl_calendar.getVisibility() == 0) {
NVRRecordingListActivity.this.rl_calendar.setVisibility(8);
}
NVRRecordingListActivity nVRRecordingListActivity = NVRRecordingListActivity.this;
nVRRecordingListActivity.mstrdate = nVRRecordingListActivity.tv_years_month.getText().toString().trim().replace(Constants.ACCEPT_TIME_SEPARATOR_SERVER, "");
NVRRecordingListActivity nVRRecordingListActivity2 = NVRRecordingListActivity.this;
String str2 = nVRRecordingListActivity2.mstrdate;
nVRRecordingListActivity2.mstr2date = str2;
NVRRecordingListActivity nVRRecordingListActivity3 = NVRRecordingListActivity.this;
nVRRecordingListActivity3.curSelectMonth = nVRRecordingListActivity3.mstr2date;
HiLogcatUtil.e("--sendIOCtrl(HiChipDefines.HI_NVR_P2P_PLATFORM_GET_PLAYBACKFILE 2222--:" + str2 + ":::::" + NVRRecordingListActivity.this.mstr2date);
NVRRecordingListActivity nVRRecordingListActivity4 = NVRRecordingListActivity.this;
nVRRecordingListActivity4.mstr2date = nVRRecordingListActivity4.tv_years_month.getText().toString().trim();
if (i3 < 10) {
str = str2 + PushConstants.PUSH_TYPE_NOTIFY + i3;
NVRRecordingListActivity.this.mstr2date = NVRRecordingListActivity.this.mstr2date + "-0" + i3;
} else {
str = str2 + i3;
NVRRecordingListActivity.this.mstr2date = NVRRecordingListActivity.this.mstr2date + Constants.ACCEPT_TIME_SEPARATOR_SERVER + i3;
}
NVRRecordingListActivity nVRRecordingListActivity5 = NVRRecordingListActivity.this;
nVRRecordingListActivity5.mstrdate = str;
nVRRecordingListActivity5.saveStrdate = str;
if (NVRRecordingListActivity.this.adapter != null) {
NVRRecordingListActivity.this.adapter.Setdate(NVRRecordingListActivity.this.mstr2date);
}
HiLogcatUtil.e("--sendIOCtrl(HiChipDefines.HI_NVR_P2P_PLATFORM_GET_PLAYBACKFILE 2222--:" + str + ":::::" + NVRRecordingListActivity.this.mstr2date);
((TextView) NVRRecordingListActivity.this.searchTimeView.findViewById(R.id.txtSearchTimeDuration)).setText(str);
NVRRecordingListActivity.this.btn_return.setEnabled(false);
NVRRecordingListActivity.this.iv_choose_data.setEnabled(false);
NVRRecordingListActivity.this.tv_changechn.setEnabled(false);
NVRRecordingListActivity.this.isChangeMonth = false;
NVRRecordingListActivity.this.mSelectPosition = i3;
NVRRecordingListActivity.this.mCamera.sendIOCtrl(HiChipNVRDefines.HI_NVR_P2P_PLATFORM_GET_PLAYBACKFILE, HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE_LIST_REQ.parseContent(NVRRecordingListActivity.this.chn, NVRRecordingListActivity.this.mgetvideotype, str.getBytes()));
EventBus.getDefault().post(new MsgCalenderDay(NVRRecordingListActivity.this.allHaveVideoDayList, NVRRecordingListActivity.this.alreadyGetVideoDay, NVRRecordingListActivity.this.mSelectPosition, NVRRecordingListActivity.this.currPager));
}
});
this.viewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrollStateChanged(int i) {
}
@Override
public void onPageScrolled(int i, float f, int i2) {
}
@Override
public void onPageSelected(int i) {
NVRRecordingListActivity.this.calStartDate.add(2, i - NVRRecordingListActivity.this.perPager);
NVRRecordingListActivity.this.calStartDate.set(5, 1);
NVRRecordingListActivity nVRRecordingListActivity = NVRRecordingListActivity.this;
nVRRecordingListActivity.perPager = nVRRecordingListActivity.currPager = i;
if (NVRRecordingListActivity.this.calStartDate.get(2) < 9) {
NVRRecordingListActivity.this.tv_years_month.setText(NVRRecordingListActivity.this.calStartDate.get(1) + "-0" + (NVRRecordingListActivity.this.calStartDate.get(2) + 1));
} else {
NVRRecordingListActivity.this.tv_years_month.setText(NVRRecordingListActivity.this.calStartDate.get(1) + Constants.ACCEPT_TIME_SEPARATOR_SERVER + (NVRRecordingListActivity.this.calStartDate.get(2) + 1));
}
int i2 = NVRRecordingListActivity.this.calStartDate.get(1);
int i3 = NVRRecordingListActivity.this.calStartDate.get(2) + 1;
if (i3 < 10) {
NVRRecordingListActivity.this.mstrdate = "" + i2 + PushConstants.PUSH_TYPE_NOTIFY + i3;
NVRRecordingListActivity.this.mstr2date = "" + i2 + "-0" + i3;
} else {
NVRRecordingListActivity.this.mstrdate = "" + i2 + i3;
NVRRecordingListActivity.this.mstr2date = "" + i2 + Constants.ACCEPT_TIME_SEPARATOR_SERVER + i3;
}
if (NVRRecordingListActivity.this.mstrdate.equals(NVRRecordingListActivity.this.curSelectMonth)) {
NVRRecordingListActivity.this.isChangeMonth = false;
} else {
NVRRecordingListActivity.this.isChangeMonth = true;
}
NVRRecordingListActivity.this.mCamera.sendIOCtrl(HiChipNVRDefines.HI_NVR_P2P_PLATFORM_GET_MONTHPLAYBACKFILE, HiChipNVRDefines.PLATFORM_S_MONTHPLAYBACKFILE_REQ.parseContent(NVRRecordingListActivity.this.chn, NVRRecordingListActivity.this.mstrdate.getBytes()));
if (TextUtils.isEmpty(NVRRecordingListActivity.this.saveStrdate)) {
return;
}
NVRRecordingListActivity nVRRecordingListActivity2 = NVRRecordingListActivity.this;
nVRRecordingListActivity2.mstrdate = nVRRecordingListActivity2.saveStrdate;
}
});
}
private void setTitleGirdView() {
this.title_gView = setGirdView();
this.title_gView.setLayoutParams(new LinearLayout.LayoutParams(-1, -2));
this.title_gView.setVerticalSpacing(1);
this.title_gView.setHorizontalSpacing(1);
this.title_gView.setAdapter((ListAdapter) new TitleGridAdapter(this));
}
private GridView setGirdView() {
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2);
GridView gridView = new GridView(this);
gridView.setLayoutParams(layoutParams);
gridView.setNumColumns(7);
gridView.setGravity(16);
gridView.setVerticalSpacing(1);
gridView.setHorizontalSpacing(1);
gridView.setBackgroundColor(0);
gridView.setSelector(new ColorDrawable(0));
return gridView;
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case 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;
case R.id.btn_return:
finish();
return;
case R.id.iv_choose_data:
if (this.rl_calendar.getVisibility() == 0) {
this.rl_calendar.setVisibility(8);
return;
}
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2);
layoutParams.height = HiTools.dip2px(this, 300.0f);
this.rl_calendar.setLayoutParams(layoutParams);
this.rl_calendar.setVisibility(0);
return;
case R.id.iv_left:
if (HiTools.isCustomFastClick(500)) {
return;
}
showPreMonth();
return;
case R.id.iv_right:
if (HiTools.isCustomFastClick(500)) {
return;
}
showNextMonth();
return;
case R.id.ll_sort:
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));
return;
case R.id.tv_changechn:
if (this.rl_calendar.getVisibility() == 0) {
this.rl_calendar.setVisibility(8);
}
showChooseNVRChnType();
return;
default:
return;
}
}
private void showPreMonth() {
NoSlidingViewPager noSlidingViewPager = this.viewpager;
int i = this.currPager - 1;
this.currPager = i;
noSlidingViewPager.setCurrentItem(i, true);
}
private void showNextMonth() {
int i = this.currPager;
if (i >= 999) {
return;
}
NoSlidingViewPager noSlidingViewPager = this.viewpager;
int i2 = i + 1;
this.currPager = i2;
noSlidingViewPager.setCurrentItem(i2, true);
}
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() || !NVRRecordingListActivity.this.isDownloading) {
return;
}
NVRRecordingListActivity.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() {
NVRRecordingListActivity.this.lambda$onItemClick$0$NVRRecordingListActivity(i);
}
}, 150L);
}
public void lambda$onItemClick$0$NVRRecordingListActivity(int i) {
final int headerViewsCount;
List<HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE> list = this.file_list;
if (list == null || list.size() == 0 || (headerViewsCount = i - this.list_video_online.getHeaderViewsCount()) < 0) {
return;
}
View inflate = View.inflate(this, R.layout.popview_video_online, null);
this.isCallDown = false;
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.eAlarmType == 255) {
textView.setText(stringArray[3]);
} else {
textView.setText(stringArray[2]);
}
((TextView) inflate.findViewById(R.id.pup_vo_item_tv_time)).setText(this.mstrdate + " " + HiGetFileTime(this.evt.u32StartTime) + " - " + HiGetFileTime(this.evt.u32StopTime));
((TextView) inflate.findViewById(R.id.tv_play_video_online)).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NVRRecordingListActivity.this.lambda$popupMethod$2$NVRRecordingListActivity(popupWindow, headerViewsCount, view);
}
});
((TextView) inflate.findViewById(R.id.tv_downlinad_video_online)).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
NVRRecordingListActivity.this.lambda$popupMethod$3$NVRRecordingListActivity(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$NVRRecordingListActivity(PopupWindow popupWindow, final int i, View view) {
popupWindow.dismiss();
this.list_video_online.postDelayed(new Runnable() {
@Override
public final void run() {
NVRRecordingListActivity.this.lambda$popupMethod$1$NVRRecordingListActivity(i);
}
}, 100L);
}
public void lambda$popupMethod$3$NVRRecordingListActivity(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$NVRRecordingListActivity(int i) {
List<HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE> list;
if (this.mCamera == null || (list = this.file_list) == null || list.size() == 0) {
return;
}
this.mCamera.mhiNvrdev.unregisterPlayNVRStateListener(this);
this.mCamera.mhiNvrdev.unregisterPlayBackNVRStateListener(this);
HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE platform_s_playbackfile = this.file_list.get(i);
Bundle bundle = new Bundle();
bundle.putString(HiDataValue.EXTRAS_KEY_UID, this.mCamera.getUid());
byte[] longToByteArray4_Little = Packet.longToByteArray4_Little(platform_s_playbackfile.u32StartPts[this.StreamType]);
byte[] longToByteArray4_Little2 = Packet.longToByteArray4_Little(platform_s_playbackfile.u32StopPts[this.StreamType]);
bundle.putByteArray("st", longToByteArray4_Little);
bundle.putByteArray("ed", longToByteArray4_Little2);
bundle.putLong("VIDEO START TIME", platform_s_playbackfile.u32StartTime);
bundle.putLong("VIDEO END TIME", platform_s_playbackfile.u32StopTime);
bundle.putSerializable("file_infokey", platform_s_playbackfile);
bundle.putString("mstrdatekey", this.mstrdate);
bundle.putInt("chnkey", this.chn);
if (this.mCamera.mhiNvrdev != null) {
int[] iArr = new int[this.mCamera.mNvrMaxChn];
int[] iArr2 = new int[this.mCamera.mNvrMaxChn];
int[] iArr3 = new int[this.mCamera.mNvrMaxChn];
int[] iArr4 = new int[this.mCamera.mNvrMaxChn];
iArr[0] = platform_s_playbackfile.u16Width[this.StreamType];
iArr2[0] = platform_s_playbackfile.u16Height[this.StreamType];
if (1 == platform_s_playbackfile.u8StreamCode[this.StreamType]) {
iArr3[0] = 5;
} else {
iArr3[0] = 4;
}
iArr4[0] = platform_s_playbackfile.u8AFormat;
this.mCamera.mhiNvrdev.SetHiCameraPlayBackWH(iArr, iArr2, iArr3, iArr4);
}
bundle.putString("title", this.mstrdate + " " + HiGetFileTime(this.evt.u32StartTime) + " - " + HiGetFileTime(this.evt.u32StopTime));
Intent intent = new Intent();
intent.putExtras(bundle);
intent.setClass(this, NVRPlaybackOnlineActivity.class);
startActivity(intent);
}
private void downloadRecording(int i, final HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE platform_s_playbackfile) {
this.isCallDown = true;
if (HiTools.isSDCardValid()) {
File file = new File(HiDataValue.getPathNVRDownload(this.mCamera.getUid(), this.chn, this));
if (!file.exists()) {
file.mkdirs();
}
this.download_path = file.getAbsoluteFile() + "/";
this.fileName = this.mstrdate + "_" + HiGetFileTime(platform_s_playbackfile.u32StartTime).replace(Constants.COLON_SEPARATOR, "");
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 (platform_s_playbackfile.u8StreamCode[this.StreamType] == 1) {
this.mDownLoadPath = this.download_path + this.fileName + ".h265";
} else {
this.mDownLoadPath = this.download_path + this.fileName + ".h264";
}
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;
}
String replace = this.mDownLoadPath.replace(".h264", ".4rec");
this.mDownLoadPath = replace;
String replace2 = replace.replace(".h265", ".5rec");
this.mDownLoadPath = replace2;
delfile(replace2);
this.total = (int) (platform_s_playbackfile.u32StopTime - platform_s_playbackfile.u32StartTime);
showLoadDialog(getString(R.string.tips_loading) + "...", false, false);
if (this.mCamera.mhiNvrdev != null) {
this.mCamera.videowidth_playback[0] = platform_s_playbackfile.u16Width[this.StreamType];
this.mCamera.videoheight_playback[0] = platform_s_playbackfile.u16Height[this.StreamType];
if (1 == platform_s_playbackfile.u8StreamCode[this.StreamType]) {
this.mCamera.videoType[0] = 5;
} else {
this.mCamera.videoType[0] = 4;
}
this.mCamera.AFormat[0] = platform_s_playbackfile.u8AFormat;
this.mCamera.mhiNvrdev.SetHiCameraWH(this.mCamera.videowidth_playback, this.mCamera.videoheight_playback, this.mCamera.videoType, this.mCamera.AFormat);
}
new Thread() {
@Override
public void run() {
byte[] longToByteArray4_Little = Packet.longToByteArray4_Little(platform_s_playbackfile.u32StartTime * 1000);
byte[] longToByteArray4_Little2 = Packet.longToByteArray4_Little(platform_s_playbackfile.u32StartTime);
byte[] longToByteArray4_Little3 = Packet.longToByteArray4_Little(platform_s_playbackfile.u32StopTime);
byte[] longToByteArray4_Little4 = Packet.longToByteArray4_Little(platform_s_playbackfile.u32StartPts[NVRRecordingListActivity.this.StreamType]);
try {
new FileWriter(NVRRecordingListActivity.this.mDownLoadPath).close();
} catch (IOException e) {
e.printStackTrace();
}
NVRRecordingListActivity.this.savefile_infos = platform_s_playbackfile;
HiLogcatUtil.e(platform_s_playbackfile.u32StartTime + Constants.COLON_SEPARATOR + platform_s_playbackfile.u32StopTime + "::" + platform_s_playbackfile.u32StartPts[NVRRecordingListActivity.this.StreamType] + "::::" + platform_s_playbackfile.u32StopPts[NVRRecordingListActivity.this.StreamType] + Constants.COLON_SEPARATOR + platform_s_playbackfile.u32StartTimefile + "::" + platform_s_playbackfile.u32StopTimefile);
NVRRecordingListActivity.this.mCamera.mhiNvrdev.startPlayBack(NVRRecordingListActivity.this.chn, 1, longToByteArray4_Little2, longToByteArray4_Little3, longToByteArray4_Little4, longToByteArray4_Little, platform_s_playbackfile.sFilePath, NVRRecordingListActivity.this.StreamType, NVRRecordingListActivity.this.mstrdate.getBytes(), 0, platform_s_playbackfile.u8Crc, true, false);
NVRRecordingListActivity.this.mCamera.mhiNvrdev.setPlaybackLocalPath(platform_s_playbackfile.u16Width[NVRRecordingListActivity.this.StreamType], platform_s_playbackfile.u16Height[NVRRecordingListActivity.this.StreamType], platform_s_playbackfile.u8StreamCode[NVRRecordingListActivity.this.StreamType] == 0 ? 4 : 5, platform_s_playbackfile.u8AFormat, NVRRecordingListActivity.this.mDownLoadPath);
}
}.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));
}
public void handNETWORK_CHANGED() {
if (this.isDownloading) {
this.isDownloading = false;
if (this.mCamera != null) {
byte[] longToByteArray4_Little = Packet.longToByteArray4_Little(this.savefile_infos.u32StartTime * 1000);
byte[] longToByteArray4_Little2 = Packet.longToByteArray4_Little(this.savefile_infos.u32StartTime);
byte[] longToByteArray4_Little3 = Packet.longToByteArray4_Little(this.savefile_infos.u32StopTime);
byte[] longToByteArray4_Little4 = Packet.longToByteArray4_Little(this.savefile_infos.u32StartPts[this.StreamType]);
HiLogcatUtil.e(this.savefile_infos.u32StartTime + Constants.COLON_SEPARATOR + this.savefile_infos.u32StopTime + "::" + this.savefile_infos.u32StartPts[this.StreamType] + "::::" + this.savefile_infos.u32StopPts[this.StreamType] + Constants.COLON_SEPARATOR + this.savefile_infos.u32StartTimefile + "::" + this.savefile_infos.u32StopTimefile);
this.mCamera.mhiNvrdev.stopPlayBack(this.chn, 2, longToByteArray4_Little2, longToByteArray4_Little3, longToByteArray4_Little4, longToByteArray4_Little, this.savefile_infos.sFilePath, this.StreamType, 0, this.savefile_infos.u8Crc, this.mstrdate.getBytes());
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) {
long j;
Bundle data = message.getData();
switch (message.arg1) {
case 20:
dismissLoadDialog();
showPopPupProgress();
this.isDownloading = true;
this.path = data.getString(ClientCookie.PATH_ATTR);
return;
case 21:
if (this.isDownloading) {
long j2 = data.getLong("total");
long j3 = data.getLong("curSize");
if (j3 >= 0) {
if (j2 == 0) {
j = ((j3 * 100) / 60) * 60;
} else {
j = (j3 * 100) / j2;
}
float f = (float) j;
if (f >= 99.0f) {
f = 99.0f;
}
int i = (int) f;
CircleProgressBar circleProgressBar = this.circleprogressbar;
if (circleProgressBar != null) {
circleProgressBar.setProgress(i);
return;
}
return;
}
return;
}
return;
case 22:
case 23:
default:
return;
case 24:
if (this.evt != null) {
String replace = this.mDownLoadPath.replace(".5rec", ".h265").replace(".4rec", ".h264");
SharePreUtils.putInt(HiDataValue.CACHE, this, replace, this.evt.eAlarmType);
HiLogcatUtil.e(replace + ":fdsafasd:" + this.evt.eAlarmType);
}
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();
return;
case 25:
MyToast.showToast(this, getString(R.string.tips_wifi_connect_failed));
dismissLoadDialog();
return;
case 26:
if (this.mCamera != null && this.isDownloading) {
byte[] longToByteArray4_Little = Packet.longToByteArray4_Little(this.savefile_infos.u32StartTime * 1000);
byte[] longToByteArray4_Little2 = Packet.longToByteArray4_Little(this.savefile_infos.u32StartTime);
byte[] longToByteArray4_Little3 = Packet.longToByteArray4_Little(this.savefile_infos.u32StopTime);
byte[] longToByteArray4_Little4 = Packet.longToByteArray4_Little(this.savefile_infos.u32StartPts[this.StreamType]);
HiLogcatUtil.e(this.savefile_infos.u32StartTime + Constants.COLON_SEPARATOR + this.savefile_infos.u32StopTime + "::" + this.savefile_infos.u32StartPts[this.StreamType] + "::::" + this.savefile_infos.u32StopPts[this.StreamType] + Constants.COLON_SEPARATOR + this.savefile_infos.u32StartTimefile + "::" + this.savefile_infos.u32StopTimefile);
this.mCamera.mhiNvrdev.stopPlayBack(this.chn, 2, longToByteArray4_Little2, longToByteArray4_Little3, longToByteArray4_Little4, longToByteArray4_Little, this.savefile_infos.sFilePath, this.StreamType, 0, this.savefile_infos.u8Crc, this.mstrdate.getBytes());
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;
case 27:
String replace2 = this.mDownLoadPath.replace(".5rec", ".h265").replace(".4rec", ".h264");
HiLogcatUtil.e(this.mDownLoadPath + ":" + replace2 + Constants.COLON_SEPARATOR);
renameFile(this.mDownLoadPath, replace2);
return;
}
}
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);
this.popu_tips_down.setText(getResources().getStringArray(R.array.online_recording_type)[2]);
this.downloadPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
NVRRecordingListActivity.this.isDownloading = false;
NVRRecordingListActivity.this.downloadPopupWindow.dismiss();
if (NVRRecordingListActivity.this.mCamera != null) {
byte[] longToByteArray4_Little = Packet.longToByteArray4_Little(NVRRecordingListActivity.this.savefile_infos.u32StartTime * 1000);
byte[] longToByteArray4_Little2 = Packet.longToByteArray4_Little(NVRRecordingListActivity.this.savefile_infos.u32StartTime);
byte[] longToByteArray4_Little3 = Packet.longToByteArray4_Little(NVRRecordingListActivity.this.savefile_infos.u32StopTime);
byte[] longToByteArray4_Little4 = Packet.longToByteArray4_Little(NVRRecordingListActivity.this.savefile_infos.u32StartPts[NVRRecordingListActivity.this.StreamType]);
HiLogcatUtil.e(NVRRecordingListActivity.this.savefile_infos.u32StartTime + Constants.COLON_SEPARATOR + NVRRecordingListActivity.this.savefile_infos.u32StopTime + "::" + NVRRecordingListActivity.this.savefile_infos.u32StartPts[NVRRecordingListActivity.this.StreamType] + "::::" + NVRRecordingListActivity.this.savefile_infos.u32StopPts[NVRRecordingListActivity.this.StreamType] + Constants.COLON_SEPARATOR + NVRRecordingListActivity.this.savefile_infos.u32StartTimefile + "::" + NVRRecordingListActivity.this.savefile_infos.u32StopTimefile);
NVRRecordingListActivity.this.mCamera.mhiNvrdev.stopPlayBack(NVRRecordingListActivity.this.chn, 2, longToByteArray4_Little2, longToByteArray4_Little3, longToByteArray4_Little4, longToByteArray4_Little, NVRRecordingListActivity.this.savefile_infos.sFilePath, NVRRecordingListActivity.this.StreamType, 0, NVRRecordingListActivity.this.savefile_infos.u8Crc, NVRRecordingListActivity.this.mstrdate.getBytes());
NVRRecordingListActivity.this.mCamera.mhiNvrdev.StopSingleLiveViewThread();
}
if (!NVRRecordingListActivity.this.isClickCancel && !NVRRecordingListActivity.this.getString(R.string.continue_down).equals(NVRRecordingListActivity.this.tv_cancel_downloading_video.getText().toString().trim())) {
NVRRecordingListActivity.this.deleteLoadingFile();
}
NVRRecordingListActivity.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 (NVRRecordingListActivity.this.getString(R.string.continue_down).equals(NVRRecordingListActivity.this.tv_cancel_downloading_video.getText().toString().trim())) {
NVRRecordingListActivity.this.isClickCancel = true;
NVRRecordingListActivity.this.downloadPopupWindow.dismiss();
if (NVRRecordingListActivity.this.mCamera != null) {
byte[] longToByteArray4_Little = Packet.longToByteArray4_Little(NVRRecordingListActivity.this.savefile_infos.u32StartTime * 1000);
byte[] longToByteArray4_Little2 = Packet.longToByteArray4_Little(NVRRecordingListActivity.this.savefile_infos.u32StartTime);
byte[] longToByteArray4_Little3 = Packet.longToByteArray4_Little(NVRRecordingListActivity.this.savefile_infos.u32StopTime);
byte[] longToByteArray4_Little4 = Packet.longToByteArray4_Little(NVRRecordingListActivity.this.savefile_infos.u32StartPts[NVRRecordingListActivity.this.StreamType]);
HiLogcatUtil.e(NVRRecordingListActivity.this.savefile_infos.u32StartTime + Constants.COLON_SEPARATOR + NVRRecordingListActivity.this.savefile_infos.u32StopTime + "::" + NVRRecordingListActivity.this.savefile_infos.u32StartPts[NVRRecordingListActivity.this.StreamType] + "::::" + NVRRecordingListActivity.this.savefile_infos.u32StopPts[NVRRecordingListActivity.this.StreamType] + Constants.COLON_SEPARATOR + NVRRecordingListActivity.this.savefile_infos.u32StartTimefile + "::" + NVRRecordingListActivity.this.savefile_infos.u32StopTimefile);
NVRRecordingListActivity.this.mCamera.mhiNvrdev.stopPlayBack(NVRRecordingListActivity.this.chn, 2, longToByteArray4_Little2, longToByteArray4_Little3, longToByteArray4_Little4, longToByteArray4_Little, NVRRecordingListActivity.this.savefile_infos.sFilePath, NVRRecordingListActivity.this.StreamType, 0, NVRRecordingListActivity.this.savefile_infos.u8Crc, NVRRecordingListActivity.this.mstrdate.getBytes());
NVRRecordingListActivity.this.mCamera.mhiNvrdev.StopSingleLiveViewThread();
return;
}
return;
}
NVRRecordingListActivity.this.isClickCancel = true;
NVRRecordingListActivity.this.downloadPopupWindow.dismiss();
NVRRecordingListActivity.this.deleteLoadingFile();
if (NVRRecordingListActivity.this.mCamera != null) {
byte[] longToByteArray4_Little5 = Packet.longToByteArray4_Little(NVRRecordingListActivity.this.savefile_infos.u32StartTime * 1000);
byte[] longToByteArray4_Little6 = Packet.longToByteArray4_Little(NVRRecordingListActivity.this.savefile_infos.u32StartTime);
byte[] longToByteArray4_Little7 = Packet.longToByteArray4_Little(NVRRecordingListActivity.this.savefile_infos.u32StopTime);
byte[] longToByteArray4_Little8 = Packet.longToByteArray4_Little(NVRRecordingListActivity.this.savefile_infos.u32StartPts[NVRRecordingListActivity.this.StreamType]);
HiLogcatUtil.e(NVRRecordingListActivity.this.savefile_infos.u32StartTime + Constants.COLON_SEPARATOR + NVRRecordingListActivity.this.savefile_infos.u32StopTime + "::" + NVRRecordingListActivity.this.savefile_infos.u32StartPts[NVRRecordingListActivity.this.StreamType] + "::::" + NVRRecordingListActivity.this.savefile_infos.u32StopPts[NVRRecordingListActivity.this.StreamType] + Constants.COLON_SEPARATOR + NVRRecordingListActivity.this.savefile_infos.u32StartTimefile + "::" + NVRRecordingListActivity.this.savefile_infos.u32StopTimefile);
NVRRecordingListActivity.this.mCamera.mhiNvrdev.stopPlayBack(NVRRecordingListActivity.this.chn, 2, longToByteArray4_Little6, longToByteArray4_Little7, longToByteArray4_Little8, longToByteArray4_Little5, NVRRecordingListActivity.this.savefile_infos.sFilePath, NVRRecordingListActivity.this.StreamType, 0, NVRRecordingListActivity.this.savefile_infos.u8Crc, NVRRecordingListActivity.this.mstrdate.getBytes());
NVRRecordingListActivity.this.mCamera.mhiNvrdev.StopSingleLiveViewThread();
}
}
});
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) {
NVRRecordingListActivity.this.isClickCancel = true;
NVRRecordingListActivity.this.downloadPopupWindow.dismiss();
Intent intent = new Intent(NVRRecordingListActivity.this, (Class<?>) LocalFileActivity2.class);
intent.putExtra("nvrposition", NVRRecordingListActivity.this.chn);
intent.putExtra("nvrsinglechn", true);
intent.putExtra(HiDataValue.EXTRAS_KEY_UID, NVRRecordingListActivity.this.mCamera.getUid());
NVRRecordingListActivity.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);
List<HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE> list = this.file_list;
if (list == null || this.adapter == null) {
return;
}
list.clear();
this.adapter.SetList(this.file_list);
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);
if (this.mCamera.mhiNvrdev != null) {
this.mCamera.mhiNvrdev.SetHiCameraObj(this.mCamera);
this.mCamera.mhiNvrdev.registerPlayNVRStateListener(this);
this.mCamera.mhiNvrdev.registerPlayBackNVRStateListener(this);
}
}
}
@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 callbackplaylocal(HiCamera hiCamera, int i, int i2, int i3, long j, int i4, int i5) {
HiLog.e(hiCamera.getUid() + Constants.COLON_SEPARATOR + i + Constants.COLON_SEPARATOR + i2 + Constants.COLON_SEPARATOR + i3 + Constants.COLON_SEPARATOR + j + Constants.COLON_SEPARATOR + i4 + Constants.COLON_SEPARATOR + i5);
if (!this.isCallDown) {
}
}
@Override
public void callbackplaylocalExt(HiCamera hiCamera, int i, int i2, int i3, long j, int i4, int i5, String str) {
HiLog.e(hiCamera.getUid() + Constants.COLON_SEPARATOR + i + Constants.COLON_SEPARATOR + i2 + Constants.COLON_SEPARATOR + i3 + Constants.COLON_SEPARATOR + j + ":::" + (j - this.mSaveFristsec) + ":::" + this.total + Constants.COLON_SEPARATOR + i4 + Constants.COLON_SEPARATOR + i5 + Constants.COLON_SEPARATOR + str);
if (this.isCallDown) {
if (this.mSaveFristsec == 0) {
this.mSaveFristsec = j;
}
if (!(i5 == 21 && i2 == 1180063816) && i5 == 21) {
return;
}
Bundle bundle = new Bundle();
bundle.putLong("total", this.total);
long j2 = this.mSaveFristsec;
bundle.putLong("curSize", j >= j2 ? (j - j2) / 1000 : -1L);
bundle.putString(ClientCookie.PATH_ATTR, str);
Message obtainMessage = this.handler.obtainMessage();
obtainMessage.what = HiDataValue.HANDLE_MESSAGE_DOWNLOAD_STATE;
obtainMessage.arg1 = i5;
obtainMessage.setData(bundle);
this.handler.sendMessage(obtainMessage);
}
}
@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);
}
}
public void higetSTimeDay(long j, long j2, byte[] bArr, byte[] bArr2) {
int i;
int i2;
int i3;
int i4;
int i5;
int i6;
int i7;
int i8;
if (this.mstrdate.length() < 8) {
return;
}
byte[] bArr3 = new byte[8];
int parseInt = Integer.parseInt(this.mstrdate.substring(0, 4));
int parseInt2 = Integer.parseInt(this.mstrdate.substring(4, 6));
int parseInt3 = Integer.parseInt(this.mstrdate.substring(6, 8));
if (j > 0) {
i3 = (int) (j / 3600);
long j3 = j % 3600;
i = parseInt3;
i5 = (int) (j3 / 60);
i2 = parseInt2;
i4 = (int) (j3 % 60);
} else {
i = parseInt3;
i2 = parseInt2;
i3 = 0;
i4 = 0;
i5 = 0;
}
if (j2 > 0) {
i6 = (int) (j2 / 3600);
long j4 = j2 % 3600;
i8 = (int) (j4 / 60);
i7 = (int) (j4 % 60);
} else {
i6 = 0;
i7 = 0;
i8 = 0;
}
StringBuilder sb = new StringBuilder();
sb.append("");
sb.append(parseInt);
sb.append("::");
sb.append(i2);
sb.append("::");
int i9 = i;
sb.append(i9);
sb.append("::");
sb.append(i3);
sb.append("::");
sb.append(i5);
sb.append("::");
sb.append(i4);
sb.append("::");
sb.append(i6);
sb.append("::");
sb.append(i8);
sb.append("::");
sb.append(i7);
HiLogcatUtil.e(sb.toString());
System.arraycopy(Packet.shortToByteArray_Little((short) parseInt), 0, bArr3, 0, 2);
bArr3[2] = (byte) i2;
bArr3[3] = (byte) i9;
bArr3[4] = (byte) i3;
bArr3[5] = (byte) i5;
bArr3[6] = (byte) i4;
System.arraycopy(bArr3, 0, bArr, 0, 8);
bArr3[4] = (byte) i6;
bArr3[5] = (byte) i8;
bArr3[6] = (byte) i7;
System.arraycopy(bArr3, 0, bArr2, 0, 8);
}
private void higetSTimeDay(byte[] bArr, byte[] bArr2, String str) {
if (this.mstrdate.length() < 8 || str.length() < 20) {
return;
}
byte[] bArr3 = new byte[8];
int parseInt = Integer.parseInt(this.mstrdate.substring(0, 4));
int parseInt2 = Integer.parseInt(this.mstrdate.substring(4, 6));
int parseInt3 = Integer.parseInt(this.mstrdate.substring(6, 8));
String[] split = str.split("/");
if (split.length < 1) {
return;
}
String str2 = split[split.length - 1];
int parseInt4 = Integer.parseInt(str2.substring(0, 2));
int parseInt5 = Integer.parseInt(str2.substring(2, 4));
int parseInt6 = Integer.parseInt(str2.substring(4, 6));
int parseInt7 = Integer.parseInt(str2.substring(7, 9));
int parseInt8 = Integer.parseInt(str2.substring(9, 11));
int parseInt9 = Integer.parseInt(str2.substring(11, 13));
HiLogcatUtil.e("" + parseInt + "::" + parseInt2 + "::" + parseInt3 + "::" + parseInt4 + "::" + parseInt5 + "::" + parseInt6 + "::" + parseInt7 + "::" + parseInt8 + "::" + parseInt9);
System.arraycopy(Packet.shortToByteArray_Little((short) parseInt), 0, bArr3, 0, 2);
bArr3[2] = (byte) parseInt2;
bArr3[3] = (byte) parseInt3;
bArr3[4] = (byte) parseInt4;
bArr3[5] = (byte) parseInt5;
bArr3[6] = (byte) parseInt6;
System.arraycopy(bArr3, 0, bArr, 0, 8);
bArr3[4] = (byte) parseInt7;
bArr3[5] = (byte) parseInt8;
bArr3[6] = (byte) parseInt9;
System.arraycopy(bArr3, 0, bArr2, 0, 8);
}
private String HiGetFileTime(long j) {
int i;
int i2;
int i3 = 0;
if (j > 0) {
int i4 = (int) (j / 3600);
long j2 = j % 3600;
i2 = (int) (j2 / 60);
i = (int) (j2 % 60);
i3 = i4;
} else {
i = 0;
i2 = 0;
}
return getFileTime(i3, i2, i);
}
private String getFileTime(int i, int i2, int i3) {
String str;
String str2;
if (i < 10) {
str = "" + PushConstants.PUSH_TYPE_NOTIFY + i + Constants.COLON_SEPARATOR;
} else {
str = "" + i + Constants.COLON_SEPARATOR;
}
if (i2 < 10) {
str2 = str + PushConstants.PUSH_TYPE_NOTIFY + i2 + Constants.COLON_SEPARATOR;
} else {
str2 = str + i2 + Constants.COLON_SEPARATOR;
}
if (i3 < 10) {
return str2 + PushConstants.PUSH_TYPE_NOTIFY + i3;
}
return str2 + i3;
}
private void renameFile(String str, String str2) {
if (TextUtils.isEmpty(str) || TextUtils.isEmpty(str2)) {
return;
}
new File(str).renameTo(new File(str2));
}
private void delfile(String str) {
if (TextUtils.isEmpty(str)) {
return;
}
File file = new File(str);
if (file.isFile() && file.exists()) {
file.delete();
}
}
public void Hi_gotoload(int i) {
this.mSelectPosition = -1;
this.btn_return.setEnabled(false);
this.iv_choose_data.setEnabled(false);
this.tv_changechn.setEnabled(false);
this.calStartDate = Calendar.getInstance();
this.currPager = 999;
this.perPager = 999;
NoSlidingViewPager noSlidingViewPager = this.viewpager;
if (noSlidingViewPager != null) {
noSlidingViewPager.setCurrentItem(999);
this.viewpager.setScanScroll(true);
}
this.chn = i;
List<HiChipNVRDefines.PLATFORM_S_PLAYBACKFILE> list = this.file_list;
if (list == null || this.adapter == null) {
return;
}
if (list != null) {
list.clear();
}
VideoOnlineListAdapter videoOnlineListAdapter = this.adapter;
if (videoOnlineListAdapter != null) {
videoOnlineListAdapter.SetList(this.file_list);
this.adapter.setClickItemPosition(-10);
}
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);
}
VideoOnlineListAdapter videoOnlineListAdapter2 = this.adapter;
if (videoOnlineListAdapter2 != null) {
videoOnlineListAdapter2.notifyDataSetChanged();
}
this.mstrdate = null;
HiLogcatUtil.e("Hi_gotoload" + this.mstrdate);
String str = this.mstrdate;
if (str == null || TextUtils.isEmpty(str)) {
Calendar calendar = Calendar.getInstance();
mYear = calendar.get(1);
mMonth = calendar.get(2) + 1;
setYearMonth(calendar.getTimeInMillis() * 1000);
if (mMonth < 10) {
this.mstrdate = "" + mYear + PushConstants.PUSH_TYPE_NOTIFY + mMonth;
this.mstr2date = "" + mYear + "-0" + mMonth;
} else {
this.mstrdate = "" + mYear + mMonth;
this.mstr2date = "" + mYear + Constants.ACCEPT_TIME_SEPARATOR_SERVER + mMonth;
}
} else {
this.mstrdate = this.mstrdate.substring(0, 6);
}
HiLogcatUtil.e("Hi_gotoload" + this.mstrdate);
((TextView) this.searchTimeView.findViewById(R.id.txtSearchTimeDuration)).setText(this.mstrdate);
this.allHaveVideoDayList.clear();
this.isModifyChn = true;
this.mSelectPosition = -1;
this.isChangeMonth = false;
this.mCamera.sendIOCtrl(HiChipNVRDefines.HI_NVR_P2P_PLATFORM_GET_MONTHPLAYBACKFILE, HiChipNVRDefines.PLATFORM_S_MONTHPLAYBACKFILE_REQ.parseContent(i, this.mstrdate.getBytes()));
}
private void showChooseNVRChnType() {
View inflate = View.inflate(this, R.layout.pup_choose_nvrchn_new, null);
RecyclerView recyclerView = (RecyclerView) inflate.findViewById(R.id.mRecyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
this.mList.clear();
int i = 0;
while (i < this.mCamera.getmNvrChannelMaxNum()) {
List<String> list = this.mList;
StringBuilder sb = new StringBuilder();
sb.append(getString(R.string.nvrchn));
i++;
sb.append(i);
list.add(sb.toString());
}
ChoosePupChannelListAdapter choosePupChannelListAdapter = new ChoosePupChannelListAdapter(this.mList);
this.mAdapter = choosePupChannelListAdapter;
recyclerView.setAdapter(choosePupChannelListAdapter);
final PopupWindow popupWindow = new PopupWindow(inflate);
popupWindow.setBackgroundDrawable(new ColorDrawable(0));
popupWindow.setOutsideTouchable(true);
popupWindow.setFocusable(true);
NVRRecordingListActivity nVRRecordingListActivity = this;
popupWindow.setWidth(HiTools.dip2px(nVRRecordingListActivity, 100.0f));
popupWindow.setHeight(HiTools.dip2px(nVRRecordingListActivity, 200.0f));
popupWindow.showAsDropDown(this.tv_changechn, 50, 10, 8388661);
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public final void onDismiss() {
NVRRecordingListActivity.lambda$showChooseNVRChnType$5();
}
});
this.mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter baseQuickAdapter, View view, int i2) {
popupWindow.dismiss();
NVRRecordingListActivity.this.tv_changechn.setText((CharSequence) NVRRecordingListActivity.this.mList.get(i2));
NVRRecordingListActivity.this.Hi_gotoload(i2);
}
});
}
public void ShowNothing(final int i) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
String string;
NVRRecordingListActivity.this.btn_return.setEnabled(true);
NVRRecordingListActivity.this.tv_changechn.setEnabled(true);
NVRRecordingListActivity.this.iv_choose_data.setEnabled(true);
NVRRecordingListActivity.this.dismissjuHuaDialog();
NVRRecordingListActivity.this.mIsDataReceveEnd = true;
NVRRecordingListActivity.this.list_video_online.removeFooterView(NVRRecordingListActivity.this.loadingView);
if (NVRRecordingListActivity.this.file_list == null) {
return;
}
if (NVRRecordingListActivity.this.file_list.size() <= 0) {
NVRRecordingListActivity.this.list_video_online.removeHeaderView(NVRRecordingListActivity.this.searchTimeView);
NVRRecordingListActivity.this.list_video_online.setVisibility(8);
NVRRecordingListActivity.this.tv_nothing.setVisibility(0);
if (i == 1) {
string = NVRRecordingListActivity.this.getString(R.string.current_moth_novideo);
} else {
string = NVRRecordingListActivity.this.getString(R.string.current_day_novideo);
}
NVRRecordingListActivity.this.tv_nothing.setText(Html.fromHtml(string));
return;
}
if (NVRRecordingListActivity.this.mIsDown) {
Collections.reverse(NVRRecordingListActivity.this.file_list);
}
NVRRecordingListActivity.this.adapter.SetList(NVRRecordingListActivity.this.file_list);
NVRRecordingListActivity.this.adapter.notifyDataSetChanged();
}
}, 100L);
}
}