Created
August 26, 2021 14:49
-
-
Save chydee/29bffc30a52b8b257fd64c84a0540553 to your computer and use it in GitHub Desktop.
OTP Behaviour
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun clearInputs() { | |
val colorStateList = ColorStateList.valueOf(Color.RED) | |
binding.apply { | |
otp1.text.clear() | |
otp2.text.clear() | |
otp3.text.clear() | |
otp4.text.clear() | |
otp5.text.clear() | |
otp6.text.clear() | |
otp1.backgroundTintList = colorStateList | |
otp2.backgroundTintList = colorStateList | |
otp3.backgroundTintList = colorStateList | |
otp4.backgroundTintList = colorStateList | |
otp5.backgroundTintList = colorStateList | |
otp6.backgroundTintList = colorStateList | |
} | |
setDefaultInputFocus() | |
} | |
private fun setDefaultInputFocus() { | |
binding.apply { | |
otp6.clearFocus() | |
otp5.clearFocus() | |
otp4.clearFocus() | |
otp3.clearFocus() | |
otp2.clearFocus() | |
otp1.requestFocus() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A TextWatcher object | |
*/ | |
private val mTextWatcher: TextWatcher = object : TextWatcher { | |
override fun beforeTextChanged(charSequence: CharSequence, i: Int, i2: Int, i3: Int) {} | |
override fun onTextChanged(charSequence: CharSequence, i: Int, i2: Int, i3: Int) {} | |
override fun afterTextChanged(editable: Editable) { | |
// check Fields For Empty Values | |
checkFieldsForEmptyValues() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment