Skip to content

Commit

Permalink
Fix: Prevent RecyclerView from resetting scroll position after return…
Browse files Browse the repository at this point in the history
…ing 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 <[email protected]>
  • Loading branch information
lzhan0121 and nicolas-raoul authored Oct 21, 2024
1 parent 014feb5 commit 7b0b604
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7b0b604

Please sign in to comment.