mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 20:15:29 +00:00
Updated helper lists so they are lazily populated
This commit is contained in:
parent
b90c65370e
commit
f5d0cc9f32
@ -75,12 +75,8 @@ class ModuleViewModel(
|
||||
private val itemNoneInstalled = TextItem(R.string.no_modules_found)
|
||||
private val itemNoneUpdatable = TextItem(R.string.module_update_none)
|
||||
|
||||
private val itemsInstalledHelpers = ObservableArrayList<TextItem>().also {
|
||||
it.add(itemNoneInstalled)
|
||||
}
|
||||
private val itemsUpdatableHelpers = ObservableArrayList<TextItem>().also {
|
||||
it.add(itemNoneUpdatable)
|
||||
}
|
||||
private val itemsInstalledHelpers = ObservableArrayList<TextItem>()
|
||||
private val itemsUpdatableHelpers = ObservableArrayList<TextItem>()
|
||||
|
||||
private val itemsCoreOnly = ObservableArrayList<SafeModeNotice>()
|
||||
private val itemsInstalled = diffListOf<ModuleItem>()
|
||||
@ -159,16 +155,22 @@ class ModuleViewModel(
|
||||
}
|
||||
|
||||
itemsInstalled.addOnListChangedCallback(
|
||||
onItemRangeInserted = { sender, _, count ->
|
||||
if (count > 0 || sender.size > 0) {
|
||||
itemsInstalledHelpers.clear()
|
||||
onItemRangeInserted = { _, _, _ ->
|
||||
itemsInstalledHelpers.clear()
|
||||
},
|
||||
onItemRangeRemoved = { sender, _, _ ->
|
||||
if (sender.isEmpty() && itemsInstalledHelpers.isEmpty()) {
|
||||
itemsInstalledHelpers.add(itemNoneInstalled)
|
||||
}
|
||||
}
|
||||
)
|
||||
itemsUpdatable.addOnListChangedCallback(
|
||||
onItemRangeInserted = { sender, _, count ->
|
||||
if (count > 0 || sender.size > 0) {
|
||||
itemsUpdatableHelpers.clear()
|
||||
onItemRangeInserted = { _, _, _ ->
|
||||
itemsUpdatableHelpers.clear()
|
||||
},
|
||||
onItemRangeRemoved = { sender, _, _ ->
|
||||
if (sender.isEmpty() && itemsUpdatableHelpers.isEmpty()) {
|
||||
itemsUpdatableHelpers.add(itemNoneUpdatable)
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -198,6 +200,10 @@ class ModuleViewModel(
|
||||
.map { it to itemsUpdatable.calculateDiff(it) }
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnSuccess { itemsUpdatable.update(it.first, it.second) }
|
||||
.doOnSuccess {
|
||||
if (itemsInstalled.isEmpty()) itemsInstalledHelpers.add(itemNoneInstalled)
|
||||
if (itemsUpdatable.isEmpty()) itemsUpdatableHelpers.add(itemNoneUpdatable)
|
||||
}
|
||||
.ignoreElement()!!
|
||||
|
||||
@Synchronized
|
||||
|
Loading…
Reference in New Issue
Block a user