fix: 修复下载状态更新不及时的问题
This commit is contained in:
@ -846,6 +846,8 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
public void addObserver(DataWatcher dataWatcher) {
|
||||
Utils.log(DownloadManager.class.getSimpleName(), "addObserver");
|
||||
DataChanger.INSTANCE.addObserver(dataWatcher);
|
||||
|
||||
notifyDownloadedStatusASAP(dataWatcher);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -856,6 +858,18 @@ public class DownloadManager implements DownloadStatusListener {
|
||||
DataChanger.INSTANCE.deleteObserver(dataWatcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* 立马通知 dataWatcher 更新已下载完的任务状态,这里的下载完成是持久状态,不是瞬时状态
|
||||
*
|
||||
*/
|
||||
private void notifyDownloadedStatusASAP(DataWatcher dataWatcher) {
|
||||
for (DownloadEntity downloadEntity : getAllDownloadEntitySnapshots()) {
|
||||
if (downloadEntity.getStatus() == DownloadStatus.done) {
|
||||
dataWatcher.onDataInit(downloadEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化下载服务
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user