-
Notifications
You must be signed in to change notification settings - Fork 7
/
MultiLayoutAdapter.kt
32 lines (27 loc) · 1.16 KB
/
MultiLayoutAdapter.kt
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
26
27
28
29
30
31
32
package com.kuky.comvvmhelper.ui.adapter
import com.kk.android.comvvmhelper.listener.MultiLayoutImp
import com.kk.android.comvvmhelper.ui.BaseMultiLayoutAdapter
import com.kk.android.comvvmhelper.ui.BaseRecyclerViewHolder
import com.kuky.comvvmhelper.R
import com.kuky.comvvmhelper.databinding.RecyclerIntItemBinding
import com.kuky.comvvmhelper.databinding.RecyclerStringItemBinding
import com.kuky.comvvmhelper.entity.IntLayoutEntity
import com.kuky.comvvmhelper.entity.StringLayoutEntity
/**
* @author kuky.
* @description
*/
class MultiLayoutAdapter : BaseMultiLayoutAdapter() {
init {
registerAdapterItems(0xFF01, R.layout.recycler_int_item)
registerAdapterItems(0xFF02, R.layout.recycler_string_item)
}
override fun setVariable(data: MultiLayoutImp, holder: BaseRecyclerViewHolder, dataPosition: Int, layoutPosition: Int) {
when (data) {
is IntLayoutEntity ->
holder.viewDataBinding<RecyclerIntItemBinding>()?.text = "IntLayoutItem #$dataPosition#"
is StringLayoutEntity ->
holder.viewDataBinding<RecyclerStringItemBinding>()?.text = "StringLayoutItem #$dataPosition#"
}
}
}