Created
January 14, 2019 14:30
-
-
Save tfcporciuncula/64ac3373bb60aa3f5eab7c608737ae5e to your computer and use it in GitHub Desktop.
DataBindingAdapter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class DataBindingAdapter<T>(diffCallback: DiffUtil.ItemCallback<T>) : | |
ListAdapter<T, DataBindingViewHolder<T>>(diffCallback) { | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DataBindingViewHolder<T> { | |
val layoutInflater = LayoutInflater.from(parent.context) | |
val binding = DataBindingUtil.inflate<ViewDataBinding>(layoutInflater, viewType, parent, false) | |
return DataBindingViewHolder(binding) | |
} | |
override fun onBindViewHolder(holder: DataBindingViewHolder<T>, position: Int) = holder.bind(getItem(position)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment