mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-11-21 20:55:41 +03:00
Minor changes
This commit is contained in:
parent
3bdca95d96
commit
de8b7b27e1
3 changed files with 10 additions and 14 deletions
|
@ -67,7 +67,7 @@ public class DownloadManager {
|
|||
downloadSubscription = downloadsSubject
|
||||
.subscribeOn(Schedulers.io())
|
||||
.filter(event -> !isChapterDownloaded(event))
|
||||
.flatMap(this::createDownload)
|
||||
.flatMap(this::prepareDownload)
|
||||
.flatMap(this::downloadChapter, preferences.getDownloadThreads())
|
||||
.onBackpressureBuffer()
|
||||
.subscribe();
|
||||
|
@ -100,7 +100,7 @@ public class DownloadManager {
|
|||
}
|
||||
|
||||
// Create a download object and add it to the downloads queue
|
||||
private Observable<Download> createDownload(DownloadChapterEvent event) {
|
||||
private Observable<Download> prepareDownload(DownloadChapterEvent event) {
|
||||
Download download = new Download(
|
||||
sourceManager.get(event.getManga().source),
|
||||
event.getManga(),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.kanade.mangafeed.data.models;
|
||||
|
||||
import eu.kanade.mangafeed.data.helpers.NetworkHelper;
|
||||
import rx.subjects.BehaviorSubject;
|
||||
import rx.subjects.PublishSubject;
|
||||
|
||||
public class Page implements NetworkHelper.ProgressListener {
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class Page implements NetworkHelper.ProgressListener {
|
|||
private transient volatile int status;
|
||||
private transient volatile int progress;
|
||||
|
||||
private transient BehaviorSubject<Integer> statusSubject;
|
||||
private transient PublishSubject<Integer> statusSubject;
|
||||
|
||||
public static final int QUEUE = 0;
|
||||
public static final int LOAD_PAGE = 1;
|
||||
|
@ -61,7 +61,8 @@ public class Page implements NetworkHelper.ProgressListener {
|
|||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
notifyStatus();
|
||||
if (statusSubject != null)
|
||||
statusSubject.onNext(status);
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
|
@ -73,14 +74,8 @@ public class Page implements NetworkHelper.ProgressListener {
|
|||
progress = (int) ((100 * bytesRead) / contentLength);
|
||||
}
|
||||
|
||||
public void setStatusSubject(BehaviorSubject<Integer> subject) {
|
||||
public void setStatusSubject(PublishSubject<Integer> subject) {
|
||||
this.statusSubject = subject;
|
||||
notifyStatus();
|
||||
}
|
||||
|
||||
private void notifyStatus() {
|
||||
if (statusSubject != null)
|
||||
statusSubject.onNext(status);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import rx.Observable;
|
|||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
import rx.subjects.BehaviorSubject;
|
||||
import rx.subjects.PublishSubject;
|
||||
|
||||
public class ReaderPageFragment extends Fragment {
|
||||
|
||||
|
@ -128,10 +128,11 @@ public class ReaderPageFragment extends Fragment {
|
|||
if (page == null || statusSubscription != null)
|
||||
return;
|
||||
|
||||
BehaviorSubject<Integer> statusSubject = BehaviorSubject.create();
|
||||
PublishSubject<Integer> statusSubject = PublishSubject.create();
|
||||
page.setStatusSubject(statusSubject);
|
||||
|
||||
statusSubscription = statusSubject
|
||||
.startWith(page.getStatus())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::processStatus);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue