RedMadRobot / input-mask-android

User input masking library repo.
MIT License
1.21k stars 114 forks source link

IndexOutOfBoundsException: setSpan (17 ... 17) ends beyond length 2 #114

Closed SteelOscar closed 2 years ago

SteelOscar commented 3 years ago

Describe the bug

I use MaskedTextChangedListener to format the phone number, the mask is +7 ([000]) [000] - [00] - [00]. With normal manual text input, everything works fine, but if you use the setTex method, the listener throws an exception

java.lang.IndexOutOfBoundsException: setSpan (17 ... 17) ends beyond length 2 at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1325) at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:684) at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:676) at android.text.Selection.setSelection(Selection.java:94) at android.text.Selection.setSelection(Selection.java:78) at android.text.Selection.setSelection(Selection.java:153) at android.widget.EditText.setSelection(EditText.java:136) at com.redmadrobot.inputmask.MaskedTextChangedListener.afterTextChanged(MaskedTextChangedListener.kt:193) at android.widget.TextView.sendAfterTextChanged(TextView.java:10551) at android.widget.TextView.setText(TextView.java:6278) at android.widget.TextView.setText(TextView.java:6097) at android.widget.EditText.setText(EditText.java:122)

SteelOscar commented 3 years ago

bug fixes MaskedTextChangedListener

Снимок экрана 2021-09-17 в 13 37 41
SteelOscar commented 2 years ago

fix it in new version of the library

taflanidi commented 2 years ago

Fixed in 6.1.0.

apolloandroid commented 1 year ago

Why 6.1.0 is not released?

osipxd commented 1 year ago

@apolloandroid, 6.1.0 is released on JitPack