mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 03:09:19 +01:00
Fix memory leak in reader
This commit is contained in:
parent
39d3033d44
commit
23c9caf87e
@ -51,7 +51,7 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||||||
private ReaderMenu readerMenu;
|
private ReaderMenu readerMenu;
|
||||||
|
|
||||||
private int uiFlags;
|
private int uiFlags;
|
||||||
private CompositeSubscription subscriptions;
|
protected CompositeSubscription subscriptions;
|
||||||
private Subscription customBrightnessSubscription;
|
private Subscription customBrightnessSubscription;
|
||||||
|
|
||||||
private static final int LEFT_TO_RIGHT = 1;
|
private static final int LEFT_TO_RIGHT = 1;
|
||||||
@ -96,7 +96,7 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
readerMenu.destroy();
|
subscriptions.unsubscribe();
|
||||||
if (viewer != null)
|
if (viewer != null)
|
||||||
viewer.destroy();
|
viewer.destroy();
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
@ -114,6 +114,8 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onChapterReady(List<Page> pages, Manga manga, Chapter chapter) {
|
public void onChapterReady(List<Page> pages, Manga manga, Chapter chapter) {
|
||||||
|
if (viewer != null)
|
||||||
|
viewer.destroy();
|
||||||
viewer = createViewer(manga);
|
viewer = createViewer(manga);
|
||||||
viewer.onPageListReady(pages);
|
viewer.onPageListReady(pages);
|
||||||
viewer.updatePageNumber();
|
viewer.updatePageNumber();
|
||||||
|
@ -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.database.models.Manga;
|
||||||
import eu.kanade.mangafeed.data.preference.PreferencesHelper;
|
import eu.kanade.mangafeed.data.preference.PreferencesHelper;
|
||||||
import icepick.State;
|
import icepick.State;
|
||||||
import rx.subscriptions.CompositeSubscription;
|
import rx.Subscription;
|
||||||
|
|
||||||
public class ReaderMenu {
|
public class ReaderMenu {
|
||||||
|
|
||||||
@ -51,8 +51,6 @@ public class ReaderMenu {
|
|||||||
|
|
||||||
private DecimalFormat decimalFormat;
|
private DecimalFormat decimalFormat;
|
||||||
|
|
||||||
private CompositeSubscription subscriptions;
|
|
||||||
|
|
||||||
public ReaderMenu(ReaderActivity activity) {
|
public ReaderMenu(ReaderActivity activity) {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
this.preferences = activity.getPreferences();
|
this.preferences = activity.getPreferences();
|
||||||
@ -64,12 +62,11 @@ public class ReaderMenu {
|
|||||||
seekBar.setOnSeekBarChangeListener(new PageSeekBarChangeListener());
|
seekBar.setOnSeekBarChangeListener(new PageSeekBarChangeListener());
|
||||||
decimalFormat = new DecimalFormat("#.##");
|
decimalFormat = new DecimalFormat("#.##");
|
||||||
|
|
||||||
subscriptions = new CompositeSubscription();
|
|
||||||
initializeOptions();
|
initializeOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroy() {
|
public void add(Subscription subscription) {
|
||||||
subscriptions.unsubscribe();
|
activity.subscriptions.add(subscription);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggle() {
|
public void toggle() {
|
||||||
@ -126,7 +123,7 @@ public class ReaderMenu {
|
|||||||
|
|
||||||
private void initializeOptions() {
|
private void initializeOptions() {
|
||||||
// Orientation changes
|
// Orientation changes
|
||||||
subscriptions.add(preferences.lockOrientation().asObservable()
|
add(preferences.lockOrientation().asObservable()
|
||||||
.subscribe(locked -> {
|
.subscribe(locked -> {
|
||||||
int resourceId = !locked ? R.drawable.ic_screen_rotation :
|
int resourceId = !locked ? R.drawable.ic_screen_rotation :
|
||||||
activity.getResources().getConfiguration().orientation == 1 ?
|
activity.getResources().getConfiguration().orientation == 1 ?
|
||||||
@ -240,7 +237,7 @@ public class ReaderMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initializePopupMenu() {
|
private void initializePopupMenu() {
|
||||||
subscriptions.add(preferences.customBrightness()
|
add(preferences.customBrightness()
|
||||||
.asObservable()
|
.asObservable()
|
||||||
.subscribe(isEnabled -> {
|
.subscribe(isEnabled -> {
|
||||||
customBrightness.setChecked(isEnabled);
|
customBrightness.setChecked(isEnabled);
|
||||||
|
Loading…
Reference in New Issue
Block a user