修复下载完成状态通知问题

This commit is contained in:
juntao
2021-01-29 12:29:22 +08:00
parent 338de605ec
commit f2b9d26e8a

View File

@ -646,20 +646,22 @@ public class DownloadManager implements DownloadStatusListener {
// startDownloadService(entry, DownloadStatus.cancel);
// 将原来安装完成后在 downloadService 完成的功能放到这里,尝试避免因为 ANR 造成闪退
mDownloadDao.removeErrorMessage(entry.getUrl());
DownloadTask task = DataChanger.INSTANCE.getDownloadingTasks().get(entry.getUrl());
if (task != null) {
task.cancel();
// 改任务队列的状态
DataChanger.INSTANCE.getDownloadingTasks().remove(entry.getUrl());
AppExecutor.getUiExecutor().executeWithDelay(() -> {
mDownloadDao.removeErrorMessage(entry.getUrl());
DownloadTask task = DataChanger.INSTANCE.getDownloadingTasks().get(entry.getUrl());
if (task != null) {
task.cancel();
// 改任务队列的状态
DataChanger.INSTANCE.getDownloadingTasks().remove(entry.getUrl());
DataChanger.INSTANCE.notifyDataChanged(entry);
}
DataChanger.INSTANCE.getDownloadEntries().remove(entry.getUrl());
DataChanger.INSTANCE.notifyDataChanged(entry);
}
DataChanger.INSTANCE.getDownloadEntries().remove(entry.getUrl());
DataChanger.INSTANCE.notifyDataChanged(entry);
DownloadStatusManager.getInstance().onTaskCancelled(entry);
Utils.log(DownloadManager.class.getSimpleName(), "cancel");
DownloadStatusManager.getInstance().onTaskCancelled(entry);
Utils.log(DownloadManager.class.getSimpleName(), "cancel");
}, 0);
}
}