Closed fabiogrum closed 7 years ago
I tried to reproduce this and am unable to. After a call to notifyDataSetChanged
, any stickied header is removed and the correct one is stickied in place (if the list is at the appropriate spot for the new header to be stickied).
If you can reproduce in a sample project I'd gladly take a look.
Hi, thank you for your help. I used your demo : https://github.com/fabiogrum/StickyHeaders.git I added a floating button, who replaces the items of the adapter with an header and an item and calls notifyDataSetChanged().
In this screenshot, you can see that the older header is still there and it hides the new header. I have this problem only if I scroll down the list and there is an header that is almost not visible.
Perfect, thanks! I'll take a look in the next few days.
I believe this takes care of it. Released in version 0.4.4.
Please let me know if it doesn't solve your issue!
Hi, seems like this issue is still here.
I'm using DiffUtil to update my items list in recyclerView but notifyDataSetChanged()
also triggers this bug.
If I remove the first header from my list along with the items that belong to first header and then update the adapter, the items are gone but the sticky header is still there even though it shouldn't be. Plus the second header (not currently sticky one) dissapears.
Not sure if you understand but let me know if you want me to post a sample or something.
Still a mystery but I stumbled across the same behaviour even with 0.4.4.
Setting the adapter before setting the StickyLayoutManager
fixed it somehow.
Before:
StickyLayoutManager layoutManager = new StickyLayoutManager(recyclerView.getContext(), adapter);
layoutManager.elevateHeaders(true);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
After:
StickyLayoutManager layoutManager = new StickyLayoutManager(recyclerView.getContext(), adapter);
layoutManager.elevateHeaders(true);
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(layoutManager);
@m4limo Sadly This does not work with DiffUtil
but seems to work with notifyDataSetChanged()
Very weird
@ThanosFisherman I'd definitely be able to have a quicker turnaround on a fix if you had a sample.
But I will look into it on my own either way in the next few days.
@bgogetap Ok I modified your sample app a little bit to match my project's setup. Have a look https://github.com/ThanosFisherman/StickyHeaders
I've also came across a new issue that it may or may not be related to this one.
Steps to reproduce new issue:
Open the app and press the menu button named "Remove 4" That will remove the first 4 items including the header. Everything seems to work as expected here.
Now scroll down a little bit until the first header becomes sticked (elevation appears). Now press again the "Remove 4" button and it will crash with a NullPointerException
That's something new I just discovered.
Steps to reproduce my issue described in this thread:
Go to activity_main.xml
and remove the android:padding="10dp"
from the RecyclerView.
Run the app. The first header is now already sticked.
Click the "Remove 4" button and see the issue described here. The first header named "Header 0" Is never detached no matter how many times you press the "Remove 4" Button.
If you however scroll down until the next non sticky header pushes the already stickied one and then scroll up again the wrong sticky header updates itself with the correct text.
@m4limo I had problems with the copy header not being updated, after your solution the problem is gone. Thank you.
Hi, I have a search feature and a filter feature in my list. I replace the items in my list and I call notifyDataSetChanged() when I use these features. I don't replace the adapter. The problem is when I scroll down the list and there is a header that is almost not visible, it remains visible when I call notifyDataSetChanged(), even if it shouldn't be because the list doesn't contain anymore this header.