diff --git a/app/src/main/java/eu/kanade/mangafeed/data/models/Page.java b/app/src/main/java/eu/kanade/mangafeed/data/models/Page.java index 8f152d8e1..d2c9e6e08 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/models/Page.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/models/Page.java @@ -1,7 +1,7 @@ package eu.kanade.mangafeed.data.models; import eu.kanade.mangafeed.data.helpers.NetworkHelper; -import rx.subjects.PublishSubject; +import rx.subjects.BehaviorSubject; public class Page implements NetworkHelper.ProgressListener { @@ -12,7 +12,7 @@ public class Page implements NetworkHelper.ProgressListener { private transient int status; private transient int progress; - private transient PublishSubject statusSubject; + private transient BehaviorSubject statusSubject; public static final int QUEUE = 0; public static final int LOAD_PAGE = 1; @@ -83,7 +83,7 @@ public class Page implements NetworkHelper.ProgressListener { progress = (int) ((100 * bytesRead) / contentLength); } - public void setStatusSubject(PublishSubject subject) { + public void setStatusSubject(BehaviorSubject subject) { this.statusSubject = subject; } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/fragment/ReaderPageFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/fragment/ReaderPageFragment.java index 044c56a26..4276e8f67 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/fragment/ReaderPageFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/fragment/ReaderPageFragment.java @@ -24,7 +24,7 @@ import rx.Observable; import rx.Subscription; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; -import rx.subjects.PublishSubject; +import rx.subjects.BehaviorSubject; public class ReaderPageFragment extends Fragment { @@ -104,17 +104,18 @@ public class ReaderPageFragment extends Fragment { private void processStatus(int status) { switch (status) { - case Page.READY: - showImage(); - unsubscribeProgress(); - unsubscribeStatus(); - break; case Page.LOAD_PAGE: showLoading(); break; case Page.DOWNLOAD_IMAGE: + observeProgress(); showDownloading(); break; + case Page.READY: + showImage(); + unsubscribeProgress(); + unsubscribeStatus(); + break; case Page.ERROR: showError(); unsubscribeProgress(); @@ -129,13 +130,9 @@ public class ReaderPageFragment extends Fragment { if (page.getStatus() == Page.READY) { showImage(); } else { - processStatus(page.getStatus()); - - PublishSubject statusSubject = PublishSubject.create(); + BehaviorSubject statusSubject = BehaviorSubject.create(); page.setStatusSubject(statusSubject); - observeProgress(); - statusSubscription = statusSubject .observeOn(AndroidSchedulers.mainThread()) .subscribe(this::processStatus);