aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt
diff options
context:
space:
mode:
authorFabian Henneke <FabianHenneke@users.noreply.github.com>2020-07-01 18:18:21 +0200
committerGitHub <noreply@github.com>2020-07-01 21:48:21 +0530
commit1c9f7971ce006d349c4cf8c1dee441c4188d5d58 (patch)
tree504434c900c5ec67a2cff5cb9be6a75ac61ab239 /app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt
parentc5a93b8b8168eead37f3f93a8e8378211c1d240b (diff)
downloadHardenedPass-1c9f7971ce006d349c4cf8c1dee441c4188d5d58.tar.gz
HardenedPass-1c9f7971ce006d349c4cf8c1dee441c4188d5d58.zip
Scroll to files and enter folders when created (#909)
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt26
1 files changed, 20 insertions, 6 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt
index ca53b320..e91df9c6 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt
@@ -43,6 +43,7 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
private var recyclerViewStateToRestore: Parcelable? = null
private var actionMode: ActionMode? = null
+ private var scrollTarget: File? = null
private val model: SearchableRepositoryViewModel by activityViewModels()
private val binding by viewBinding(PasswordRecyclerViewBinding::bind)
@@ -132,6 +133,11 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
// When the result is filtered, we always scroll to the top since that is where
// the best fuzzy match appears.
recyclerView.scrollToPosition(0)
+ } else if (scrollTarget != null) {
+ scrollTarget?.let {
+ recyclerView.scrollToPosition(recyclerAdapter.getPositionForFile(it))
+ }
+ scrollTarget == null
} else {
// When the result is not filtered and there is a saved scroll position for it,
// we try to restore it.
@@ -223,12 +229,7 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
listener = object : OnFragmentInteractionListener {
override fun onFragmentInteraction(item: PasswordItem) {
if (item.type == PasswordItem.TYPE_CATEGORY) {
- requireStore().clearSearch()
- model.navigateTo(
- item.file,
- recyclerViewState = binding.passRecycler.layoutManager!!.onSaveInstanceState()
- )
- requireStore().supportActionBar?.setDisplayHomeAsUpEnabled(true)
+ navigateTo(item.file)
} else {
if (requireArguments().getBoolean("matchWith", false)) {
requireStore().matchPasswordWithApp(item)
@@ -272,6 +273,19 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
fun createPassword() = requireStore().createPassword()
+ fun navigateTo(file: File) {
+ requireStore().clearSearch()
+ model.navigateTo(
+ file,
+ recyclerViewState = binding.passRecycler.layoutManager!!.onSaveInstanceState()
+ )
+ requireStore().supportActionBar?.setDisplayHomeAsUpEnabled(true)
+ }
+
+ fun scrollToOnNextRefresh(file: File) {
+ scrollTarget = file
+ }
+
interface OnFragmentInteractionListener {
fun onFragmentInteraction(item: PasswordItem)
}