Silence kotlin warnings

This commit is contained in:
vvb2060 2020-10-15 17:50:35 +08:00 committed by topjohnwu
parent eb261c8026
commit 5833aadef5
5 changed files with 11 additions and 13 deletions

View File

@ -9,18 +9,18 @@ import me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter
import me.tatarka.bindingcollectionadapter2.ItemBinding import me.tatarka.bindingcollectionadapter2.ItemBinding
import me.tatarka.bindingcollectionadapter2.OnItemBind import me.tatarka.bindingcollectionadapter2.OnItemBind
inline fun <T : ComparableRvItem<*>> diffListOf( fun <T : ComparableRvItem<*>> diffListOf(
vararg newItems: T vararg newItems: T
) = diffListOf(newItems.toList()) ) = diffListOf(newItems.toList())
inline fun <T : ComparableRvItem<*>> diffListOf( fun <T : ComparableRvItem<*>> diffListOf(
newItems: List<T> newItems: List<T>
) = DiffObservableList(object : DiffObservableList.Callback<T> { ) = DiffObservableList(object : DiffObservableList.Callback<T> {
override fun areItemsTheSame(oldItem: T, newItem: T) = oldItem.genericItemSameAs(newItem) override fun areItemsTheSame(oldItem: T, newItem: T) = oldItem.genericItemSameAs(newItem)
override fun areContentsTheSame(oldItem: T, newItem: T) = oldItem.genericContentSameAs(newItem) override fun areContentsTheSame(oldItem: T, newItem: T) = oldItem.genericContentSameAs(newItem)
}).also { it.update(newItems) } }).also { it.update(newItems) }
inline fun <T : ComparableRvItem<*>> filterableListOf( fun <T : ComparableRvItem<*>> filterableListOf(
vararg newItems: T vararg newItems: T
) = FilterableDiffObservableList(object : DiffObservableList.Callback<T> { ) = FilterableDiffObservableList(object : DiffObservableList.Callback<T> {
override fun areItemsTheSame(oldItem: T, newItem: T) = oldItem.genericItemSameAs(newItem) override fun areItemsTheSame(oldItem: T, newItem: T) = oldItem.genericItemSameAs(newItem)

View File

@ -290,7 +290,7 @@ abstract class MagiskInstallImpl : KoinComponent {
srcBoot = File(installDir, "boot.img").path srcBoot = File(installDir, "boot.img").path
} }
var isSigned = false var isSigned: Boolean
try { try {
SuFileInputStream(srcBoot).use { SuFileInputStream(srcBoot).use {
isSigned = SignBoot.verifySignature(it, null) isSigned = SignBoot.verifySignature(it, null)

View File

@ -35,11 +35,9 @@ class SnackbarEvent private constructor(
) = Snackbar.make(view, message, length).apply(builder).show() ) = Snackbar.make(view, message, length).apply(builder).show()
override fun invoke(activity: BaseUIActivity<*, *>) { override fun invoke(activity: BaseUIActivity<*, *>) {
if (activity is BaseUIActivity<*, *>) { snackbar(activity.snackbarView,
snackbar(activity.snackbarView, msg.getText(activity.resources).toString(),
msg.getText(activity.resources).toString(), length, builder)
length, builder)
}
} }
} }

View File

@ -55,15 +55,15 @@ class EndlessRecyclerScrollListener(
val visibleItemPosition = if (direction == Direction.BOTTOM) { val visibleItemPosition = if (direction == Direction.BOTTOM) {
when (layoutManager) { when (layoutManager) {
is StaggeredGridLayoutManager -> is StaggeredGridLayoutManager ->
layoutManager.findLastVisibleItemPositions(null).max() ?: 0 layoutManager.findLastVisibleItemPositions(null).maxOrNull() ?: 0
is GridLayoutManager -> layoutManager.findLastVisibleItemPosition() is GridLayoutManager -> layoutManager.findLastVisibleItemPosition()
is LinearLayoutManager -> layoutManager.findLastVisibleItemPosition() is LinearLayoutManager -> layoutManager.findLastVisibleItemPosition()
else -> throw IllegalArgumentException("Only LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager are supported") else -> throw IllegalArgumentException("Only LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager are supported")
} }
} else { } else {
when (layoutManager) { when (layoutManager) {
is StaggeredGridLayoutManager -> layoutManager.findFirstVisibleItemPositions(null).min() is StaggeredGridLayoutManager ->
?: 0 layoutManager.findFirstVisibleItemPositions(null).minOrNull() ?: 0
is GridLayoutManager -> layoutManager.findFirstVisibleItemPosition() is GridLayoutManager -> layoutManager.findFirstVisibleItemPosition()
is LinearLayoutManager -> layoutManager.findFirstVisibleItemPosition() is LinearLayoutManager -> layoutManager.findFirstVisibleItemPosition()
else -> throw IllegalArgumentException("Only LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager are supported") else -> throw IllegalArgumentException("Only LinearLayoutManager, GridLayoutManager and StaggeredGridLayoutManager are supported")

View File

@ -228,7 +228,7 @@ class MagiskDialog(
dismiss() dismiss()
} }
} }
val items = list.mapIndexed { i, it -> DialogItem(it, i) } val items = list.mapIndexed { i, cs -> DialogItem(cs, i) }
val binding = itemBindingOf<DialogItem> { it.bindExtra(BR.listener, actualListener) } val binding = itemBindingOf<DialogItem> { it.bindExtra(BR.listener, actualListener) }
.let { ItemBinding.of(it) } .let { ItemBinding.of(it) }