Skip to content

Instantly share code, notes, and snippets.

@myeonginwoo
Created October 22, 2018 16:32
Show Gist options
  • Select an option

  • Save myeonginwoo/0a645eee77cf06fb9e99bc130b2404a2 to your computer and use it in GitHub Desktop.

Select an option

Save myeonginwoo/0a645eee77cf06fb9e99bc130b2404a2 to your computer and use it in GitHub Desktop.
override fun onUpdatedItem(oldItem: Item, newItem: Item) {
tv_item.text = "${getItemStr(oldItem)} -> ${getItemStr(newItem)}"
iv_item.setBackgroundColor(ContextCompat.getColor(this, when (newItem) {
ITEM_A -> R.color.red
ITEM_B -> R.color.green
ITEM_C -> R.color.blue
}))
}
private fun getItemStr(item: Item): String = getString(when (item) {
ITEM_A -> R.string.a
ITEM_B -> R.string.b
ITEM_C -> R.string.c
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment