diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderActivity.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderActivity.java index 123daa1de..6670774bf 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderActivity.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderActivity.java @@ -51,7 +51,7 @@ public class ReaderActivity extends BaseRxActivity { private ReaderMenu readerMenu; private int uiFlags; - private CompositeSubscription subscriptions; + protected CompositeSubscription subscriptions; private Subscription customBrightnessSubscription; private static final int LEFT_TO_RIGHT = 1; @@ -96,7 +96,7 @@ public class ReaderActivity extends BaseRxActivity { @Override protected void onDestroy() { - readerMenu.destroy(); + subscriptions.unsubscribe(); if (viewer != null) viewer.destroy(); super.onDestroy(); @@ -114,6 +114,8 @@ public class ReaderActivity extends BaseRxActivity { } public void onChapterReady(List pages, Manga manga, Chapter chapter) { + if (viewer != null) + viewer.destroy(); viewer = createViewer(manga); viewer.onPageListReady(pages); viewer.updatePageNumber(); diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderMenu.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderMenu.java index fdf217454..da5bd6762 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderMenu.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderMenu.java @@ -27,7 +27,7 @@ import eu.kanade.mangafeed.data.database.models.Chapter; import eu.kanade.mangafeed.data.database.models.Manga; import eu.kanade.mangafeed.data.preference.PreferencesHelper; import icepick.State; -import rx.subscriptions.CompositeSubscription; +import rx.Subscription; public class ReaderMenu { @@ -51,8 +51,6 @@ public class ReaderMenu { private DecimalFormat decimalFormat; - private CompositeSubscription subscriptions; - public ReaderMenu(ReaderActivity activity) { this.activity = activity; this.preferences = activity.getPreferences(); @@ -64,12 +62,11 @@ public class ReaderMenu { seekBar.setOnSeekBarChangeListener(new PageSeekBarChangeListener()); decimalFormat = new DecimalFormat("#.##"); - subscriptions = new CompositeSubscription(); initializeOptions(); } - public void destroy() { - subscriptions.unsubscribe(); + public void add(Subscription subscription) { + activity.subscriptions.add(subscription); } public void toggle() { @@ -126,7 +123,7 @@ public class ReaderMenu { private void initializeOptions() { // Orientation changes - subscriptions.add(preferences.lockOrientation().asObservable() + add(preferences.lockOrientation().asObservable() .subscribe(locked -> { int resourceId = !locked ? R.drawable.ic_screen_rotation : activity.getResources().getConfiguration().orientation == 1 ? @@ -240,7 +237,7 @@ public class ReaderMenu { } private void initializePopupMenu() { - subscriptions.add(preferences.customBrightness() + add(preferences.customBrightness() .asObservable() .subscribe(isEnabled -> { customBrightness.setChecked(isEnabled);