Last active
August 16, 2020 21:14
-
-
Save Shivamdhuria/808e2a0cf0b2e3f22b86d5dc067a8053 to your computer and use it in GitHub Desktop.
This file contains 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
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