aboutsummaryrefslogtreecommitdiff
path: root/fastadapter/src/main/kotlin/ca/allanwang
diff options
context:
space:
mode:
Diffstat (limited to 'fastadapter/src/main/kotlin/ca/allanwang')
-rw-r--r--fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt14
-rw-r--r--fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt8
-rw-r--r--fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt4
-rw-r--r--fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt6
-rw-r--r--fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt15
5 files changed, 20 insertions, 27 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 17fd09f..42fe1a2 100644
--- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/AdapterUtils.kt
+++ b/fastadapter/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 <Item : IItem<*, *>> fastAdapter(vararg adapter: IAdapter<out Item>) =
- FastAdapter.with<Item, IAdapter<out Item>>(adapter.toList())!!
+fun <Item : IItem<*>> fastAdapter(vararg adapter: IAdapter<out Item>) =
+ FastAdapter.with<Item, IAdapter<out Item>>(adapter.toList())
-inline fun <reified T : IAdapterExtension<Item>, Item : IItem<*, *>> FastAdapter<Item>.getExtension(): T? =
+inline fun <reified T : IAdapterExtension<Item>, Item : IItem<*>> FastAdapter<Item>.getExtension(): T? =
getExtension(T::class.java)
/**
* Returns selection size, or -1 if selection is disabled
*/
-inline val <Item : IItem<*, *>> IAdapter<Item>.selectionSize: Int
- get() = fastAdapter.getExtension<SelectExtension<Item>, Item>()?.selections?.size ?: -1
+inline val <Item : IItem<*>> IAdapter<Item>.selectionSize: Int
+ get() = fastAdapter?.getExtension<SelectExtension<Item>, Item>()?.selections?.size ?: -1
-inline val <Item : IItem<*, *>> IAdapter<Item>.selectedItems: Set<Item>
- get() = fastAdapter.getExtension<SelectExtension<Item>, Item>()?.selectedItems ?: emptySet()
+inline val <Item : IItem<*>> IAdapter<Item>.selectedItems: Set<Item>
+ get() = fastAdapter?.getExtension<SelectExtension<Item>, 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 152982f..01ac0e5 100644
--- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt
+++ b/fastadapter/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<Item : IItem<*, *>>(
+class FastItemThemedAdapter<Item : IItem<*>>(
textColor: Int? = null,
backgroundColor: Int? = null,
accentColor: Int? = null
@@ -113,11 +113,11 @@ class FastItemThemedAdapter<Item : IItem<*, *>>(
return super.setNewList(items)
}
- private fun injectTheme(items: Collection<IItem<*, *>?>?) {
+ private fun injectTheme(items: Collection<IItem<*>?>?) {
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/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt
index 40b4774..3e7d707 100644
--- a/fastadapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt
+++ b/fastadapter/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 <Item : IItem<*, *>> FastAdapter<Item>.withOnRepeatedClickListener(
+fun <Item : IItem<*>> FastAdapter<Item>.withOnRepeatedClickListener(
count: Int,
duration: Long,
event: OnClickListener<Item>
@@ -37,7 +37,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 : IItem<*>>(
@IntRange(from = 1) val count: Int,
@IntRange(from = 1) val duration: Long,
val event: OnClickListener<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 6e33833..47c465c 100644
--- a/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt
+++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt
@@ -51,13 +51,13 @@ class CardIItem(
), ThemableIItem by ThemableIItemDelegate() {
companion object {
- fun bindClickEvents(fastAdapter: FastAdapter<IItem<*, *>>) {
- fastAdapter.withEventHook(object : ClickEventHook<IItem<*, *>>() {
+ fun bindClickEvents(fastAdapter: FastAdapter<IItem<*>>) {
+ fastAdapter.withEventHook(object : ClickEventHook<IItem<*>>() {
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, adapter: FastAdapter<IItem<*, *>>, item: IItem<*, *>) {
+ override fun onClick(v: View, position: Int, adapter: FastAdapter<IItem<*>>, item: IItem<*>) {
if (item !is CardIItem) return
with(item.configs) {
when (v.id) {
diff --git a/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt b/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt
index c66dc01..34a2b7d 100644
--- a/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt
+++ b/fastadapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt
@@ -15,12 +15,9 @@
*/
package ca.allanwang.kau.iitems
-import android.annotation.SuppressLint
import android.view.View
import androidx.annotation.LayoutRes
import androidx.recyclerview.widget.RecyclerView
-import com.mikepenz.fastadapter.IClickable
-import com.mikepenz.fastadapter.IItem
import com.mikepenz.fastadapter.items.AbstractItem
/**
@@ -29,14 +26,10 @@ import com.mikepenz.fastadapter.items.AbstractItem
* Kotlin implementation of the [AbstractItem] to make things shorter
* If only one iitem type extends the given [layoutRes], you may use it as the type and not worry about another id
*/
-open class KauIItem<Item, VH : RecyclerView.ViewHolder>(
- @param:LayoutRes private val layoutRes: Int,
+open class KauIItem<VH : RecyclerView.ViewHolder>(
+ @param:LayoutRes override val layoutRes: Int,
private val viewHolder: (v: View) -> VH,
- private val type: Int = layoutRes
-) : AbstractItem<Item, VH>() where Item : IItem<*, *>, Item : IClickable<*> {
- @SuppressLint("ResourceType")
- final override fun getType(): Int = type
-
+ override val type: Int = layoutRes
+) : AbstractItem<VH>() {
final override fun getViewHolder(v: View): VH = viewHolder(v)
- final override fun getLayoutRes(): Int = layoutRes
}