mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 20:15:29 +00:00
Move flow.concurrentMap to ktx
This commit is contained in:
parent
b6affe06a5
commit
be9b0c2e8f
13
app/src/main/java/com/topjohnwu/magisk/ktx/XFlow.kt
Normal file
13
app/src/main/java/com/topjohnwu/magisk/ktx/XFlow.kt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package com.topjohnwu.magisk.ktx
|
||||||
|
|
||||||
|
import kotlinx.coroutines.FlowPreview
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.flatMapMerge
|
||||||
|
import kotlinx.coroutines.flow.flow
|
||||||
|
|
||||||
|
@FlowPreview
|
||||||
|
inline fun <T, R> Flow<T>.concurrentMap(crossinline transform: suspend (T) -> R): Flow<R> {
|
||||||
|
return flatMapMerge { value ->
|
||||||
|
flow { emit(transform(value)) }
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@ import com.topjohnwu.magisk.arch.Queryable
|
|||||||
import com.topjohnwu.magisk.databinding.filterableListOf
|
import com.topjohnwu.magisk.databinding.filterableListOf
|
||||||
import com.topjohnwu.magisk.databinding.itemBindingOf
|
import com.topjohnwu.magisk.databinding.itemBindingOf
|
||||||
import com.topjohnwu.magisk.di.AppContext
|
import com.topjohnwu.magisk.di.AppContext
|
||||||
|
import com.topjohnwu.magisk.ktx.concurrentMap
|
||||||
import com.topjohnwu.magisk.utils.Utils
|
import com.topjohnwu.magisk.utils.Utils
|
||||||
import com.topjohnwu.superuser.Shell
|
import com.topjohnwu.superuser.Shell
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
@ -16,6 +17,7 @@ import kotlinx.coroutines.flow.*
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
|
@FlowPreview
|
||||||
class DenyListViewModel : BaseViewModel(), Queryable {
|
class DenyListViewModel : BaseViewModel(), Queryable {
|
||||||
|
|
||||||
override val queryDelay = 0L
|
override val queryDelay = 0L
|
||||||
@ -46,14 +48,6 @@ class DenyListViewModel : BaseViewModel(), Queryable {
|
|||||||
it.bindExtra(BR.viewModel, this)
|
it.bindExtra(BR.viewModel, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@FlowPreview
|
|
||||||
private inline fun <T, R> Flow<T>.concurrentMap(crossinline transform: suspend (T) -> R): Flow<R> {
|
|
||||||
return flatMapMerge { value ->
|
|
||||||
flow { emit(transform(value)) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@FlowPreview
|
|
||||||
@SuppressLint("InlinedApi")
|
@SuppressLint("InlinedApi")
|
||||||
override fun refresh() = viewModelScope.launch {
|
override fun refresh() = viewModelScope.launch {
|
||||||
if (!Utils.showSuperUser()) {
|
if (!Utils.showSuperUser()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user