fix: replace Stack
with ArrayDeque
in SearchableRepositoryViewModel
This commit is contained in:
parent
469700f627
commit
0669f8a062
2 changed files with 3 additions and 15 deletions
|
@ -81,17 +81,6 @@
|
|||
column="5"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="DenyListedApi"
|
||||
message="For a stack use ArrayDeque which is more efficient internally."
|
||||
errorLine1=" private val navigationStack = Stack<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."
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue