Skip to content

Instantly share code, notes, and snippets.

@vontell
Created January 30, 2018 18:44
Show Gist options
  • Save vontell/dbc166d8e82e863e4979c01222d0bd06 to your computer and use it in GitHub Desktop.
Save vontell/dbc166d8e82e863e4979c01222d0bd06 to your computer and use it in GitHub Desktop.
002 Displaying ChipView Properties
...
// METHODS FOR PROPERLY DISPLAYING THE SET INFORMATION -----------------------------------------
/**
* Displays a new ChipView label by setting the layout's text and reloading the view.
*/
private fun displayText() {
if (text != null) {
chip_text.text = text
} else {
chip_text.text = ""
}
chip_text.invalidate()
chip_text.requestLayout()
}
/**
* Displays a new ChipView image by setting the layout's image and reloading the view.
*/
private fun displayImage() {
when {
imageURL != null -> {
chip_image.visibility = View.VISIBLE
chip_image.load(imageURL!!)
}
imageResource != null -> {
chip_image.visibility = View.VISIBLE
chip_image.setImageDrawable(imageResource)
}
else -> {
chip_image.visibility = View.GONE
chip_image.setImageDrawable(null)
}
}
chip_image.invalidate()
chip_image.requestLayout()
}
/**
* Displays the remove icon if a listener is available
*/
private fun displayRemoveIcon() {
if (removeListener != null) {
chip_close.visibility = View.VISIBLE
chip_close.setOnClickListener {
removeListener!!.onRemove(this)
}
} else {
chip_close.visibility = View.GONE
chip_close.setOnClickListener {}
}
chip_close.invalidate()
chip_close.requestLayout()
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment