ebarrenechea / header-decor

A couple of sticky header decorations for android's recycler view.
Apache License 2.0
879 stars 159 forks source link

Weird scrolling issue while using conditions in getHeaderId (GIF) #64

Open hunter-isaiah96 opened 7 years ago

hunter-isaiah96 commented 7 years ago

For example, if I use this simple condition to check(for simplicity)

if(task.getTitle().equals("Sticky Above This")){ return (long) position; } return StickyHeaderDecoration.NO_HEADER_ID;

When there are multiple items between a view, it produces this strange behavior

When I use return (long) position / 2 it shows a header every 2 items and scrolls just fine. I'm not 100% sure if it's me or the library but it would be nice to have a sense of direction.

aditijoshi commented 7 years ago

If you're still facing a problem refer to this issue, helped me understand how the header id works :- https://github.com/edubarr/header-decor/issues/25

Basically, every cell ( whether the header is displayed immediately above that or not) needs a header id so you need not use the if condition at all ( in your sample code) instead return the same header id for every cell that belongs to a section ( a section being all the cells that are under a header). Hope this helps!

viktor1190 commented 7 years ago

@hunter-isaiah96 try to return 0 instead of StickyHeaderDecoration.NO_HEADER_ID