aboutsummaryrefslogtreecommitdiff
path: root/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt
diff options
context:
space:
mode:
Diffstat (limited to 'adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt')
-rw-r--r--adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt24
1 files changed, 24 insertions, 0 deletions
diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt
new file mode 100644
index 0000000..d8567c4
--- /dev/null
+++ b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt
@@ -0,0 +1,24 @@
+package ca.allanwang.kau.iitems
+
+import android.support.annotation.LayoutRes
+import android.support.v7.widget.RecyclerView
+import android.view.View
+import com.mikepenz.fastadapter.IClickable
+import com.mikepenz.fastadapter.IItem
+import com.mikepenz.fastadapter.items.AbstractItem
+
+/**
+ * Created by Allan Wang on 2017-07-03.
+ *
+ * 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,
+ private val viewHolder: (v: View) -> VH,
+ private val type: Int = layoutRes
+) : AbstractItem<Item, VH>() where Item : IItem<*, *>, Item : IClickable<*> {
+ override final fun getType(): Int = type
+ override final fun getViewHolder(v: View): VH = viewHolder(v)
+ override final fun getLayoutRes(): Int = layoutRes
+} \ No newline at end of file