Skip to content

Instantly share code, notes, and snippets.

@Marchuck
Created June 14, 2018 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marchuck/7be9593c5e9d89279b0d68a37a6834e7 to your computer and use it in GitHub Desktop.
Save Marchuck/7be9593c5e9d89279b0d68a37a6834e7 to your computer and use it in GitHub Desktop.
class SwapiAdapter(diffCallback: DiffUtil.ItemCallback<Person?>)
: PagedListAdapter<Person, SwapiPersonViewHolder>(diffCallback) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SwapiPersonViewHolder {
val inflater = LayoutInflater.from(parent.context)
val binding = DataBindingUtil.inflate<ItemSwapiPersonBinding>(
inflater, R.layout.item_swapi_person, parent, false)
return SwapiPersonViewHolder(binding)
}
override fun onBindViewHolder(holder: SwapiPersonViewHolder, position: Int) {
val item = getItem(position)
holder.bind(item)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment