Created
January 30, 2018 18:44
-
-
Save vontell/dbc166d8e82e863e4979c01222d0bd06 to your computer and use it in GitHub Desktop.
002 Displaying ChipView Properties
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 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