splitwise/TokenAutoComplete — pull request #78 by weitsai (2014-09-07 16:12:50+00:00)
Title: Fix deleteSelectedObject IndexOutOfBoundsException

Fix the object occurs IndexOutOfBoundsException which is generated by addObject(obj) when delete KeyEvent triggered.

----------------Log------------------------
09-07 15:03:06.836: E/InputEventSender(1630): Exception dispatching finished signal.
09-07 15:03:06.836: E/MessageQueue-JNI(1630): Exception in MessageQueue callback: handleReceiveCallback
09-07 15:03:06.836: E/MessageQueue-JNI(1630): java.lang.IndexOutOfBoundsException: charAt: 0 >= length 0
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.text.SpannableStringBuilder.charAt(SpannableStringBuilder.java:114)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at com.tokenautocomplete.TokenCompleteTextView$TokenTextWatcher.onTextChanged(TokenCompleteTextView.java:1059)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.widget.TextView.sendOnTextChanged(TextView.java:7318)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.widget.TextView.handleTextChanged(TextView.java:7377)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:9076)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:962)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:496)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:212)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:30)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.text.method.BaseKeyListener.backspaceOrForwardDelete(BaseKeyListener.java:94)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.text.method.BaseKeyListener.backspace(BaseKeyListener.java:49)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.text.method.BaseKeyListener.onKeyDown(BaseKeyListener.java:155)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.text.method.QwertyKeyListener.onKeyDown(QwertyKeyListener.java:357)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.text.method.TextKeyListener.onKeyDown(TextKeyListener.java:136)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.widget.TextView.doKeyDown(TextView.java:5464)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.widget.TextView.onKeyDown(TextView.java:5283)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.widget.AutoCompleteTextView.onKeyDown(AutoCompleteTextView.java:716)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at com.tokenautocomplete.TokenCompleteTextView.onKeyDown(TokenCompleteTextView.java:392)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.KeyEvent.dispatch(KeyEvent.java:2623)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.View.dispatchKeyEvent(View.java:7343)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.widget.ScrollView.dispatchKeyEvent(ScrollView.java:353)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1933)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1408)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.app.Activity.dispatchKeyEvent(Activity.java:2384)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at com.actionbarsherlock.app.SherlockActivity.dispatchKeyEvent(SherlockActivity.java:116)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1860)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:3791)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3774)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3483)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3540)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3516)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:3666)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:1982)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1698)
09-07 15:03:06.836: E/MessageQueue-JNI(1630):	at android.view.inputmethod.InputMetho
09-07 15:03:06.836: D/AndroidRuntime(1630): Shutting down VM
09-07 15:03:06.836: W/dalvikvm(1630): threadid=1: thread exiting with uncaught exception (group=0xa4b85648)
09-07 15:03:06.836: E/AndroidRuntime(1630): FATAL EXCEPTION: main
09-07 15:03:06.836: E/AndroidRuntime(1630): java.lang.IndexOutOfBoundsException: charAt: 0 >= length 0
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.text.SpannableStringBuilder.charAt(SpannableStringBuilder.java:114)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at com.tokenautocomplete.TokenCompleteTextView$TokenTextWatcher.onTextChanged(TokenCompleteTextView.java:1059)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.widget.TextView.sendOnTextChanged(TextView.java:7318)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.widget.TextView.handleTextChanged(TextView.java:7377)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:9076)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:962)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:496)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:212)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:30)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.text.method.BaseKeyListener.backspaceOrForwardDelete(BaseKeyListener.java:94)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.text.method.BaseKeyListener.backspace(BaseKeyListener.java:49)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.text.method.BaseKeyListener.onKeyDown(BaseKeyListener.java:155)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.text.method.QwertyKeyListener.onKeyDown(QwertyKeyListener.java:357)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.text.method.TextKeyListener.onKeyDown(TextKeyListener.java:136)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.widget.TextView.doKeyDown(TextView.java:5464)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.widget.TextView.onKeyDown(TextView.java:5283)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.widget.AutoCompleteTextView.onKeyDown(AutoCompleteTextView.java:716)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at com.tokenautocomplete.TokenCompleteTextView.onKeyDown(TokenCompleteTextView.java:392)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.KeyEvent.dispatch(KeyEvent.java:2623)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.View.dispatchKeyEvent(View.java:7343)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.widget.ScrollView.dispatchKeyEvent(ScrollView.java:353)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1393)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1933)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1408)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.app.Activity.dispatchKeyEvent(Activity.java:2384)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at com.actionbarsherlock.app.SherlockActivity.dispatchKeyEvent(SherlockActivity.java:116)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1860)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:3791)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3774)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3483)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3540)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3406)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3379)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3429)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3398)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3516)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:3666)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:1982)
09-07 15:03:06.836: E/AndroidRuntime(1630):	at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1698)