Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun setText(text: String) {
- this.text.text = text
- }
- fun setState(state: State) {
- when (state) {
- State.DISABLED -> {
- image.setImageDrawable(resources.getDrawable(R.drawable.ic_more))
- image.visibility = View.VISIBLE
- progress.visibility = View.GONE
- text.setTextColor(resources.getColor(R.color.color_white_transp))
- }
- State.LOADING -> {
- image.visibility = View.GONE
- progress.visibility = View.VISIBLE
- this.progress.indeterminateDrawable.setColorFilter(resources.getColor(R.color.white), PorterDuff.Mode.MULTIPLY)
- text.setTextColor(resources.getColor(R.color.white))
- }
- State.DONE -> {
- image.setImageDrawable(resources.getDrawable(R.drawable.ic_check_white_24dp))
- image.visibility = View.VISIBLE
- progress.visibility = View.GONE
- text.setTextColor(resources.getColor(R.color.white))
- }
- State.FAILED -> {
- image.setImageDrawable(resources.getDrawable(R.drawable.ic_close_red))
- image.visibility = View.VISIBLE
- progress.visibility = View.GONE
- text.setTextColor(resources.getColor(R.color.red_text))
- }
- }
- }
Add Comment
Please, Sign In to add comment