From 5fbeeade9406a664944040ea70c3d0ce7f470109 Mon Sep 17 00:00:00 2001 From: len Date: Fri, 8 Apr 2016 22:57:31 +0200 Subject: [PATCH] A few more crashes fixed --- .../java/eu/kanade/tachiyomi/ui/library/LibraryFragment.kt | 4 +++- .../kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.kt | 6 ++---- .../eu/kanade/tachiyomi/ui/manga/info/MangaInfoPresenter.kt | 2 +- .../tachiyomi/ui/manga/myanimelist/MyAnimeListPresenter.kt | 2 +- .../java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryFragment.kt index 041f6baa3..cf267b2de 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryFragment.kt @@ -237,7 +237,9 @@ class LibraryFragment : BaseRxFragment(), ActionMode.Callback this.query = query // Notify the subject the query has changed. - presenter.searchSubject.onNext(query) + if (isResumed) { + presenter.searchSubject.onNext(query) + } } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.kt index 7c06c1dee..c64ecf138 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.kt @@ -68,7 +68,7 @@ class ChaptersPresenter : BasePresenter() { { view, download -> view.onChapterStatusChange(download) }, { view, error -> Timber.e(error.cause, error.message) }) - manga = SharedData.get(MangaEvent::class.java)!!.manga + manga = SharedData.get(MangaEvent::class.java)?.manga ?: return add(Observable.just(manga) .subscribeLatestCache({ view, manga -> view.onNextManga(manga) })) @@ -79,9 +79,7 @@ class ChaptersPresenter : BasePresenter() { .subscribeOn(Schedulers.io()) .doOnNext { chapters -> this.chapters = chapters - SharedData.get(ChapterCountEvent::class.java)?.let { - it.emit(chapters.size) - } + SharedData.get(ChapterCountEvent::class.java)?.emit(chapters.size) for (chapter in chapters) { setChapterStatus(chapter) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoPresenter.kt index efc0719ca..4c25c81a1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoPresenter.kt @@ -73,7 +73,7 @@ class MangaInfoPresenter : BasePresenter() { { view, manga -> view.onFetchMangaDone() }, { view, error -> view.onFetchMangaError() }) - manga = SharedData.get(MangaEvent::class.java)!!.manga + manga = SharedData.get(MangaEvent::class.java)?.manga ?: return source = sourceManager.get(manga.source)!! refreshManga() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/myanimelist/MyAnimeListPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/myanimelist/MyAnimeListPresenter.kt index 510a57ca0..c8d0c54c4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/myanimelist/MyAnimeListPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/myanimelist/MyAnimeListPresenter.kt @@ -58,7 +58,7 @@ class MyAnimeListPresenter : BasePresenter() { { view, result -> view.onRefreshDone() }, { view, error -> view.onRefreshError(error) }) - manga = SharedData.get(MangaEvent::class.java)!!.manga + manga = SharedData.get(MangaEvent::class.java)?.manga ?: return start(GET_MANGA_SYNC) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index 8c6cc38a4..2b078a40c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -71,7 +71,7 @@ class ReaderPresenter : BasePresenter() { super.onCreate(savedState) if (savedState == null) { - val event = SharedData.remove(ReaderEvent::class.java)!! + val event = SharedData.remove(ReaderEvent::class.java) ?: return manga = event.manga chapter = event.chapter } else {