hanggrian / socialview

Android TextView and EditText with hashtag, mention, and hyperlink support
http://hanggrian.com/socialview/
Apache License 2.0
324 stars 81 forks source link

App crash when deleting #10

Closed CripyIce closed 7 years ago

CripyIce commented 7 years ago

Hi there, First of all, amazing library!! But wanted to know what can i do with a crash i am handling right now with the EditText (SocialAutoCompleteTextView)? When i mention someone at the beginning and going to the middle of the word and start deleting it crashes with this error:

java.lang.IndexOutOfBoundsException: charAt: -1 < 0 at android.text.SpannableStringBuilder.charAt(SpannableStringBuilder.java:121) at com.hendraanggrian.socialview.SociableViewImpl.onTextChanged(SociableViewImpl.java:291) at android.widget.TextView.sendOnTextChanged(TextView.java:9332) at android.widget.TextView.handleTextChanged(TextView.java:9419) at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:11875) at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:1252) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:573) at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:229) at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:227) at android.text.method.BaseKeyListener.backspaceOrForwardDelete(BaseKeyListener.java:370) at android.text.method.BaseKeyListener.backspace(BaseKeyListener.java:71) at android.text.method.BaseKeyListener.onKeyDown(BaseKeyListener.java:479) at android.text.method.QwertyKeyListener.onKeyDown(QwertyKeyListener.java:362) at android.text.method.TextKeyListener.onKeyDown(TextKeyListener.java:141) at android.widget.TextView.doKeyDown(TextView.java:7302) at android.widget.TextView.onKeyDown(TextView.java:7079) at android.widget.AutoCompleteTextView.onKeyDown(AutoCompleteTextView.java:831) at android.view.KeyEvent.dispatch(KeyEvent.java:2688) at android.view.View.dispatchKeyEvent(View.java:11465) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1797) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1797) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1797) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1797) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1797) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1797) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1797) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1797) at com.android.internal.policy.DecorView.superDispatchKeyEvent(DecorView.java:415) at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1811) at android.app.Activity.dispatchKeyEvent(Activity.java:3251) at android.support.v7.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:535) at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:58) at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:316) at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:329) at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4703) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4575) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4117) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4170) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4136) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4263) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4144) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4320) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4117) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4170) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4136) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4144) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4117) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4170) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4136) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4296) at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:4457) at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2435) at an

Thanks in advance :)

hanggrian commented 7 years ago

Thank you for your detailed report. It seems that the crash seem to only occur when backspacing a mention symbol.

If we are talking about the same bug, it should be fixed in version 0.13.1 I have just deployed. But just to be sure, can you please try it? :)

CripyIce commented 7 years ago

Yeah, we are talking about the same bug. And now it works PERFECT!! Thanks for the fast reply and fix :) Really appreciate it!!

hanggrian commented 7 years ago

No worries! Let me know if you catch another one :)