blob: 335b89c0139436d9a3365d48853244b91cf7c3fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
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
}
|