Skip to content

Instantly share code, notes, and snippets.

@Shivamdhuria
Last active August 16, 2020 21:14
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 Shivamdhuria/808e2a0cf0b2e3f22b86d5dc067a8053 to your computer and use it in GitHub Desktop.
Save Shivamdhuria/808e2a0cf0b2e3f22b86d5dc067a8053 to your computer and use it in GitHub Desktop.
class RecyclerAdapter(val callback: RecyclerViewClickListener) : ListAdapter<Dog, RecyclerAdapter.DogViewHolder>(UserDataAdapterListDiff()) {
interface RecyclerViewClickListener {
fun onItemClicked(view: View, dog: Dog)
}
....inner class DogViewHolder(override val containerView: View) : RecyclerView.ViewHolder(containerView), LayoutContainer {
fun bind(dog: Dog) {
with(containerView) {
breed_name.text = dog.breed?.capitalize()
dog.imageUrl?.let { it1 -> ImageLoader.loadImage(containerView.context, it1, image_thumbnail) }
//Set the transition name for each Item Container
ViewCompat.setTransitionName(item_container, dog.imageUrl)
// Return the VIEW and the DOG object when clicked.
setOnClickListener { callback.onItemClicked(item_container, dog) }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment