mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-30 21:45:27 +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 itemNoneInstalled = TextItem(R.string.no_modules_found)
|
||||||
private val itemNoneUpdatable = TextItem(R.string.module_update_none)
|
private val itemNoneUpdatable = TextItem(R.string.module_update_none)
|
||||||
|
|
||||||
private val itemsInstalledHelpers = ObservableArrayList<TextItem>().also {
|
private val itemsInstalledHelpers = ObservableArrayList<TextItem>()
|
||||||
it.add(itemNoneInstalled)
|
private val itemsUpdatableHelpers = ObservableArrayList<TextItem>()
|
||||||
}
|
|
||||||
private val itemsUpdatableHelpers = ObservableArrayList<TextItem>().also {
|
|
||||||
it.add(itemNoneUpdatable)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val itemsCoreOnly = ObservableArrayList<SafeModeNotice>()
|
private val itemsCoreOnly = ObservableArrayList<SafeModeNotice>()
|
||||||
private val itemsInstalled = diffListOf<ModuleItem>()
|
private val itemsInstalled = diffListOf<ModuleItem>()
|
||||||
@ -159,16 +155,22 @@ class ModuleViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
itemsInstalled.addOnListChangedCallback(
|
itemsInstalled.addOnListChangedCallback(
|
||||||
onItemRangeInserted = { sender, _, count ->
|
onItemRangeInserted = { _, _, _ ->
|
||||||
if (count > 0 || sender.size > 0) {
|
itemsInstalledHelpers.clear()
|
||||||
itemsInstalledHelpers.clear()
|
},
|
||||||
|
onItemRangeRemoved = { sender, _, _ ->
|
||||||
|
if (sender.isEmpty() && itemsInstalledHelpers.isEmpty()) {
|
||||||
|
itemsInstalledHelpers.add(itemNoneInstalled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
itemsUpdatable.addOnListChangedCallback(
|
itemsUpdatable.addOnListChangedCallback(
|
||||||
onItemRangeInserted = { sender, _, count ->
|
onItemRangeInserted = { _, _, _ ->
|
||||||
if (count > 0 || sender.size > 0) {
|
itemsUpdatableHelpers.clear()
|
||||||
itemsUpdatableHelpers.clear()
|
},
|
||||||
|
onItemRangeRemoved = { sender, _, _ ->
|
||||||
|
if (sender.isEmpty() && itemsUpdatableHelpers.isEmpty()) {
|
||||||
|
itemsUpdatableHelpers.add(itemNoneUpdatable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -198,6 +200,10 @@ class ModuleViewModel(
|
|||||||
.map { it to itemsUpdatable.calculateDiff(it) }
|
.map { it to itemsUpdatable.calculateDiff(it) }
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.doOnSuccess { itemsUpdatable.update(it.first, it.second) }
|
.doOnSuccess { itemsUpdatable.update(it.first, it.second) }
|
||||||
|
.doOnSuccess {
|
||||||
|
if (itemsInstalled.isEmpty()) itemsInstalledHelpers.add(itemNoneInstalled)
|
||||||
|
if (itemsUpdatable.isEmpty()) itemsUpdatableHelpers.add(itemNoneUpdatable)
|
||||||
|
}
|
||||||
.ignoreElement()!!
|
.ignoreElement()!!
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
|
Loading…
Reference in New Issue
Block a user