aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/lint-baseline.xml11
-rw-r--r--app/src/main/java/app/passwordstore/util/viewmodel/SearchableRepositoryViewModel.kt7
2 files changed, 3 insertions, 15 deletions
diff --git a/app/lint-baseline.xml b/app/lint-baseline.xml
index f6232d8e..de1f0a60 100644
--- a/app/lint-baseline.xml
+++ b/app/lint-baseline.xml
@@ -83,17 +83,6 @@
<issue
id="DenyListedApi"
- message="For a stack use ArrayDeque which is more efficient internally."
- errorLine1=" private val navigationStack = Stack&lt;NavigationStackEntry>()"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/app/passwordstore/util/viewmodel/SearchableRepositoryViewModel.kt"
- line="297"
- column="33"/>
- </issue>
-
- <issue
- id="DenyListedApi"
message="Use the structured concurrent CoroutineScope#launch and Flow#collect APIs instead of reactive Flow#onEach and Flow#launchIn. Suspend calls like Flow#collect can be refactored into standalone suspend funs and mixed in with regular control flow in a suspend context, but calls that invoke CoroutineScope#launch and Flow#collect at the same time hide the suspend context, encouraging the developer to continue working in the reactive domain."
errorLine1=" model.searchResult"
errorLine2=" ^">
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
}