-
Notifications
You must be signed in to change notification settings - Fork 548
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
Update view from normal header to sticky header #393
Comments
@NegreaVlad, Thanks for compliments! 👍 You have access to the Adapter to know the current sticky posiiton and the Regarding the size, it is not huge compared to RecyclerView. But, with RC3, I will remove all the deprecated methods, so 400~700 lines will be removed. |
@davideas I need to make changes to the header view when it becomes a sticky header. I use the list to show a calendar. The sticky header has a button that when clicked, the list scrolls to the current day. The other headers (which are not sticky) do not have this button. How can I make this button appear on the sticky headers and not the regular headers? |
|
I found the |
Well, you can save it at each callback. I will check if I can provide the old position. |
Yes, I can provide it, but I have to refactor the method signature, it will be available from next version and snapshot. |
Thanks to your suggestions, I was able to achieve what I wanted, but it seems a bit hacky.
I have modified the
I am open to suggestions. |
Good, but you can Another solution would be to check if that header is sticky so you can display your view. Try both and check if any suite to your use case. |
For the first solution, I should receive the instance of the old and new header items and update them so that they know if they are sticky or not and send them as payload to |
The second solution, in bindViewHolder you have the |
@davideas Updating the UI inside the I have a view which I want to be shown only if the header is sticky, so I hide this view when Is there some sort of animation/delay when updating the headers view? I see a sort of alpha animation going on when I set the view's visibility to |
@NegreaVlad, that alpha animation is for the container layout when sticky feature is enabled/disabled, not when they swap. Would you make a short video, to have a better idea of what is displayed with normal scrolling and with fling? Also show me the binding method of the header. |
@davideas You can find the two screen recordings here: scrolling_videos.zip The header's binding method:
|
I'm using a handler to notify of item changes in order to prevent errors:
The delay is very small:
|
@NegreaVlad, thanks for the videos and code. By the way, nice layout and user interface, thanks also to my adapter 😃 I tried myself in the demoApp, this delay appears also on my test and I can explain why. You resolve in 2 ways:
PS. Instead of using a |
@davideas Thanks for the help, you are 100% right. The alpha animation was caused by the Both of your suggestions fix the issue. I had gone with the first, using The final code:
|
@NegreaVlad, watch out that you actually need the execution in |
@davideas There is however another issue that I found. Because I use a Basically, the wrong item receives the I tried setting a |
@NegreaVlad, you actually can register more observers as many you want. |
@davideas You are right, I didn't look close enough, you can add multiple observers. I fixed the issue with the wrong header index by using a The code:
Inside my custom
Thanks again for the help and quick replies. |
In my app, the sticky headers have an extra view added to them over the basic header. How can I do this?
I tried forking the library and adding the sticky header position to the IFlexible onBindView method:
bindViewHolder(FlexibleAdapter adapter, VH holder, int position, int stickyPosition, List payloads)
This way I can update the sticky header, but the changes are not reverted when the sticky header is changed, because the header is not bound again.
Congratulations for the library! It is very powerful, but the FlexibleAdapter class is huge. It's size should be reduced. Maybe more helper classes like
StickyHeaderHelper
could be made.Any help is welcome, thanks!
The text was updated successfully, but these errors were encountered: