mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-17 17:18:29 +00:00
Fix superuser fragment crashes
Fix superuser screen encountering inconsistencies when refreshing the data rapidly
This commit is contained in:
parent
12bbc7fd6b
commit
7e5f2822ae
@ -22,6 +22,7 @@ import com.topjohnwu.magisk.utils.toggle
|
|||||||
import com.topjohnwu.magisk.view.dialogs.CustomAlertDialog
|
import com.topjohnwu.magisk.view.dialogs.CustomAlertDialog
|
||||||
import com.topjohnwu.magisk.view.dialogs.FingerprintAuthDialog
|
import com.topjohnwu.magisk.view.dialogs.FingerprintAuthDialog
|
||||||
import io.reactivex.Single
|
import io.reactivex.Single
|
||||||
|
import io.reactivex.disposables.Disposable
|
||||||
import me.tatarka.bindingcollectionadapter2.ItemBinding
|
import me.tatarka.bindingcollectionadapter2.ItemBinding
|
||||||
|
|
||||||
class SuperuserViewModel(
|
class SuperuserViewModel(
|
||||||
@ -38,6 +39,7 @@ class SuperuserViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var ignoreNext: PolicyRvItem? = null
|
private var ignoreNext: PolicyRvItem? = null
|
||||||
|
private var fetchTask: Disposable? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
rxBus.register<PolicyEnableEvent>()
|
rxBus.register<PolicyEnableEvent>()
|
||||||
@ -51,7 +53,8 @@ class SuperuserViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updatePolicies() {
|
fun updatePolicies() {
|
||||||
appRepo.fetchAll()
|
fetchTask?.dispose()
|
||||||
|
fetchTask = appRepo.fetchAll()
|
||||||
.flattenAsFlowable { it }
|
.flattenAsFlowable { it }
|
||||||
.map { PolicyRvItem(it, it.applicationInfo.loadIcon(packageManager)) }
|
.map { PolicyRvItem(it, it.applicationInfo.loadIcon(packageManager)) }
|
||||||
.toList()
|
.toList()
|
||||||
@ -65,7 +68,6 @@ class SuperuserViewModel(
|
|||||||
.applySchedulers()
|
.applySchedulers()
|
||||||
.applyViewModel(this)
|
.applyViewModel(this)
|
||||||
.subscribeK { items.update(it.first, it.second) }
|
.subscribeK { items.update(it.first, it.second) }
|
||||||
.add()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deletePressed(item: PolicyRvItem) {
|
fun deletePressed(item: PolicyRvItem) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user