/** 用下载任务列表更新应用列表的下载状态 */ private void updateDownloadState(List<UpdateAppBean> list) { if (list == null || list.size() <= 0) { return; } Map<String, DownloadTask> map = DownloadTaskRecorder.getInstance().getDownloadTaskList(); for (UpdateAppBean bean : list) { if (map.containsKey(bean.downloadUrl)) { DownloadTask task = map.get(bean.downloadUrl); bean.downloadStatus = task.state; bean.alreadyDownloadPercent = task.alreadyDownloadPercent; } else { bean.downloadStatus = DownloadTask.NOT_START; bean.alreadyDownloadPercent = 0; } } }
@Override public void notifyDownloadState(DownloadTask downloadTask) { boolean needToUpdate = false; if (mBean.uAppList != null && mBean.uAppList.size() > 0) { for (UpdateAppBean bean : mBean.uAppList) { if (bean.downloadUrl.equals(downloadTask.url)) { needToUpdate = true; bean.downloadStatus = downloadTask.state; bean.alreadyDownloadPercent = downloadTask.alreadyDownloadPercent; } } } if (needToUpdate) { adapter.update(mBean.uAppList); } }