diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt index df1564e9c..ea70e895b 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserViewModel.kt @@ -22,6 +22,7 @@ import com.topjohnwu.magisk.utils.toggle import com.topjohnwu.magisk.view.dialogs.CustomAlertDialog import com.topjohnwu.magisk.view.dialogs.FingerprintAuthDialog import io.reactivex.Single +import io.reactivex.disposables.Disposable import me.tatarka.bindingcollectionadapter2.ItemBinding class SuperuserViewModel( @@ -38,6 +39,7 @@ class SuperuserViewModel( } private var ignoreNext: PolicyRvItem? = null + private var fetchTask: Disposable? = null init { rxBus.register() @@ -51,7 +53,8 @@ class SuperuserViewModel( } fun updatePolicies() { - appRepo.fetchAll() + fetchTask?.dispose() + fetchTask = appRepo.fetchAll() .flattenAsFlowable { it } .map { PolicyRvItem(it, it.applicationInfo.loadIcon(packageManager)) } .toList() @@ -65,7 +68,6 @@ class SuperuserViewModel( .applySchedulers() .applyViewModel(this) .subscribeK { items.update(it.first, it.second) } - .add() } fun deletePressed(item: PolicyRvItem) {