Skip to content
This repository has been archived by the owner on Jun 9, 2020. It is now read-only.

Section item does not stay pinned #39

Open
mbeaty opened this issue Mar 3, 2014 · 2 comments · May be fixed by #94
Open

Section item does not stay pinned #39

mbeaty opened this issue Mar 3, 2014 · 2 comments · May be fixed by #94

Comments

@mbeaty
Copy link

mbeaty commented Mar 3, 2014

I have a list with just one list item (TextView) per section. That single list item's TextView contains wrapping text that can potentially consume the entire height of the ListView's container. If this is the case, I am finding that the pinned section item does not stay pinned, but rather it disappears only to reappear at the time the next section item is scrolled into view. To reproduce this, simply create the list with one ITEM per SECTION, and make the text for the item section very long - long enough to extend beyond the height of the ListView's container. I am observing this with the example app and have no other customization at all.

Update: To clarify, my test actually does the above, but my test list has 10 such sections, each with identical items, just for testing purposes. Again, only one item per section.

@mbeaty
Copy link
Author

mbeaty commented Mar 3, 2014

This is the code causing this issue:

void ensureShadowForPosition(int sectionPosition, int firstVisibleItem, int visibleItemCount) {
   if (visibleItemCount < 2) { // no need for creating shadow at all, we have a single visible item           
         destroyPinnedShadow();
         return;
    }
    ...
}

I commented out this if block and it works fine. It seems that you are assuming here that a one item list would never be scrollable, therefore the shadow would be unnecessary. However, if the ListView's container is small enough in height, and the item's text length is such that the list can scroll, the shadow would still be useful, and desired. So, I think you need to somehow take into account whether the view is still scrollable, and not just look at whether visibleItemCount < 2. Does this make sense, and would you agree with this? Thank you.

Update: Actually, on further analysis, I think you can just remove the above if block with no ill effect. Please advise.

@sajith666
Copy link

Thank you for this.

@justingrayston justingrayston linked a pull request Mar 31, 2017 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants