From b33da641d93fe00a1c6eea99be74e5371e734e44 Mon Sep 17 00:00:00 2001 From: inorichi Date: Thu, 18 Feb 2016 14:25:35 +0100 Subject: [PATCH] Fix crash in chapters list #159 --- .../tachiyomi/ui/manga/chapter/ChaptersFragment.java | 9 +++++++++ .../tachiyomi/ui/manga/chapter/ChaptersPresenter.java | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.java b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.java index 336c23777..1484b7025 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersFragment.java @@ -100,6 +100,15 @@ public class ChaptersFragment extends BaseRxFragment implemen return view; } + @Override + public void onPause() { + // Stop recycler's scrolling when onPause is called. If the activity is finishing + // the presenter will be destroyed, and it could cause NPE + // https://github.com/inorichi/tachiyomi/issues/159 + recyclerView.stopScroll(); + super.onPause(); + } + @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.chapters, menu); diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.java b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.java index 5ef4de1a5..b2e940448 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.java @@ -38,7 +38,7 @@ public class ChaptersPresenter extends BasePresenter { @Inject PreferencesHelper preferences; @Inject DownloadManager downloadManager; - @State Manga manga; + private Manga manga; private Source source; private List chapters; @State boolean hasRequested;