use of entity.RecordFile in project GwellDemo by dxsdyhm.
the class RecordFilesActivity method init.
private void init() {
txLoading.setVisibility(View.GONE);
mLayoutManager = new LinearLayoutManager(this);
rcRecordfiles.setLayoutManager(new LinearLayoutManager(this));
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
// 加载更多
rcRecordfiles.addOnScrollListener(new OnLoadMoreListener() {
@Override
public void onLoadMore() {
// 获取上一次获取的数据中最后一位
RecordFile file = (RecordFile) items.get(OnLoadMoreListener.itemCount - 1);
String lastTime = file.getName().substring(6, 22);
lastTime = lastTime.replace("_", " ");
Date nextEndTime = null;
try {
nextEndTime = sdf.parse(lastTime);
} catch (ParseException e) {
e.printStackTrace();
}
// 因获取到数据是按照时间从近到远顺序排序
// 所以加载更多时startDate不用变,改变nextEndTime即可
P2PHandler.getInstance().getRecordFiles(deviceId, devicePwd, startDate, nextEndTime);
}
});
regFilter();
deviceId = getIntent().getStringExtra("callID");
devicePwd = getIntent().getStringExtra("callPwd");
if (!TextUtils.isEmpty(deviceId) && !TextUtils.isEmpty(devicePwd)) {
getRecordFiles();
}
}
use of entity.RecordFile in project GwellDemo by dxsdyhm.
the class RecordFilesActivity method updateAdapter.
private void updateAdapter(String[] names) {
txLoading.setVisibility(View.GONE);
// 因加载更多时,之前的最后一个文件和加载后第一个文件重复,故仅第一次加载时加载第一个文件
if (firstLoad) {
items.add(new RecordFile(count, names[0]));
firstLoad = false;
}
for (int i = 1; i < names.length; i++) {
items.add(new RecordFile(++count, names[i]));
}
adapter.notifyDataSetChanged();
}
use of entity.RecordFile in project GwellDemo by dxsdyhm.
the class RecordFilesActivity method getRecordFiles.
private void getRecordFiles() {
txLoading.setVisibility(View.VISIBLE);
txLoading.setText(R.string.loading);
// 经过转换后的设备密码
devicePwd = P2PHandler.getInstance().EntryPassword(devicePwd);
items = new Items();
adapter = new MultiTypeAdapter(items);
Date endDate = new Date(System.currentTimeMillis());
RecordFileProvider recordFileProvider = new RecordFileProvider();
adapter.register(RecordFile.class, recordFileProvider);
recordFileProvider.setOnItemClickListner(new RecordFileProvider.OnItemClickListner() {
@Override
public void onItemClick(int position, RecordFile recordFile) {
Intent intent = new Intent(RecordFilesActivity.this, PlayBackActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable("file", recordFile);
intent.putExtra("recordFile", bundle);
intent.putExtra("deviceId", deviceId);
intent.putExtra("devicePwd", devicePwd);
startActivity(intent);
}
});
// 获取录像列表
P2PHandler.getInstance().getRecordFiles(deviceId, devicePwd, startDate, endDate);
rcRecordfiles.setAdapter(adapter);
new Timer().schedule(new TimerTask() {
@Override
public void run() {
if (items.size() == 0) {
hander.sendEmptyMessage(0);
}
}
}, 8000);
}
Aggregations