Closed adcaine closed 7 years ago
Thanks for the report! I have a fix in the works which should be pushed up to the 'next' branch shortly.
I can't match the expected behavior of forcing a partially formatted number like "$0." to appear, as that's not how the formatter works and would require some hackiness peppered around the formatting code, but since this error also occurs with '," and "-" characters, I've simply stopped the code causing the crash (the cursor placement code) from executing if the string length is zero. Perhaps not ideal, but it's what we've got.
On Sat, Sep 23, 2017 at 8:10 PM, Allan Caine notifications@github.com wrote:
Reproduction Steps:
In the sample app,
- Click in Reset button.
- Type a decimal point in the first field
Expected
- The string "$0." appears in the field
Actual
The app crashes.
09-23 20:08:43.367 14567-14567/com.blackcat.currencyedittexttester E/AndroidRuntime: FATAL EXCEPTION: main Process: com.blackcat.currencyedittexttester, PID: 14567 java.lang.IndexOutOfBoundsException: setSpan (1 ... 1) ends beyond length 0 at android.text.SpannableStringBuilder.checkRange( SpannableStringBuilder.java:1265) at android.text.SpannableStringBuilder.setSpan( SpannableStringBuilder.java:684) at android.text.SpannableStringBuilder.setSpan( SpannableStringBuilder.java:677) at android.text.Selection.setSelection(Selection.java:76) at android.widget.TextView.semSetSelection(TextView.java:11458) at android.widget.TextView.semSetSelection(TextView.java:11472) at android.widget.EditText.setSelection(EditText.java:124) at com.blackcat.currencyedittext.CurrencyTextWatcher.afterTextChanged( CurrencyTextWatcher.java:68) at android.widget.TextView.sendAfterTextChanged(TextView.java:9443)
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/BlacKCaT27/CurrencyEditText/issues/37, or mute the thread https://github.com/notifications/unsubscribe-auth/AE_54d4bpVqiPHsDMYFP06QXXNgH4gdSks5slZ31gaJpZM4PhuXl .
Fixed in version 2.0.2
I think your intended approach is fine. 😊 Allan
On Sat, Sep 23, 2017 at 10:20 PM Josh Kitchens notifications@github.com wrote:
Thanks for the report! I have a fix in the works which should be pushed up to the 'next' branch shortly.
I can't match the expected behavior of forcing a partially formatted number like "$0." to appear, as that's not how the formatter works and would require some hackiness peppered around the formatting code, but since this error also occurs with '," and "-" characters, I've simply stopped the code causing the crash (the cursor placement code) from executing if the string length is zero. Perhaps not ideal, but it's what we've got.
On Sat, Sep 23, 2017 at 8:10 PM, Allan Caine notifications@github.com wrote:
Reproduction Steps:
In the sample app,
- Click in Reset button.
- Type a decimal point in the first field
Expected
- The string "$0." appears in the field
Actual
The app crashes.
09-23 20:08:43.367 14567-14567/com.blackcat.currencyedittexttester E/AndroidRuntime: FATAL EXCEPTION: main Process: com.blackcat.currencyedittexttester, PID: 14567 java.lang.IndexOutOfBoundsException: setSpan (1 ... 1) ends beyond length 0 at android.text.SpannableStringBuilder.checkRange( SpannableStringBuilder.java:1265) at android.text.SpannableStringBuilder.setSpan( SpannableStringBuilder.java:684) at android.text.SpannableStringBuilder.setSpan( SpannableStringBuilder.java:677) at android.text.Selection.setSelection(Selection.java:76) at android.widget.TextView.semSetSelection(TextView.java:11458) at android.widget.TextView.semSetSelection(TextView.java:11472) at android.widget.EditText.setSelection(EditText.java:124) at com.blackcat.currencyedittext.CurrencyTextWatcher.afterTextChanged( CurrencyTextWatcher.java:68) at android.widget.TextView.sendAfterTextChanged(TextView.java:9443)
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/BlacKCaT27/CurrencyEditText/issues/37, or mute the thread < https://github.com/notifications/unsubscribe-auth/AE_54d4bpVqiPHsDMYFP06QXXNgH4gdSks5slZ31gaJpZM4PhuXl
.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/BlacKCaT27/CurrencyEditText/issues/37#issuecomment-331682190, or mute the thread https://github.com/notifications/unsubscribe-auth/ADtsQ1A4TKJH5sv4ktREBx03gh3R7yyvks5slbx6gaJpZM4PhuXl .
Reproduction Steps:
In the sample app,
Expected
Actual
The app crashes.
09-23 20:08:43.367 14567-14567/com.blackcat.currencyedittexttester E/AndroidRuntime: FATAL EXCEPTION: main Process: com.blackcat.currencyedittexttester, PID: 14567 java.lang.IndexOutOfBoundsException: setSpan (1 ... 1) ends beyond length 0 at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1265) at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:684) at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:677) at android.text.Selection.setSelection(Selection.java:76) at android.widget.TextView.semSetSelection(TextView.java:11458) at android.widget.TextView.semSetSelection(TextView.java:11472) at android.widget.EditText.setSelection(EditText.java:124) at com.blackcat.currencyedittext.CurrencyTextWatcher.afterTextChanged(CurrencyTextWatcher.java:68) at android.widget.TextView.sendAfterTextChanged(TextView.java:9443)