diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 3752c803ce..061f40a2e3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -176,6 +176,7 @@ class LibraryController( private var filterTooltip: ViewTooltip? = null private var isAnimatingHopper: Boolean? = null var hasMovedHopper = preferences.shownHopperSwipeTutorial().get() + private var shouldScrollToTop = false private lateinit var elevateAppBar: ((Boolean) -> Unit) override fun getTitle(): String? { @@ -454,7 +455,7 @@ class LibraryController( ) { _, item -> preferences.groupLibraryBy().set(item) presenter.groupType = item - recycler?.scrollToPosition(0) + shouldScrollToTop = true presenter.getLibrary() true }.show() @@ -697,6 +698,10 @@ class LibraryController( category_recycler.setCategories(presenter.categories) filter_bottom_sheet.setExpandText(preferences.collapsedCategories().getOrDefault().isNotEmpty()) setActiveCategory() + if (shouldScrollToTop) { + recycler.scrollToPosition(0) + shouldScrollToTop = false + } if (onRoot) { activity?.toolbar?.setOnClickListener { val recycler = recycler ?: return@setOnClickListener @@ -780,7 +785,7 @@ class LibraryController( presenter.switchSection(pos) activeCategory = pos setActiveCategory() - recycler.scrollToPosition(0) + shouldScrollToTop = true return } val headerPosition = adapter.indexOf(pos)