Added safe mode notice to modules

This commit is contained in:
Viktor De Pasquale 2020-01-21 22:01:55 +01:00
parent 327b186240
commit c5e5b70e08

View File

@ -81,12 +81,14 @@ class ModuleViewModel(
it.add(itemNoneUpdatable)
}
private val itemsCoreOnly = ObservableArrayList<SafeModeNotice>()
private val itemsInstalled = diffListOf<ModuleItem>()
private val itemsUpdatable = diffListOf<RepoItem.Update>()
private val itemsRemote = diffListOf<RepoItem.Remote>()
val adapter = adapterOf<ComparableRvItem<*>>()
val items = MergeObservableList<ComparableRvItem<*>>()
.insertList(itemsCoreOnly)
.insertItem(sectionActive)
.insertList(itemsInstalledHelpers)
.insertList(itemsInstalled)
@ -159,6 +161,7 @@ class ModuleViewModel(
// ---
override fun refresh(): Disposable {
updateCoreOnlyWarning()
if (itemsRemote.isEmpty())
loadRemote()
return loadInstalled().subscribeK()
@ -268,6 +271,15 @@ class ModuleViewModel(
.subscribeK { it.progress.value = progress }
.add()
private fun updateCoreOnlyWarning() {
if (Config.coreOnly) {
if (itemsCoreOnly.isNotEmpty()) return
itemsCoreOnly.add(SafeModeNotice)
} else {
itemsCoreOnly.clear()
}
}
// ---
@WorkerThread