sealed class SampleListItem(override val viewType: ViewType) : ListItem {
data class Sample(
val id: String
) : SampleListItem(ViewType.SAMPLE1)
data class Sample2(
val name: String
) : SampleListItem(ViewType.SAMPLE2)
enum class ViewType {
SAMPLE1,
SAMPLE2
}
}
class SampleAdapter : MultiTypeListAdapter<SampleListItem, SampleListItem.ViewType>({
when (it) {
is SampleListItem.Sample -> it.id
is SampleListItem.Sample2 -> it.name
}
}) {
override fun onCreateViewHolder(viewType: SampleListItem.ViewType, parent: ViewGroup): CommonViewHolder<SampleListItem> {
when (viewType) {
SampleListItem.ViewType.SAMPLE1 -> TODO()
SampleListItem.ViewType.SAMPLE2 -> TODO()
}
}
private class SampleViewHolder(binding: ViewBinding) : CommonViewHolder<SampleListItem.Sample>(binding) {
override fun onBindView(item: SampleListItem.Sample) {
TODO()
}
}
private class Sample2ViewHolder(binding: ViewBinding) : ViewOnlyViewHolder(binding)
}
-
Notifications
You must be signed in to change notification settings - Fork 0
MultiType ListAdapter를 쉽게 사용하기 위한 BaseListAdapter입니다.
License
myung6024/BaseListAdapter
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
MultiType ListAdapter를 쉽게 사용하기 위한 BaseListAdapter입니다.
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published