From f0237ca8dd0e4ad4c1873f5951099cf03b5f0dd1 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Fri, 7 Jul 2017 15:29:35 -0700 Subject: Update kauIItem for optional id --- core/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt | 5 +++-- core/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'core/src') diff --git a/core/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt b/core/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt index 00b165c..d8567c4 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt @@ -11,11 +11,12 @@ 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( - private val type: Int, @param:LayoutRes private val layoutRes: Int, - private val viewHolder: (v: View) -> VH + private val viewHolder: (v: View) -> VH, + private val type: Int = layoutRes ) : AbstractItem() where Item : IItem<*, *>, Item : IClickable<*> { override final fun getType(): Int = type override final fun getViewHolder(v: View): VH = viewHolder(v) diff --git a/core/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt b/core/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt index ac8ec2e..96dc789 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt @@ -29,9 +29,9 @@ class SearchItem(val key: String, val iicon: IIcon? = GoogleMaterial.Icon.gmd_search, val image: Drawable? = null ) : KauIItem( - R.id.kau_item_search, R.layout.kau_search_iitem, - {ViewHolder(it)} + { ViewHolder(it) }, + R.id.kau_item_search ) { companion object { -- cgit v1.2.3