Skip to content

Commit

Permalink
Fix logic for 'at least one' item
Browse files Browse the repository at this point in the history
We only show global header/footer if there's at least one item to display.  The header was fine already, but we weren't considering other cases where there were items found in order to decide to display the footer.

So if you had no header visible, but wanted a footer, it wouldn't show up.
  • Loading branch information
Redth committed Jun 7, 2024
1 parent 4eb498f commit cf2e554
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions VirtualListView/PositionalViewSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int GetTotalCount()

var sum = 0;

var hasAtLeastOneItem = false;
//var hasAtLeastOneItem = false;
var numberOfSections = Adapter.GetNumberOfSections();

if (HasGlobalHeader && numberOfSections > 0)
Expand All @@ -50,7 +50,6 @@ int GetTotalCount()
// If we found one, we can stop looping
// since we just care to calculate a spot
// for the header cell if the adapter isn't empty
hasAtLeastOneItem = true;
break;
}
}
Expand All @@ -72,7 +71,7 @@ int GetTotalCount()

// Only count footer if there is already at least one item
// otherwise the adapter is empty and we shouldn't count it
if (HasGlobalFooter && hasAtLeastOneItem)
if (HasGlobalFooter && sum > 0)
sum += 1;

return sum;
Expand Down

0 comments on commit cf2e554

Please sign in to comment.