mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-31 08:17:03 +00:00
Added back safe mode notice
This commit is contained in:
@@ -81,6 +81,19 @@ class RepoRvItem(val item: Repo) : ComparableRvItem<RepoRvItem>() {
|
||||
override fun itemSameAs(other: RepoRvItem): Boolean = item.id == other.item.id
|
||||
}
|
||||
|
||||
object SafeModeNotice : ComparableRvItem<SafeModeNotice>() {
|
||||
override val layoutRes = R.layout.item_safe_mode_notice
|
||||
|
||||
override fun onBindingBound(binding: ViewDataBinding) {
|
||||
super.onBindingBound(binding)
|
||||
val params = binding.root.layoutParams as? StaggeredGridLayoutManager.LayoutParams
|
||||
params?.isFullSpan = true
|
||||
}
|
||||
|
||||
override fun contentSameAs(other: SafeModeNotice) = this == other
|
||||
override fun itemSameAs(other: SafeModeNotice) = this === other
|
||||
}
|
||||
|
||||
object InstallModule : ComparableRvItem<InstallModule>() {
|
||||
override val layoutRes = R.layout.item_module_download
|
||||
|
||||
|
||||
@@ -15,10 +15,7 @@ import com.topjohnwu.magisk.model.download.RemoteFileService
|
||||
import com.topjohnwu.magisk.model.entity.internal.DownloadSubject
|
||||
import com.topjohnwu.magisk.model.entity.module.Module
|
||||
import com.topjohnwu.magisk.model.entity.module.Repo
|
||||
import com.topjohnwu.magisk.model.entity.recycler.InstallModule
|
||||
import com.topjohnwu.magisk.model.entity.recycler.ModuleItem
|
||||
import com.topjohnwu.magisk.model.entity.recycler.RepoItem
|
||||
import com.topjohnwu.magisk.model.entity.recycler.SectionTitle
|
||||
import com.topjohnwu.magisk.model.entity.recycler.*
|
||||
import com.topjohnwu.magisk.model.events.InstallExternalModuleEvent
|
||||
import com.topjohnwu.magisk.model.events.OpenChangelogEvent
|
||||
import com.topjohnwu.magisk.model.events.dialog.ModuleInstallDialog
|
||||
@@ -284,12 +281,17 @@ class ModuleViewModel(
|
||||
active: List<ModuleItem> = itemsInstalled,
|
||||
updatable: List<RepoItem.Update> = itemsUpdatable,
|
||||
remote: List<RepoItem.Remote> = itemsRemote
|
||||
) = (active + InstallModule).prependIfNotEmpty { sectionActive } +
|
||||
) = (active + InstallModule)
|
||||
.prependIfNotEmpty { sectionActive }
|
||||
.prependIf(Config.coreOnly) { SafeModeNotice } +
|
||||
updatable.prependIfNotEmpty { sectionUpdate } +
|
||||
remote.prependIfNotEmpty { sectionRemote }
|
||||
|
||||
private fun <T> List<T>.prependIf(condition: Boolean, item: () -> T) =
|
||||
if (condition) listOf(item()) + this else this
|
||||
|
||||
private fun <T> List<T>.prependIfNotEmpty(item: () -> T) =
|
||||
if (isNotEmpty()) listOf(item()) + this else this
|
||||
prependIf(isNotEmpty(), item)
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user