From c8656526df5b06f8f3317d8ebdc61c844c307de9 Mon Sep 17 00:00:00 2001 From: Jay Date: Sat, 11 Jan 2020 14:27:58 -0800 Subject: [PATCH] Chapter list starts at top for unfaved manga --- .../kanade/tachiyomi/ui/manga/chapter/ChaptersController.kt | 2 +- .../kanade/tachiyomi/ui/manga/chapter/ChaptersPresenter.kt | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersController.kt index 825f4504fc..da3425ea0e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersController.kt @@ -250,7 +250,7 @@ class ChaptersController() : NucleusController(), private fun scrollToUnread() { if (adapter?.items.isNullOrEmpty()) return if (scrollToUnread) { - val index = presenter.getFirstUnreadIndex() + val index = presenter.getFirstUnreadIndex() ?: return val centerOfScreen = if (startingChapterYPos != null) startingChapterYPos!!.toInt() - recycler.top - 96 else recycler.height / 2 - 96 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 76301b6a98..ba01e7fb44 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 @@ -415,7 +415,10 @@ class ChaptersPresenter( return manga.sortDescending() } - fun getFirstUnreadIndex(): Int { + fun getFirstUnreadIndex(): Int? { + if (!manga.favorite) { + return null + } val index = chapters.sortedByDescending { it.source_order }.indexOfFirst { !it.read } return if (sortDescending()) (chapters.size - 1) - index else index