Search in sources :

Example 1 with DownloadItem

use of zlc.season.rxdownloadproject.model.DownloadItem in project RxDownload by ssseasonnn.

the class DownloadManagerActivity method loadData.

private void loadData() {
    RxDownload.getInstance(this).getTotalDownloadRecords().map(new Function<List<DownloadRecord>, List<DownloadItem>>() {

        @Override
        public List<DownloadItem> apply(List<DownloadRecord> downloadRecords) throws Exception {
            List<DownloadItem> result = new ArrayList<>();
            for (DownloadRecord each : downloadRecords) {
                DownloadItem bean = new DownloadItem();
                bean.record = each;
                result.add(bean);
            }
            return result;
        }
    }).subscribe(new Consumer<List<DownloadItem>>() {

        @Override
        public void accept(List<DownloadItem> downloadBeen) throws Exception {
            mAdapter.addAll(downloadBeen);
        }
    });
}
Also used : Function(io.reactivex.functions.Function) ArrayList(java.util.ArrayList) DownloadItem(zlc.season.rxdownloadproject.model.DownloadItem) ArrayList(java.util.ArrayList) List(java.util.List) DownloadRecord(zlc.season.rxdownload2.entity.DownloadRecord)

Example 2 with DownloadItem

use of zlc.season.rxdownloadproject.model.DownloadItem in project RxDownload by ssseasonnn.

the class DownloadManagerActivity method onDestroy.

@Override
protected void onDestroy() {
    super.onDestroy();
    List<DownloadItem> list = mAdapter.getData();
    for (DownloadItem each : list) {
        Utils.dispose(each.disposable);
    }
}
Also used : DownloadItem(zlc.season.rxdownloadproject.model.DownloadItem)

Aggregations

DownloadItem (zlc.season.rxdownloadproject.model.DownloadItem)2 Function (io.reactivex.functions.Function)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 DownloadRecord (zlc.season.rxdownload2.entity.DownloadRecord)1