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 in Class NachoTextView #74

Open
huzaifaiftikhar opened this issue Oct 19, 2018 · 0 comments
Open

IndexOutOfBoundsException in Class NachoTextView #74

huzaifaiftikhar opened this issue Oct 19, 2018 · 0 comments

Comments

@huzaifaiftikhar
Copy link

Summary:
App crashes when trying to paste over a chipified text. I am using , as the ChipTerminator.
Source code of the app.

Library version
1.1.1

Steps to reproduce:

  • Type a text and create a chip.
  • Type another text and create a second chip.
  • Select the second chip and cut it.
  • Select the first chip and select paste. (Trying to paste the second chip which was cut in the previous step)
  • The app crashes on clicking paste.

When I tried reproducing it with the sample apk in this repository, the sample app didn't crash. However, it didn't paste anything either and erased the chip onto which I pasted.

System logs:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: openfoodfacts.github.scrachx.openfood, PID: 3887
    java.lang.IndexOutOfBoundsException: getChars (0 ... 4) ends beyond length 0
        at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1315)
        at android.text.SpannableStringBuilder.getChars(SpannableStringBuilder.java:1197)
        at android.text.TextUtils.getChars(TextUtils.java:100)
        at android.text.SpannableStringBuilder.<init>(SpannableStringBuilder.java:67)
        at android.text.SpannableStringBuilder.subSequence(SpannableStringBuilder.java:1189)
        at com.hootsuite.nachos.NachoTextView.handleTextChanged(NachoTextView.java:839)
        at com.hootsuite.nachos.NachoTextView.afterTextChanged(NachoTextView.java:826)
        at android.widget.TextView.sendAfterTextChanged(TextView.java:9424)
        at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:11983)
        at android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:1268)
        at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:574)
        at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:504)
        at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:502)
        at android.widget.TextView.paste(TextView.java:11237)
        at android.widget.TextView.onTextContextMenuItem(TextView.java:10881)
        at com.hootsuite.nachos.NachoTextView.onTextContextMenuItem(NachoTextView.java:619)
        at android.widget.Editor$TextActionModeCallback.onActionItemClicked(Editor.java:3991)
        at com.android.internal.policy.DecorView$ActionModeCallback2Wrapper.onActionItemClicked(DecorView.java:2581)
        at com.android.internal.view.FloatingActionMode$3.onMenuItemSelected(FloatingActionMode.java:96)
        at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:761)
        at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:167)
        at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:908)
        at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:898)
        at com.android.internal.view.FloatingActionMode.lambda$-com_android_internal_view_FloatingActionMode_4856(FloatingActionMode.java:121)
        at com.android.internal.view.-$Lambda$IoKM3AcgDw3Ok5aFi0zlym2p3IA.$m$0(Unknown Source:4)
        at com.android.internal.view.-$Lambda$IoKM3AcgDw3Ok5aFi0zlym2p3IA.onMenuItemClick(Unknown Source:0)
        at com.android.internal.widget.FloatingToolbar$FloatingToolbarPopup$2.onClick(FloatingToolbar.java:425)
        at android.view.View.performClick(View.java:6297)
        at android.view.View$PerformClick.run(View.java:24797)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6626)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)

Expected behavior:
The app shouldn't crash.

Device and Android version:
Motorola Moto G5s
Android 8.1.0

Screenshots:
videotogif_2018 10 19_22 28 53        videotogif_2018 10 19_23 11 02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant