Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexOutOfBoundsException #6

Closed
olegosipenko opened this issue Jan 28, 2016 · 13 comments
Closed

IndexOutOfBoundsException #6

olegosipenko opened this issue Jan 28, 2016 · 13 comments
Assignees
Labels
Milestone

Comments

@olegosipenko
Copy link

How to reproduce: type some input, bacskpace, type - backspace and so on. After couple of iterations there is a crash

FATAL EXCEPTION: main
Process: com.thrd.maskededitbox, PID: 11763
java.lang.IndexOutOfBoundsException: replace (15 ... 16) ends beyond length 15
at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1090)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:498)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:492)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:491)
at com.github.pinball83.maskededittext.MaskedEditText$MaskedInputFilter.filter(MaskedEditText.java:327)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:502)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:492)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:491)
at android.text.method.NumberKeyListener.onKeyDown(NumberKeyListener.java:121)
at android.widget.TextView.doKeyDown(TextView.java:6095)
at android.widget.TextView.onKeyDown(TextView.java:5908)
at android.view.KeyEvent.dispatch(KeyEvent.java:2640)
at android.view.View.dispatchKeyEvent(View.java:9240)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.widget.ScrollView.dispatchKeyEvent(ScrollView.java:379)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1640)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2395)
at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1727)
at android.app.Activity.dispatchKeyEvent(Activity.java:2731)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:50)
at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:224)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2310)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4127)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4089)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3787)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3844)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5922)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5896)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5857)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3434)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

@pinball83
Copy link
Owner

Could you give mask example to reproduce bug? Also it will be helpful if you point which position you made input. Thanks

@pinball83 pinball83 added the bug label Feb 1, 2016
@pinball83 pinball83 self-assigned this Feb 1, 2016
@pinball83 pinball83 added this to the 1.0.4 milestone Feb 1, 2016
@olegosipenko
Copy link
Author

It's your sample, I didn't make any alterations in code - I just typed and erased

@dschuermann
Copy link

We also have this problem!

@SagarPanwala
Copy link

👍 I'm also having same problem

@richbarruet
Copy link

I have the same problem
If I try to delete a "word" (by holding backspace), it always remove all character (instead of replacing them with whitespaces an mask), then crash when I read
It can also happen if I delete single characters, but it's more random

@Nublo
Copy link
Contributor

Nublo commented May 23, 2016

Main problem here was when you press back and don't release it. First deletion is happening one by one symbol. And then at some moment off time android begin to remove pack of symbols( > 1).
And current implementation is not handling this use case. I fix this in this pull request.

@richbarruet
Copy link

Thanks
Will it take cares of the other's crashes? (not sure if it's the same problem)

@Nublo
Copy link
Contributor

Nublo commented May 23, 2016

@richbarruet I am not sure now about other crashes, but i will investigate this problem and take care of them if they appear.

@dimmduh
Copy link

dimmduh commented Jan 18, 2017

The problem is still exists :(
But you can install fixed version from @Nublo repo via gradle
compile 'com.github.Nublo:masked-edittext:eeb70445d313647870a9fc398d997a6a65e1d673'

@miroslavign
Copy link

+1 on collecting this issue and For @Nublo for a patch and distribution

@ColinWa
Copy link

ColinWa commented Feb 1, 2017

I experienced this fatal exception too. i used MaskedEditText together with TextInputLayout in Fragments, everytime in enter numbers in the field exceeding the limit. The fields that caused this problem had a TextWatcher directly on MaskEditText field inside the TextInputLayout as follows:

CODE:

postalCodeEditText.addTextChangedListener(new TextWatcher() {
      // ...
});

To mitigate the problem :

  1. Get the TextInputLayout
    CODE:
    postalCodeTextInputLayout = (TextInputLayout) getActivity().findViewById(R.id.TextInputLayout_postalCode);

  2. Set the TextWatcher on the TextInputLayout.getEditText()
    CODE:
    postalCodeTextInputLayout.getEditText().addTextChangedListener(new TextWatcher() { //... });

This was after i tried @Nublo's Fork which did not fix this either
This might be another dimension to the problem as there may still be another cause other than the one i mentioned.

@miroslavign
Copy link

@ColinWa yes, now I see this problem again. Gonna try ytour solution and give feedback. Hopefully, it will be thumbs up :)

@miroslavign
Copy link

@ColinWa even with this latest fix of yours, it still happens to me on some devices :(

pinball83 added a commit that referenced this issue Jan 11, 2018
Fix remove symbols when removing more than one symbol. Close #6.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants