From cb2223d47aafaa8fa4458041e3dcc5bf9d1ef9a2 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 19 May 2020 01:34:14 -0400 Subject: [PATCH] Don't scroll to the top of the list on group change until view refresh --- .../eu/kanade/tachiyomi/ui/library/LibraryController.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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)