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.OnItemBind
inline fun <T : ComparableRvItem<*>> diffListOf(
fun <T : ComparableRvItem<*>> diffListOf(
vararg newItems: T
) = diffListOf(newItems.toList())
inline fun <T : ComparableRvItem<*>> diffListOf(
fun <T : ComparableRvItem<*>> diffListOf(
newItems: List<T>
) = DiffObservableList(object : DiffObservableList.Callback<T> {
override fun areItemsTheSame(oldItem: T, newItem: T) = oldItem.genericItemSameAs(newItem)
override fun areContentsTheSame(oldItem: T, newItem: T) = oldItem.genericContentSameAs(newItem)
}).also { it.update(newItems) }
inline fun <T : ComparableRvItem<*>> filterableListOf(
fun <T : ComparableRvItem<*>> filterableListOf(
vararg newItems: T
) = FilterableDiffObservableList(object : DiffObservableList.Callback<T> {
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
}
var isSigned = false
var isSigned: Boolean
try {
SuFileInputStream(srcBoot).use {
isSigned = SignBoot.verifySignature(it, null)

View File

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

View File

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

View File

@ -228,7 +228,7 @@ class MagiskDialog(
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) }
.let { ItemBinding.of(it) }