Skip to content

Instantly share code, notes, and snippets.

@klukwist
Created April 5, 2020 13:21
Show Gist options
  • Save klukwist/f5eecbb4d976055a423144c745741086 to your computer and use it in GitHub Desktop.
Save klukwist/f5eecbb4d976055a423144c745741086 to your computer and use it in GitHub Desktop.
class ClassicHolder(private val binding: ItemPersonBinding) : RecyclerView.ViewHolder(binding.root) {
fun bind(viewModel: PersonItemViewModel, position: Int) {
binding.setVariable(BR.viewModel, viewModel)
binding.setVariable(BR.position, position)
binding.executePendingBindings()
}
companion object {
fun create(parent: ViewGroup): ClassicHolder {
val inflater = LayoutInflater.from(parent.context)
val binding: ItemPersonBinding =
DataBindingUtil.inflate(inflater, R.layout.item_person, parent, false)
return ClassicHolder(binding)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment