From 93df4e3dd91ecedbfc39ac7c9e9f2c20258fe55e Mon Sep 17 00:00:00 2001 From: FooIbar <118464521+FooIbar@users.noreply.github.com> Date: Sun, 29 Oct 2023 22:44:42 +0800 Subject: [PATCH] Revert "Scroll to top after refreshing" (#139) * Revert "Fix progress not showing after clicking error tip" This reverts commit bc914566dddfbb3314cf982e099c656875c66377. * Revert "Try to fix recyclerview disappearing after refresh (#61)" This reverts commit f9a3c3d266bce2e59a29f62672c8b971cc726537. * Revert "Scroll to top after refreshing" This reverts commit b0896ea46582838d88a2f0b67ae0f3a3cc56c0ff. --- .../com/hippo/ehviewer/ui/scene/FavoritesScene.kt | 13 ++----------- .../com/hippo/ehviewer/ui/scene/GalleryListScene.kt | 13 ++----------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/scene/FavoritesScene.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/scene/FavoritesScene.kt index 048fddd7b..59a1c5904 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/scene/FavoritesScene.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/scene/FavoritesScene.kt @@ -102,7 +102,6 @@ import rikka.core.res.resolveColor // Note that we do not really follow mvvm structure, just use it as ... storage class VMStorage : ViewModel() { var urlBuilder = FavListUrlBuilder(favCat = Settings.recentFavCat) - var shouldScrollToTop = false private val cloudDataFlow = Pager(PagingConfig(25)) { object : PagingSource() { override fun getRefreshKey(state: PagingState): String? = null @@ -119,7 +118,6 @@ class VMStorage : ViewModel() { } else { urlBuilder.setIndex(key, false) } - shouldScrollToTop = true } } val r = runSuspendCatching { @@ -347,10 +345,7 @@ class FavoritesScene : SearchBarScene() { is LoadState.Loading -> { showSearchBar() if (!binding.refreshLayout.isRefreshing) { - // https://github.com/FooIbar/EhViewer/issues/45 - // transition.showView(1) - transition.showView(0, false) - binding.refreshLayout.isRefreshing = true + transition.showView(1) } } is LoadState.Error -> { @@ -364,11 +359,7 @@ class FavoritesScene : SearchBarScene() { binding.tip.text = empty transition.showView(2) } else { - transition.showView(0, false) - if (vm.shouldScrollToTop) { - vm.shouldScrollToTop = false - binding.recyclerView.scrollToPosition(0) - } + transition.showView(0) } } } diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/scene/GalleryListScene.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/scene/GalleryListScene.kt index fcdeaa89f..cd6a97900 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/scene/GalleryListScene.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/scene/GalleryListScene.kt @@ -127,7 +127,6 @@ import rikka.core.res.resolveColor class VMStorage1 : ViewModel() { var urlBuilder = ListUrlBuilder() - var shouldScrollToTop = false val dataFlow = Pager(PagingConfig(25)) { object : PagingSource() { override fun getRefreshKey(state: PagingState): String? = null @@ -158,7 +157,6 @@ class VMStorage1 : ViewModel() { } else { urlBuilder.setIndex(key, false) } - shouldScrollToTop = true } } val r = runSuspendCatching { @@ -383,10 +381,7 @@ class GalleryListScene : SearchBarScene() { is LoadState.Loading -> { showSearchBar() if (!binding.refreshLayout.isRefreshing) { - // https://github.com/FooIbar/EhViewer/issues/45 - // transition.showView(1) - transition.showView(0, false) - binding.refreshLayout.isRefreshing = true + transition.showView(1) } } @@ -412,11 +407,7 @@ class GalleryListScene : SearchBarScene() { binding.tip.text = empty transition.showView(2) } else { - transition.showView(0, false) - if (vm.shouldScrollToTop) { - vm.shouldScrollToTop = false - binding.recyclerView.scrollToPosition(0) - } + transition.showView(0) } } }