use of Utils.OnLoadMoreListener 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();
}
}
Aggregations