Fix crash in registration v2 country code drop down.
This commit is contained in:
parent
c8a9759eba
commit
4151d123cd
2 changed files with 10 additions and 2 deletions
|
@ -186,8 +186,11 @@ class EnterPhoneNumberV2Fragment : LoggingFragment(R.layout.fragment_registratio
|
|||
|
||||
private fun initializeInputFields() {
|
||||
binding.countryCode.editText?.addTextChangedListener { s ->
|
||||
val countryCode: Int = s.toString().toInt()
|
||||
fragmentViewModel.setCountry(countryCode)
|
||||
val sanitized = s.toString().filter { c -> c.isDigit() }
|
||||
if (sanitized.isNotNullOrBlank()) {
|
||||
val countryCode: Int = sanitized.toInt()
|
||||
fragmentViewModel.setCountry(countryCode)
|
||||
}
|
||||
}
|
||||
|
||||
phoneNumberInputLayout.addTextChangedListener {
|
||||
|
|
|
@ -63,6 +63,11 @@ class EnterPhoneNumberV2ViewModel : ViewModel() {
|
|||
|
||||
fun setCountry(digits: Int) {
|
||||
val matchingIndex = countryCodeToAdapterIndex(digits)
|
||||
if (matchingIndex == -1) {
|
||||
Log.d(TAG, "Invalid country code specified $digits")
|
||||
return
|
||||
}
|
||||
|
||||
store.update {
|
||||
it.copy(countryPrefixIndex = matchingIndex)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue