Chapter list starts at top for unfaved manga

This commit is contained in:
Jay 2020-01-11 14:27:58 -08:00
parent 73d1b6ac27
commit c8656526df
2 changed files with 5 additions and 2 deletions

View File

@ -250,7 +250,7 @@ class ChaptersController() : NucleusController<ChaptersPresenter>(),
private fun scrollToUnread() { private fun scrollToUnread() {
if (adapter?.items.isNullOrEmpty()) return if (adapter?.items.isNullOrEmpty()) return
if (scrollToUnread) { if (scrollToUnread) {
val index = presenter.getFirstUnreadIndex() val index = presenter.getFirstUnreadIndex() ?: return
val centerOfScreen = val centerOfScreen =
if (startingChapterYPos != null) startingChapterYPos!!.toInt() - recycler.top - 96 if (startingChapterYPos != null) startingChapterYPos!!.toInt() - recycler.top - 96
else recycler.height / 2 - 96 else recycler.height / 2 - 96

View File

@ -415,7 +415,10 @@ class ChaptersPresenter(
return manga.sortDescending() return manga.sortDescending()
} }
fun getFirstUnreadIndex(): Int { fun getFirstUnreadIndex(): Int? {
if (!manga.favorite) {
return null
}
val index = chapters.sortedByDescending { it.source_order }.indexOfFirst { !it.read } val index = chapters.sortedByDescending { it.source_order }.indexOfFirst { !it.read }
return if (sortDescending()) (chapters.size - 1) - index return if (sortDescending()) (chapters.size - 1) - index
else index else index