From 01058912580a3ecfe77eaf6af209e1c46a97f2d7 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 13 Jun 2019 01:14:21 -0700 Subject: Initial fastadapter update --- adapter/build.gradle | 2 +- .../main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt | 14 +++++++------- .../ca/allanwang/kau/adapters/FastItemThemedAdapter.kt | 8 ++++---- .../ca/allanwang/kau/adapters/RepeatedClickListener.kt | 4 ++-- .../src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt | 6 +++--- .../src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) (limited to 'adapter') diff --git a/adapter/build.gradle b/adapter/build.gradle index de42b6c..4f38eae 100644 --- a/adapter/build.gradle +++ b/adapter/build.gradle @@ -6,7 +6,7 @@ dependencies { implementation project(':core') api kau.Dependencies.fastAdapter - api kau.Dependencies.fastAdapterCommons + api kau.Dependencies.fastAdapter('utils') } apply from: '../artifacts.gradle' diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt index 17fd09f..42fe1a2 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt @@ -28,17 +28,17 @@ import com.mikepenz.fastadapter.select.SelectExtension /** * Add kotlin's generic syntax to better support out types */ -fun > fastAdapter(vararg adapter: IAdapter) = - FastAdapter.with>(adapter.toList())!! +fun > fastAdapter(vararg adapter: IAdapter) = + FastAdapter.with>(adapter.toList()) -inline fun , Item : IItem<*, *>> FastAdapter.getExtension(): T? = +inline fun , Item : IItem<*>> FastAdapter.getExtension(): T? = getExtension(T::class.java) /** * Returns selection size, or -1 if selection is disabled */ -inline val > IAdapter.selectionSize: Int - get() = fastAdapter.getExtension, Item>()?.selections?.size ?: -1 +inline val > IAdapter.selectionSize: Int + get() = fastAdapter?.getExtension, Item>()?.selections?.size ?: -1 -inline val > IAdapter.selectedItems: Set - get() = fastAdapter.getExtension, Item>()?.selectedItems ?: emptySet() +inline val > IAdapter.selectedItems: Set + get() = fastAdapter?.getExtension, Item>()?.selectedItems ?: emptySet() diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt index 152982f..01ac0e5 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt @@ -24,7 +24,7 @@ import androidx.annotation.RequiresApi import ca.allanwang.kau.ui.createSimpleRippleDrawable import ca.allanwang.kau.utils.adjustAlpha import com.mikepenz.fastadapter.IItem -import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter +import com.mikepenz.fastadapter.adapters.FastItemAdapter /** * Created by Allan Wang on 2017-06-29. @@ -35,7 +35,7 @@ import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter * This adapter overrides every method where an item is added * If that item extends [ThemableIItem], then the colors will be set */ -class FastItemThemedAdapter>( +class FastItemThemedAdapter>( textColor: Int? = null, backgroundColor: Int? = null, accentColor: Int? = null @@ -113,11 +113,11 @@ class FastItemThemedAdapter>( return super.setNewList(items) } - private fun injectTheme(items: Collection?>?) { + private fun injectTheme(items: Collection?>?) { items?.forEach { injectTheme(it) } } - protected fun injectTheme(item: IItem<*, *>?) { + protected fun injectTheme(item: IItem<*>?) { if (item is ThemableIItem && item.themeEnabled) { item.textColor = textColor item.backgroundColor = backgroundColor diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt index 40b4774..3e7d707 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt @@ -25,7 +25,7 @@ import com.mikepenz.fastadapter.listeners.OnClickListener /** * Created by Allan Wang on 26/12/17. */ -fun > FastAdapter.withOnRepeatedClickListener( +fun > FastAdapter.withOnRepeatedClickListener( count: Int, duration: Long, event: OnClickListener @@ -37,7 +37,7 @@ fun > FastAdapter.withOnRepeatedClickListener( * each within [duration] from each other. * Only then will the [event] be fired, and everything will be reset. */ -private class RepeatedClickListener>( +private class RepeatedClickListener>( @IntRange(from = 1) val count: Int, @IntRange(from = 1) val duration: Long, val event: OnClickListener diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt index 6e33833..47c465c 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt @@ -51,13 +51,13 @@ class CardIItem( ), ThemableIItem by ThemableIItemDelegate() { companion object { - fun bindClickEvents(fastAdapter: FastAdapter>) { - fastAdapter.withEventHook(object : ClickEventHook>() { + fun bindClickEvents(fastAdapter: FastAdapter>) { + fastAdapter.withEventHook(object : ClickEventHook>() { override fun onBindMany(viewHolder: RecyclerView.ViewHolder): List? { return if (viewHolder is ViewHolder) listOf(viewHolder.card, viewHolder.button) else null } - override fun onClick(v: View, position: Int, adapter: FastAdapter>, item: IItem<*, *>) { + override fun onClick(v: View, position: Int, adapter: FastAdapter>, item: IItem<*>) { if (item !is CardIItem) return with(item.configs) { when (v.id) { diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt index c66dc01..853d388 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt @@ -33,7 +33,7 @@ open class KauIItem( @param:LayoutRes private val layoutRes: Int, private val viewHolder: (v: View) -> VH, private val type: Int = layoutRes -) : AbstractItem() where Item : IItem<*, *>, Item : IClickable<*> { +) : AbstractItem() where Item : IItem<*>, Item : IClickable<*> { @SuppressLint("ResourceType") final override fun getType(): Int = type -- cgit v1.2.3