mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-18 15:07:30 +01:00
Update number of downloaded images in the queue, and improve the way the view refreshes the data
This commit is contained in:
@@ -77,7 +77,6 @@ public class DownloadManager {
|
||||
.subscribe(threadsNumber::onNext);
|
||||
|
||||
downloadsSubscription = downloadsQueueSubject
|
||||
.observeOn(Schedulers.newThread())
|
||||
.lift(new DynamicConcurrentMergeOperator<>(this::downloadChapter, threadsNumber))
|
||||
.onBackpressureBuffer()
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@@ -167,6 +166,8 @@ public class DownloadManager {
|
||||
Observable.just(download.pages);
|
||||
|
||||
return pageListObservable
|
||||
.subscribeOn(Schedulers.io())
|
||||
.doOnNext(pages -> download.downloadedImages = 0)
|
||||
.doOnNext(pages -> download.setStatus(Download.DOWNLOADING))
|
||||
// Get all the URLs to the source images, fetch pages if necessary
|
||||
.flatMap(pageList -> Observable.merge(
|
||||
@@ -174,6 +175,7 @@ public class DownloadManager {
|
||||
download.source.getRemainingImageUrlsFromPageList(pageList)))
|
||||
// Start downloading images, consider we can have downloaded images already
|
||||
.concatMap(page -> getDownloadedImage(page, download.source, download.directory))
|
||||
.doOnNext(p -> download.downloadedImages++)
|
||||
// Do after download completes
|
||||
.doOnCompleted(() -> onDownloadCompleted(download))
|
||||
.toList()
|
||||
@@ -363,6 +365,11 @@ public class DownloadManager {
|
||||
|
||||
public void stopDownloads() {
|
||||
destroySubscriptions();
|
||||
for (Download download : queue.get()) {
|
||||
if (download.getStatus() == Download.DOWNLOADING) {
|
||||
download.setStatus(Download.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
|
||||
@@ -14,6 +14,7 @@ public class Download {
|
||||
public File directory;
|
||||
|
||||
public transient volatile int totalProgress;
|
||||
public transient volatile int downloadedImages;
|
||||
private transient volatile int status;
|
||||
|
||||
private transient PublishSubject<Download> statusSubject;
|
||||
|
||||
Reference in New Issue
Block a user