Search in sources :

Example 1 with RecordFile

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();
    }
}
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)

Example 2 with RecordFile

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();
}
Also used : RecordFile(entity.RecordFile)

Example 3 with RecordFile

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);
}
Also used : Bundle(android.os.Bundle) RecordFileProvider(adapter.RecordFileProvider) Intent(android.content.Intent) Date(java.util.Date) RecordFile(entity.RecordFile) Timer(java.util.Timer) TimerTask(java.util.TimerTask) Items(me.drakeet.multitype.Items) MultiTypeAdapter(me.drakeet.multitype.MultiTypeAdapter)

Aggregations

RecordFile (entity.RecordFile)3 Date (java.util.Date)2 OnLoadMoreListener (Utils.OnLoadMoreListener)1 RecordFileProvider (adapter.RecordFileProvider)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1 Items (me.drakeet.multitype.Items)1 MultiTypeAdapter (me.drakeet.multitype.MultiTypeAdapter)1