aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt14
1 files changed, 11 insertions, 3 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt
index f5d9b3ab..e4551f1c 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt
@@ -124,10 +124,18 @@ class PasswordFragment : Fragment() {
// and not on folder navigations since the latter leads to too many removal animations.
(recyclerView.itemAnimator as OnOffItemAnimator).isEnabled = result.isFiltered
recyclerAdapter.submitList(result.passwordItems) {
- recyclerViewStateToRestore?.let {
- recyclerView.layoutManager!!.onRestoreInstanceState(it)
+ if (result.isFiltered) {
+ // When the result is filtered, we always scroll to the top since that is where
+ // the best fuzzy match appears.
+ recyclerView.scrollToPosition(0)
+ } else {
+ // When the result is not filtered and there is a saved scroll position for it,
+ // we try to restore it.
+ recyclerViewStateToRestore?.let {
+ recyclerView.layoutManager!!.onRestoreInstanceState(it)
+ }
+ recyclerViewStateToRestore = null
}
- recyclerViewStateToRestore = null
}
}
}