Search in sources :

Example 1 with OnLoadMoreListener

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();
    }
}
Also used : OnLoadMoreListener(Utils.OnLoadMoreListener) RecordFile(entity.RecordFile) ParseException(java.text.ParseException) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

OnLoadMoreListener (Utils.OnLoadMoreListener)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecordFile (entity.RecordFile)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1