Fix: Prevent RecyclerView from resetting scroll position after returning from preview (#5873) (#5880)

Resolved an issue where RecyclerView would incorrectly scroll to the top after exiting fullscreen preview. Adjusted scroll behavior to maintain position unless actioned images are filtered. Implemented observer logic adjustments to handle dataset updates more efficiently.

Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
myyyy 2024-10-22 00:41:32 +11:00 committed by GitHub
parent 014feb54e5
commit 7b0b604834
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -285,9 +285,11 @@ class ImageFragment :
imageAdapter.notifyDataSetChanged()
selectorRV?.let {
it.visibility = View.VISIBLE
lastItemId?.let { pos ->
(it.layoutManager as GridLayoutManager)
.scrollToPosition(ImageHelper.getIndexFromId(filteredImages, pos))
if (switch?.isChecked == false) {
lastItemId?.let { pos ->
(it.layoutManager as GridLayoutManager)
.scrollToPosition(ImageHelper.getIndexFromId(filteredImages, pos))
}
}
}
} else {