Closed rubengees closed 9 years ago
I got the same errors. In my case, I delete all items at once and add a new items set. What I'm thinking of is that your stickyheaderadapter lacks of a notifyDataSetChange call?
I have discovered that there are two different bugs. The first is the issue above. Another appears when you call
notifyItemRangeRemoved(i, 1);
instead. Moreover i changed some things and now I get the following error when i delete an item and call notifyItemRemoved():
java.lang.IndexOutOfBoundsException: invalid position 2. State item count is 2
at android.support.v7.widget.RecyclerView$Recycler.convertPreLayoutPositionToPostLayout(RecyclerView.java:3234)
at android.support.v7.widget.RecyclerViewHelper.convertPreLayoutPositionToPostLayout(RecyclerViewHelper.java:9)
at com.eowise.recyclerview.stickyheaders.StickyHeadersItemDecoration$HeaderStore.isHeader(StickyHeadersItemDecoration.java:164)
at com.eowise.recyclerview.stickyheaders.StickyHeadersItemDecoration.onDrawOver(StickyHeadersItemDecoration.java:54)
I don't know if my code is that one which contains a bug, but i checked everything twice and couldn't find anything.
I am about to commit a fix for the first bug.
For the second one, are you able to reproduce it with the samples ?
I found this link, hope this helps!
I've published the 0.4.4-SNAPSHOT version on sonatype. Could you try if you still have an exception ?
I can't test it. Could you publish it, so I can build with Gradle? (Using Android Studio)
You can add the sonatype snapshot repo to your build.gradle :
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
and change the recyclerview-stickyheader lib version :
dependencies {
compile 'com.eowise:recyclerview-stickyheaders:0.4.4-SNAPSHOT@aar'
}
I still get an error: Failed to find
I added everything you suggested above.
What's the error exactly ?
Can you provide a PoC that reproduce it ?
Sorry I made a mistake, testing now.
Okay, removing items looks good now, but I'm getting strange errors calling onNotifyDataSetChanged() when I add items. I get the following Error:
java.lang.IndexOutOfBoundsException: Invalid index 1, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.add(ArrayList.java:147)
at com.eowise.recyclerview.stickyheaders.HeaderStore.isHeader(HeaderStore.java:74)
at com.eowise.recyclerview.stickyheaders.StickyHeadersItemDecoration.getItemOffsets(StickyHeadersItemDecoration.java:89)
at android.support.v7.widget.RecyclerView.getItemDecorInsetsForChild(RecyclerView.java:2662)
at android.support.v7.widget.RecyclerView$LayoutManager.measureChildWithMargins(RecyclerView.java:5434)
I can't use notifyOnItemInserted() because I don't know where the new items are, because I sort my List after insertion.
Ok, can you make another test after replacing 0.4.4-SNAPSHOT with 0.5.0-SNAPSHOT in your build.gradle ? I think this issue is fixed by PR #13, witch wasn't included in 0.4.4-SNAPSHOT.
Ok, it works! Thank you for your help!
Finally ! ;)
Haha great
Hi, with the latest version (0.4.3) I get a IndexOutOfBoundsException (Invalid index 0, size is 0) when I delete the last item from my Adapter.
This is the code I use: