Skip to content

MultiType ListAdapter를 쉽게 사용하기 위한 BaseListAdapter입니다.

License

Notifications You must be signed in to change notification settings

myung6024/BaseListAdapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample

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)
}

About

MultiType ListAdapter를 쉽게 사용하기 위한 BaseListAdapter입니다.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages