Skip to content

Instantly share code, notes, and snippets.

@klukwist
Created April 5, 2020 13:18
Show Gist options
  • Save klukwist/fa23ea499d10ca250f1158ec32d750ee to your computer and use it in GitHub Desktop.
Save klukwist/fa23ea499d10ca250f1158ec32d750ee to your computer and use it in GitHub Desktop.
class ClassicAdapter : RecyclerView.Adapter<ClassicHolder>() {
private val viewModel = PersonItemViewModel()
private val data: List<Person>
get() = viewModel.data
fun setData(persons: List<Person>) {
viewModel.data = persons
notifyDataSetChanged()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ClassicHolder =
ClassicHolder.create(parent)
override fun getItemCount(): Int = data.size
override fun onBindViewHolder(holder: ClassicHolder, position: Int) {
holder.bind(viewModel, position)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment