-
Notifications
You must be signed in to change notification settings - Fork 231
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
Getting crash due to StringIndexOutOfBoundsException inside RecyclerView #54
Comments
same |
I think not only in recyclerview |
have solve it ? |
hmm i think need. to change to other lib |
I've tried debugging this and I found that this part right here is causing it. On this method of ReadMoreTextView.java
When you set the mode to TRIM_MODE_LINES, that case will execute and there are times that the value of trimEndIndex is negative so the if statement below it will execute and when trimLength is greater than the actual text length, this will cause the SpannableStringBuilder to throw and index out of bounds error. ps. the trimLength have a default value of 240 |
I found out that one of the reasons for this is old data is still there, because of the recycling mechanism of recyclerview. What I mean is the old text is still there and it was used to calculate other variables within the ReadMoreTextView to initialize it, so by the time that the new text is passed into it will used the precomputed values from the old data. In this case the length of the old text is used to initialize the SpannableStringBuilder which caused the index out of bounds. I added a setting to recyclerview to disable the recycling mechanism to avoid this issue. Altho it solved it, but it beats the purpose of the recyclerview and it obviously affected the performance. Have to find another way for this. Maybe put a handler inside the ReadMoreTextView to update the data effectively or wait for the recyclerview to finally load the new data first, but don't know how yet. Hope this will help others to figure out this problem once and for all. |
i do not have much time to solve the library problem, so i using this lib : https://github.com/devendroid/ReadMoreOption |
I have a possible solution. I'll work on this. |
ok buddy, if u want to make it easy
|
Is anyone still working on this lib? No pull requests, no commits, is there maybe an updated repo with this issues fixed? |
I'm using
ReadMoreTextView
inRecyclerView
.Getting crash due to
StringIndexOutOfBoundsException
so many times insideRecyclerView
.The text was updated successfully, but these errors were encountered: