Skip to content

Instantly share code, notes, and snippets.

@nitrico
Last active April 1, 2017 16:49
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 nitrico/88d0e3c78e8a84951e110b3b7d63033c to your computer and use it in GitHub Desktop.
Save nitrico/88d0e3c78e8a84951e110b3b7d63033c to your computer and use it in GitHub Desktop.
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