Skip to content

Instantly share code, notes, and snippets.

@javikin
Created December 4, 2017 15:01
Show Gist options
  • Save javikin/f73688e44dfa2b54cef50ab81f8cc3da to your computer and use it in GitHub Desktop.
Save javikin/f73688e44dfa2b54cef50ab81f8cc3da to your computer and use it in GitHub Desktop.
class MyAdapter(val mDataset: Array<String>,
val itemClickListener: (String) -> Unit,
val itemClickButtonListener: (String) -> Unit) :
RecyclerView.Adapter<MyAdapter.ViewHolder>() {
...
class ViewHolder(var mView: View) : RecyclerView.ViewHolder(mView) {
fun bind(item: String,
itemClickListener: (String) -> Unit,
itemClickButtonListener: (String) -> Unit) = with(itemView) {
itemView.button_ok.setOnClickListener { itemClickButtonListener(item) }
setOnClickListener { itemClickListener(item) }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment