aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2023-06-04 02:18:13 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2023-06-04 02:24:23 +0530
commit0669f8a062e9a8743173e755e32efd136438cad6 (patch)
tree3a93417bc56c83287379d715248a1ef72854e8a0 /app/src/main/java
parent469700f62703a9e81ea711ebe7af6f9c9a8e21fe (diff)
fix: replace `Stack` with `ArrayDeque` in `SearchableRepositoryViewModel`
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/app/passwordstore/util/viewmodel/SearchableRepositoryViewModel.kt7
1 files changed, 3 insertions, 4 deletions
diff --git a/app/src/main/java/app/passwordstore/util/viewmodel/SearchableRepositoryViewModel.kt b/app/src/main/java/app/passwordstore/util/viewmodel/SearchableRepositoryViewModel.kt
index edb82cc0..4dae1d6b 100644
--- a/app/src/main/java/app/passwordstore/util/viewmodel/SearchableRepositoryViewModel.kt
+++ b/app/src/main/java/app/passwordstore/util/viewmodel/SearchableRepositoryViewModel.kt
@@ -35,7 +35,6 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import java.io.File
import java.text.Collator
import java.util.Locale
-import java.util.Stack
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -294,7 +293,7 @@ constructor(
data class NavigationStackEntry(val dir: File, val recyclerViewState: Parcelable?)
- private val navigationStack = Stack<NavigationStackEntry>()
+ private val navigationStack = ArrayDeque<NavigationStackEntry>()
fun navigateTo(
newDirectory: File = root,
@@ -305,7 +304,7 @@ constructor(
if (!newDirectory.exists()) return
require(newDirectory.isDirectory) { "Can only navigate to a directory" }
if (pushPreviousLocation) {
- navigationStack.push(NavigationStackEntry(_currentDir.value, recyclerViewState))
+ navigationStack.addFirst(NavigationStackEntry(_currentDir.value, recyclerViewState))
}
searchActionFlow.update {
makeSearchAction(
@@ -330,7 +329,7 @@ constructor(
*/
fun navigateBack(): Parcelable? {
if (!canNavigateBack) return null
- val (oldDir, oldRecyclerViewState) = navigationStack.pop()
+ val (oldDir, oldRecyclerViewState) = navigationStack.removeFirst()
navigateTo(oldDir, pushPreviousLocation = false)
return oldRecyclerViewState
}