mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-29 03:13:17 -05: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
|
downloadSubscription = downloadsSubject
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.filter(event -> !isChapterDownloaded(event))
|
.filter(event -> !isChapterDownloaded(event))
|
||||||
.flatMap(this::createDownload)
|
.flatMap(this::prepareDownload)
|
||||||
.flatMap(this::downloadChapter, preferences.getDownloadThreads())
|
.flatMap(this::downloadChapter, preferences.getDownloadThreads())
|
||||||
.onBackpressureBuffer()
|
.onBackpressureBuffer()
|
||||||
.subscribe();
|
.subscribe();
|
||||||
|
@ -100,7 +100,7 @@ public class DownloadManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a download object and add it to the downloads queue
|
// 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(
|
Download download = new Download(
|
||||||
sourceManager.get(event.getManga().source),
|
sourceManager.get(event.getManga().source),
|
||||||
event.getManga(),
|
event.getManga(),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.kanade.mangafeed.data.models;
|
package eu.kanade.mangafeed.data.models;
|
||||||
|
|
||||||
import eu.kanade.mangafeed.data.helpers.NetworkHelper;
|
import eu.kanade.mangafeed.data.helpers.NetworkHelper;
|
||||||
import rx.subjects.BehaviorSubject;
|
import rx.subjects.PublishSubject;
|
||||||
|
|
||||||
public class Page implements NetworkHelper.ProgressListener {
|
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 status;
|
||||||
private transient volatile int progress;
|
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 QUEUE = 0;
|
||||||
public static final int LOAD_PAGE = 1;
|
public static final int LOAD_PAGE = 1;
|
||||||
|
@ -61,7 +61,8 @@ public class Page implements NetworkHelper.ProgressListener {
|
||||||
|
|
||||||
public void setStatus(int status) {
|
public void setStatus(int status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
notifyStatus();
|
if (statusSubject != null)
|
||||||
|
statusSubject.onNext(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getProgress() {
|
public int getProgress() {
|
||||||
|
@ -73,14 +74,8 @@ public class Page implements NetworkHelper.ProgressListener {
|
||||||
progress = (int) ((100 * bytesRead) / contentLength);
|
progress = (int) ((100 * bytesRead) / contentLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatusSubject(BehaviorSubject<Integer> subject) {
|
public void setStatusSubject(PublishSubject<Integer> subject) {
|
||||||
this.statusSubject = 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.Subscription;
|
||||||
import rx.android.schedulers.AndroidSchedulers;
|
import rx.android.schedulers.AndroidSchedulers;
|
||||||
import rx.schedulers.Schedulers;
|
import rx.schedulers.Schedulers;
|
||||||
import rx.subjects.BehaviorSubject;
|
import rx.subjects.PublishSubject;
|
||||||
|
|
||||||
public class ReaderPageFragment extends Fragment {
|
public class ReaderPageFragment extends Fragment {
|
||||||
|
|
||||||
|
@ -128,10 +128,11 @@ public class ReaderPageFragment extends Fragment {
|
||||||
if (page == null || statusSubscription != null)
|
if (page == null || statusSubscription != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BehaviorSubject<Integer> statusSubject = BehaviorSubject.create();
|
PublishSubject<Integer> statusSubject = PublishSubject.create();
|
||||||
page.setStatusSubject(statusSubject);
|
page.setStatusSubject(statusSubject);
|
||||||
|
|
||||||
statusSubscription = statusSubject
|
statusSubscription = statusSubject
|
||||||
|
.startWith(page.getStatus())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(this::processStatus);
|
.subscribe(this::processStatus);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue