Change the download event. Fix some bugs in download manager. Other minor changes.

This commit is contained in:
inorichi
2015-11-06 03:29:23 +01:00
parent 2683cad5b5
commit d3a32da62c
10 changed files with 148 additions and 100 deletions
@@ -75,21 +75,22 @@ public class DownloadQueuePresenter extends BasePresenter<DownloadQueueFragment>
case Download.DOWNLOADED:
unsubscribeProgress(download);
unsubscribePagesStatus(download);
download.totalProgress = download.pages.size() * 100;
view.updateProgress(download);
break;
}
}
private void observeProgress(Download download, DownloadQueueFragment view) {
Subscription subscription = Observable.interval(50, TimeUnit.MILLISECONDS, Schedulers.newThread())
Subscription subscription = Observable.interval(75, TimeUnit.MILLISECONDS, Schedulers.newThread())
.flatMap(tick -> Observable.from(download.pages)
.map(Page::getProgress)
.reduce((x, y) -> x + y))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(progress -> {
download.totalProgress = progress;
view.updateProgress(download);
if (download.totalProgress != progress) {
download.totalProgress = progress;
view.updateProgress(download);
}
});
progressSubscriptions.put(download, subscription);