bravoborja / ReadMoreTextView

A Custom TextView with trim text
Apache License 2.0
1.69k stars 229 forks source link

StringIndexOutBounds when text is less than trim length #10

Closed nilskassube closed 6 years ago

nilskassube commented 8 years ago

If you try to trim by length, and the length of the text is smaller than the limit, you get

java.lang.StringIndexOutOfBoundsException: length=8; regionStart=0; regionLength=101 at java.lang.String.startEndAndLength(String.java:298) at java.lang.String.getChars(String.java:598) at android.text.TextUtils.getChars(TextUtils.java:81) at android.text.SpannableStringBuilder.(SpannableStringBuilder.java:65) at com.borjabravo.readmoretextview.ReadMoreTextView.updateCollapsedText(ReadMoreTextView.java:137) at com.borjabravo.readmoretextview.ReadMoreTextView.getTrimmedText(ReadMoreTextView.java:115) at com.borjabravo.readmoretextview.ReadMoreTextView.getDisplayableText(ReadMoreTextView.java:92) at com.borjabravo.readmoretextview.ReadMoreTextView.setText(ReadMoreTextView.java:86)

JigneshWorld commented 8 years ago
java.lang.StringIndexOutOfBoundsException: length=9; regionStart=0; regionLength=241
                                                                                   at java.lang.String.startEndAndLength(String.java:298)
                                                                                   at java.lang.String.getChars(String.java:598)
                                                                                   at android.text.TextUtils.getChars(TextUtils.java:81)
                                                                                   at android.text.SpannableStringBuilder.<init>(SpannableStringBuilder.java:65)
                                                                                   at com.borjabravo.readmoretextview.ReadMoreTextView.updateCollapsedText(ReadMoreTextView.java:137)
                                                                                   at com.borjabravo.readmoretextview.ReadMoreTextView.getTrimmedText(ReadMoreTextView.java:115)
                                                                                   at com.borjabravo.readmoretextview.ReadMoreTextView.getDisplayableText(ReadMoreTextView.java:92)
                                                                                   at com.borjabravo.readmoretextview.ReadMoreTextView.setText(ReadMoreTextView.java:86)
                                                                                   at com.borjabravo.readmoretextview.ReadMoreTextView.access$200(ReadMoreTextView.java:36)
                                                                                   at com.borjabravo.readmoretextview.ReadMoreTextView$1.onGlobalLayout(ReadMoreTextView.java:206)
                                                                                   at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:912)
                                                                                   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1969)
                                                                                   at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
                                                                                   at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
                                                                                   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
                                                                                   at android.view.Choreographer.doCallbacks(Choreographer.java:670)
                                                                                   at android.view.Choreographer.doFrame(Choreographer.java:606)
                                                                                   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
                                                                                   at android.os.Handler.handleCallback(Handler.java:739)
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                   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)

Same issue. :+1:

Tring to use this textview inside recyclerview. @bravoborja any help or suggestions?

sandeshlasnapure commented 7 years ago

Still having issue with recycler view, sometime clickable span not adding to text view. device-2017-01-24-022331

asywalulfikri commented 7 years ago

i have same problem

pudao2010 commented 7 years ago

I have same problem,When I use the ReadMoreTextView in RecyclerView,My App will crash,so I abandon it in my App

asywalulfikri commented 7 years ago

any body have resolve it ?

ziem commented 7 years ago

Is there any progress on this issue?

bipinbharti1357 commented 7 years ago

i have same problem if any have solution?

bipinbharti1357 commented 7 years ago

@sandeshlasnapure can you show me your for "readmore"?

bipinbharti1357 commented 7 years ago

using handler may be solve the problem

jianjiankedizai commented 7 years ago

this is a big problem

sondevelopervn commented 6 years ago

When I use the ReadMoreTextView in RecyclerView,My App will crash java.lang.StringIndexOutOfBoundsException: length=3; regionStart=0; regionLength=885 at java.lang.String.startEndAndLength(String.java:298) at java.lang.String.getChars(String.java:598) at android.text.TextUtils.getChars(TextUtils.java:85) at android.text.SpannableStringBuilder.(SpannableStringBuilder.java:65)