Fix: Restore store scroll position on back press (#670)
Restoring the scroll position in the main store fragment is currently broken since the stored state (recyclerView.verticalScrollbarPosition) is always 0 - it is just an enum that governs where the scrollbar is placed on the screen. The fix is to remember the list position of the last fully visible item and scroll to it when restoring the scroll position. Co-authored-by: Harsh Shandilya <msfjarvis@gmail.com>
This commit is contained in:
parent
791868f3d6
commit
94b0b64501
1 changed files with 2 additions and 2 deletions
|
@ -123,7 +123,7 @@ class PasswordFragment : Fragment() {
|
|||
)
|
||||
// push the category were we're going
|
||||
pathStack.push(item.file)
|
||||
scrollPosition.push(recyclerView.verticalScrollbarPosition)
|
||||
scrollPosition.push((recyclerView.layoutManager as LinearLayoutManager).findLastCompletelyVisibleItemPosition())
|
||||
recyclerView.scrollToPosition(0)
|
||||
recyclerAdapter.clear()
|
||||
recyclerAdapter.addAll(getPasswords(item.file, getRepositoryDirectory(context), sortOrder))
|
||||
|
@ -235,7 +235,7 @@ class PasswordFragment : Fragment() {
|
|||
/** Goes back one level back in the path */
|
||||
fun popBack() {
|
||||
if (passListStack.isEmpty()) return
|
||||
recyclerView.scrollToPosition(scrollPosition.pop())
|
||||
(recyclerView.layoutManager as LinearLayoutManager).scrollToPosition(scrollPosition.pop())
|
||||
recyclerAdapter.clear()
|
||||
recyclerAdapter.addAll(passListStack.pop())
|
||||
pathStack.pop()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue