Last active
January 30, 2018 19:03
-
-
Save vontell/4a420805cfe6e797426dd2b838e150fd to your computer and use it in GitHub Desktop.
002 OnChipRemoveListener
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
... | |
// 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