Skip to content

Instantly share code, notes, and snippets.

@nitrico
Last active April 1, 2017 16:49
Embed
What would you like to do?
val tweetType = Type<ItemTweetBinding>(R.layout.item_tweet)
// all these methods are optional:
.onCreate { println("Created #${it.adapterPosition}: ${it.binding.item}") }
.onBind { println("Bound #${it.adapterPosition}: ${it.binding.item}") }
.onRecycle { println("Recycled #${it.adapterPosition}: ${it.binding.item}") }
.onClick { toast("Clicked #${it.adapterPosition}: ${it.binding.item}") }
.onLongClick { toast("Long-clicked #${it.adapterPosition}: ${it.binding.item}") }
LastAdapter(items, BR.item)
.map<Tweet>(tweetType)
// you can also define the callbacks directly in the map call:
.map<User, ItemUserBinding>(R.layout.item_user) {
// again, all the methods are optional:
onCreate { println("Created #${it.adapterPosition}: ${it.binding.item}") }
onBind { println("Bound #${it.adapterPosition}: ${it.binding.item}") }
onRecycle { println("Recycled #${it.adapterPosition}: ${it.binding.item}") }
onClick { toast("Clicked #${it.adapterPosition}: ${it.binding.item}") }
onLongClick { toast("Long-clicked #${it.adapterPosition}: ${it.binding.item}") }
}
.into(list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment