when(currentButtonState){
ButtonState.GONE -> setupGoneButton(duration)
ButtonState.BEGIN -> setupStartButton(duration)
ButtonState.PROGRESS -> setupProgress()
ButtonState.SUCCESS -> setupSuccessButton()
}
when(currentButtonState){
ButtonState.GONE -> setupGoneButton(duration)
ButtonState.BEGIN -> setupStartButton(duration)
ButtonState.PROGRESS -> setupProgress()
ButtonState.SUCCESS -> setupSuccessButton()
}
val iconId = when {
link.contains("twitter", true) -> R.drawable.twitter
link.contains("facebook", true) -> R.drawable.facebook
link.contains("linkedin", true) -> R.drawable.linkedin
link.contains("pinterest", true) -> R.drawable.pinterest
link.contains("skype", true) -> R.drawable.skype
else -> R.drawable.blank
}
when (x) {
in 1..10 -> print("x is in the range")
in validNumbers -> print("x is valid")
!in 10..20 -> print("x is outside the range")
else -> print("none of the above")
}
fun transform(color: String): Int = when (color) {
"Red" -> Color.RED
"Green" -> Color.GREEN
"Blue" -> Color.BLUE
else -> Color.TRANSPARENT
}
// Instance type checking
val item = viewModels.get(position)
when(item){
is HeaderViewModel -> return HeaderViewModel.viewType
is RequestButtonViewModel -> return RequestButtonViewModel.viewType
is MoreViewModel -> return MoreViewModel.viewType
is EmptyViewModel -> return EmptyViewModel.viewType
is WhosOutItemViewModel -> return WhosOutItemViewModel.viewType
is FooterViewModel -> return FooterViewModel.viewType
}