diff options
Diffstat (limited to 'fastadapter/src')
4 files changed, 15 insertions, 11 deletions
diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt index 14fdc9d..59832ed 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt @@ -16,6 +16,7 @@ package ca.allanwang.kau.adapters import com.mikepenz.fastadapter.FastAdapter +import com.mikepenz.fastadapter.GenericItem import com.mikepenz.fastadapter.IAdapter import com.mikepenz.fastadapter.IAdapterExtension import com.mikepenz.fastadapter.IItem @@ -28,14 +29,14 @@ import com.mikepenz.fastadapter.select.SelectExtension /** * Add kotlin's generic syntax to better support out types */ -fun <Item : IItem<*>> fastAdapter(vararg adapter: IAdapter<out Item>) = +fun <Item : GenericItem> fastAdapter(vararg adapter: IAdapter<out Item>) = FastAdapter.with<Item, IAdapter<out Item>>(adapter.toList()) /** * Returns selection size, or -1 if selection is disabled */ -inline val <Item : IItem<*>> IAdapter<Item>.selectionSize: Int +inline val <Item : GenericItem> IAdapter<Item>.selectionSize: Int get() = fastAdapter?.getExtension<SelectExtension<Item>>()?.selections?.size ?: -1 -inline val <Item : IItem<*>> IAdapter<Item>.selectedItems: Set<Item> +inline val <Item : GenericItem> IAdapter<Item>.selectedItems: Set<Item> get() = fastAdapter?.getExtension<SelectExtension<Item>>()?.selectedItems ?: emptySet() diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt index 24a37c4..e3f43ca 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt @@ -23,6 +23,7 @@ import android.widget.TextView import androidx.annotation.RequiresApi import ca.allanwang.kau.ui.createSimpleRippleDrawable import ca.allanwang.kau.utils.adjustAlpha +import com.mikepenz.fastadapter.GenericItem import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.IItemAdapter import com.mikepenz.fastadapter.adapters.FastItemAdapter @@ -36,7 +37,7 @@ import com.mikepenz.fastadapter.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<Item : IItem<*>>( +class FastItemThemedAdapter<Item : GenericItem>( textColor: Int? = null, backgroundColor: Int? = null, accentColor: Int? = null @@ -85,11 +86,11 @@ class FastItemThemedAdapter<Item : IItem<*>>( notifyAdapterDataSetChanged() } - private fun injectTheme(items: Collection<IItem<*>?>?) { + private fun injectTheme(items: Collection<GenericItem?>?) { items?.forEach { injectTheme(it) } } - protected fun injectTheme(item: IItem<*>?) { + protected fun injectTheme(item: GenericItem?) { if (item is ThemableIItem && item.themeEnabled) { item.textColor = textColor item.backgroundColor = backgroundColor diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt index 99c367b..3aca18b 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt @@ -19,13 +19,14 @@ import android.view.View import androidx.annotation.IntRange import com.mikepenz.fastadapter.ClickListener import com.mikepenz.fastadapter.FastAdapter +import com.mikepenz.fastadapter.GenericItem import com.mikepenz.fastadapter.IAdapter import com.mikepenz.fastadapter.IItem /** * Created by Allan Wang on 26/12/17. */ -fun <Item : IItem<*>> FastAdapter<Item>.withOnRepeatedClickListener( +fun <Item : GenericItem> FastAdapter<Item>.withOnRepeatedClickListener( count: Int, duration: Long, event: ClickListener<Item> @@ -39,7 +40,7 @@ fun <Item : IItem<*>> FastAdapter<Item>.withOnRepeatedClickListener( * each within [duration] from each other. * Only then will the [event] be fired, and everything will be reset. */ -private class RepeatedClickListener<Item : IItem<*>>( +private class RepeatedClickListener<Item : GenericItem>( @IntRange(from = 1) val count: Int, @IntRange(from = 1) val duration: Long, val event: ClickListener<Item> diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt index f9f06b9..040559c 100644 --- a/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt +++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt @@ -34,6 +34,7 @@ import ca.allanwang.kau.utils.string import ca.allanwang.kau.utils.toDrawable import ca.allanwang.kau.utils.visible import com.mikepenz.fastadapter.FastAdapter +import com.mikepenz.fastadapter.GenericItem import com.mikepenz.fastadapter.IItem import com.mikepenz.fastadapter.listeners.ClickEventHook import com.mikepenz.iconics.typeface.IIcon @@ -51,13 +52,13 @@ class CardIItem( ), ThemableIItem by ThemableIItemDelegate() { companion object { - fun bindClickEvents(fastAdapter: FastAdapter<IItem<*>>) { - fastAdapter.addEventHook(object : ClickEventHook<IItem<*>>() { + fun bindClickEvents(fastAdapter: FastAdapter<GenericItem>) { + fastAdapter.addEventHook(object : ClickEventHook<GenericItem>() { override fun onBindMany(viewHolder: RecyclerView.ViewHolder): List<View>? { return if (viewHolder is ViewHolder) listOf(viewHolder.card, viewHolder.button) else null } - override fun onClick(v: View, position: Int, fastAdapter: FastAdapter<IItem<*>>, item: IItem<*>) { + override fun onClick(v: View, position: Int, fastAdapter: FastAdapter<GenericItem>, item: GenericItem) { if (item !is CardIItem) return with(item.configs) { when (v.id) { |