Slide 18
Slide 18 text
fun setCurrentValue(newValue: Int) {
if (newValue in MIN_VALUE#..MAX_VALUE) {
textInputLayout.text = newValue.toString()
} else {
textInputLayout.text = newValue.coerceIn(MIN_VALUE, MAX_VALUE).toString()
}
}
private const val MAX_VALUE = 99
private const val MIN_VALUE = 8
fun setCurrentValue(newValue: Int) {
if (newValue > MAX_VALUE #|| newValue < MIN_VALUE) {
val valueToSet = if (newValue > MAX_VALUE) MAX_VALUE else MIN_VALUE
textInputLayout.setText(valueToSet.toString())
return
} else {
textInputLayout.setText(newValue.toString())
}
}
fun setCurrentValue(newValue: Int) {
val text = newValue
.takeIf { newValue in MIN_VALUE#..MAX_VALUE }
#?: newValue.coerceIn(MIN_VALUE, MAX_VALUE)
textInputLayout.text = text.toString()
}