Scroll to top after refreshing
This commit is contained in:
1 parent
654e9a79c5
commit
b0896ea465
2 files changed
+12
No files matched your search
@@ -104,6 +104,7 @@ import java.util.Locale
|
||||
// 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<String, BaseGalleryInfo>() {
|
||||
override fun getRefreshKey(state: PagingState<String, BaseGalleryInfo>): String? = null
|
||||
@@ -120,6 +121,7 @@ class VMStorage : ViewModel() {
|
||||
} else {
|
||||
urlBuilder.setIndex(key, false)
|
||||
}
|
||||
shouldScrollToTop = true
|
||||
}
|
||||
}
|
||||
val r = runSuspendCatching {
|
||||
@@ -357,6 +359,10 @@ class FavoritesScene : SearchBarScene() {
|
||||
binding.tip.text = empty
|
||||
transition.showView(2)
|
||||
} else {
|
||||
if (vm.shouldScrollToTop) {
|
||||
vm.shouldScrollToTop = false
|
||||
binding.recyclerView.scrollToPosition(0)
|
||||
}
|
||||
transition.showView(0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ import java.util.Locale
|
||||
|
||||
class VMStorage1 : ViewModel() {
|
||||
var urlBuilder = ListUrlBuilder()
|
||||
var shouldScrollToTop = false
|
||||
val dataFlow = Pager(PagingConfig(25)) {
|
||||
object : PagingSource<String, BaseGalleryInfo>() {
|
||||
override fun getRefreshKey(state: PagingState<String, BaseGalleryInfo>): String? = null
|
||||
@@ -154,6 +155,7 @@ class VMStorage1 : ViewModel() {
|
||||
} else {
|
||||
urlBuilder.setIndex(key, false)
|
||||
}
|
||||
shouldScrollToTop = true
|
||||
}
|
||||
}
|
||||
val r = runSuspendCatching {
|
||||
@@ -402,6 +404,10 @@ class GalleryListScene : SearchBarScene() {
|
||||
binding.tip.text = empty
|
||||
transition.showView(2)
|
||||
} else {
|
||||
if (vm.shouldScrollToTop) {
|
||||
vm.shouldScrollToTop = false
|
||||
binding.recyclerView.scrollToPosition(0)
|
||||
}
|
||||
transition.showView(0)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user