mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-30 13:35:27 +00:00
Update items in the right thread
This commit is contained in:
parent
c7a27481f9
commit
a721206c6f
@ -10,7 +10,11 @@ import com.topjohnwu.magisk.core.Info
|
|||||||
import com.topjohnwu.magisk.core.base.ContentResultCallback
|
import com.topjohnwu.magisk.core.base.ContentResultCallback
|
||||||
import com.topjohnwu.magisk.core.model.module.LocalModule
|
import com.topjohnwu.magisk.core.model.module.LocalModule
|
||||||
import com.topjohnwu.magisk.core.model.module.OnlineModule
|
import com.topjohnwu.magisk.core.model.module.OnlineModule
|
||||||
import com.topjohnwu.magisk.databinding.*
|
import com.topjohnwu.magisk.databinding.MergeObservableList
|
||||||
|
import com.topjohnwu.magisk.databinding.RvItem
|
||||||
|
import com.topjohnwu.magisk.databinding.bindExtra
|
||||||
|
import com.topjohnwu.magisk.databinding.diffListOf
|
||||||
|
import com.topjohnwu.magisk.databinding.set
|
||||||
import com.topjohnwu.magisk.events.GetContentEvent
|
import com.topjohnwu.magisk.events.GetContentEvent
|
||||||
import com.topjohnwu.magisk.events.SnackbarEvent
|
import com.topjohnwu.magisk.events.SnackbarEvent
|
||||||
import com.topjohnwu.magisk.events.dialog.ModuleInstallDialog
|
import com.topjohnwu.magisk.events.dialog.ModuleInstallDialog
|
||||||
@ -35,19 +39,17 @@ class ModuleViewModel : AsyncLoadViewModel() {
|
|||||||
var loading = true
|
var loading = true
|
||||||
private set(value) = set(value, field, { field = it }, BR.loading)
|
private set(value) = set(value, field, { field = it }, BR.loading)
|
||||||
|
|
||||||
private suspend fun init() = withContext(Dispatchers.IO) {
|
override suspend fun doLoadWork() {
|
||||||
if (Info.env.isActive && LocalModule.loaded()) {
|
loading = true
|
||||||
|
val moduleLoaded = Info.env.isActive &&
|
||||||
|
withContext(Dispatchers.IO) { LocalModule.loaded() }
|
||||||
|
if (moduleLoaded) {
|
||||||
|
loadInstalled()
|
||||||
|
if (items.isEmpty()) {
|
||||||
items.insertItem(InstallModule)
|
items.insertItem(InstallModule)
|
||||||
.insertList(itemsInstalled)
|
.insertList(itemsInstalled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun doLoadWork() {
|
|
||||||
loading = true
|
|
||||||
if (items.isEmpty()) {
|
|
||||||
init()
|
|
||||||
}
|
|
||||||
loadInstalled()
|
|
||||||
loading = false
|
loading = false
|
||||||
loadUpdateInfo()
|
loadUpdateInfo()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user