diff options
author | Allan Wang <me@allanwang.ca> | 2017-07-07 15:29:35 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-07-07 15:29:35 -0700 |
commit | f0237ca8dd0e4ad4c1873f5951099cf03b5f0dd1 (patch) | |
tree | 5c89f04b3f59c2efeab28826f0559bdd326dbbdf | |
parent | 3dd7fceba150b80fa1cba8102ee1b3f1bbf2948e (diff) | |
download | kau-f0237ca8dd0e4ad4c1873f5951099cf03b5f0dd1.tar.gz kau-f0237ca8dd0e4ad4c1873f5951099cf03b5f0dd1.tar.bz2 kau-f0237ca8dd0e4ad4c1873f5951099cf03b5f0dd1.zip |
Update kauIItem for optional id
4 files changed, 7 insertions, 8 deletions
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<Item, VH : RecyclerView.ViewHolder>( - 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<Item, VH>() 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<SearchItem, SearchItem.ViewHolder>( - R.id.kau_item_search, R.layout.kau_search_iitem, - {ViewHolder(it)} + { ViewHolder(it) }, + R.id.kau_item_search ) { companion object { diff --git a/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImageItem.kt b/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImageItem.kt index 7b55c58..0b13a30 100644 --- a/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImageItem.kt +++ b/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImageItem.kt @@ -10,9 +10,7 @@ import ca.allanwang.kau.utils.bindView * Created by Allan Wang on 2017-07-04. */ class ImageItem(data:String) - : KauIItem<ImageItem, ImageItem.ViewHolder>(R.layout.kau_iitem_card, R.layout.kau_iitem_card, { ViewHolder(it) }) { - - + : KauIItem<ImageItem, ImageItem.ViewHolder>(R.layout.kau_iitem_card, { ViewHolder(it) }) { class ViewHolder(v: View) : RecyclerView.ViewHolder(v) { val image: ImageView by bindView(R.id.kau_image) diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt index c1b1865..21aa713 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt @@ -12,7 +12,7 @@ import ca.allanwang.kau.utils.hasPermission * Created by Allan Wang on 2017-07-03. */ class PermissionCheckbox(val permission: String) : KauIItem<PermissionCheckbox, PermissionCheckbox.ViewHolder>( - R.layout.permission_checkbox, R.layout.permission_checkbox, { ViewHolder(it) }) { + R.layout.permission_checkbox, { ViewHolder(it) }) { override fun bindView(holder: ViewHolder, payloads: MutableList<Any>?) { super.bindView(holder, payloads) |