Skip to content

Instantly share code, notes, and snippets.

@vontell
Last active January 30, 2018 19:03
Show Gist options
  • Save vontell/4a420805cfe6e797426dd2b838e150fd to your computer and use it in GitHub Desktop.
Save vontell/4a420805cfe6e797426dd2b838e150fd to your computer and use it in GitHub Desktop.
002 OnChipRemoveListener
...
// METHODS AND INTERFACE FOR THE CHIP REMOVAL LISTENER -------------------------------------------------------
/**
* Interface definition for a callback to be invoked when a ChipView remove button is clicked.
*/
interface OnChipRemovedListener {
/**
* Called when a ChipView remove button has been clicked
*
* @param v The ChipView that the user interacted with.
*/
fun onRemove(v: View)
}
/**
* Sets the OnClickListener or function to be called when the remove / close
* button on the ChipView is clicked
* @param listener The listener to be executed when the close button is clicked
*/
fun setOnRemoveListener(listener: OnChipRemovedListener?) {
removeListener = listener
displayRemoveIcon()
}
fun setOnRemoveListener(listener: (v : View) -> Unit) {
removeListener = object : OnChipRemovedListener {
override fun onRemove(v: View) {
listener(v)
}
}
displayRemoveIcon()
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment