Skip to content

Instantly share code, notes, and snippets.

@rygelouv
Last active April 13, 2018 10:04
Show Gist options
  • Select an option

  • Save rygelouv/2448f1e4799b6225a54eb96766e7169f to your computer and use it in GitHub Desktop.

Select an option

Save rygelouv/2448f1e4799b6225a54eb96766e7169f to your computer and use it in GitHub Desktop.
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))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment