@Override public void configurePinnedHeaders(PinnedHeaderListView listView) { int size = getPartitionCount(); int topPosition = listView.getPositionAt(0); int partition = getPartitionForPosition(topPosition); if (partition >= 0) { for (int i = 0; i < size; i++) { if (isHeaderVisible(partition)) { listView.setHeaderInvisible(i, isPartitionEmpty(i)); } } if (isHeaderVisible(partition)) { int headerHeight = listView.getPinnedHeaderHeight(partition); int visiblePosition = listView.getPositionAt(headerHeight); if (getPartitionForPosition(visiblePosition) == partition) { listView.setHeaderPinnedAtTop(partition, 0); } else { listView.setFadingHeader(partition, topPosition, true); } } } }
@Override public void configurePinnedHeaders(PinnedHeaderListView listView) { super.configurePinnedHeaders(listView); if (!isSectionHeaderDisplayEnabled()) { return; } int index = getPinnedHeaderCount() - 1; if (mIndexer == null || getCount() == 0) { listView.setHeaderInvisible(index, false); } else { int listPosition = listView.getPositionAt(listView.getTotalTopPinnedHeaderHeight()); int position = listPosition - listView.getHeaderViewsCount(); int section = -1; int partition = getPartitionForPosition(position); if (partition == mIndexedPartition) { int offset = getOffsetInPartition(position); if (offset != -1) { section = getSectionForPosition(offset); } } if (section == -1) { listView.setHeaderInvisible(index, false); } else { setPinnedSectionTitle(mHeader, (String) mIndexer.getSections()[section]); if (section == 0) { setPinnedHeaderContactsCount(mHeader); } else { clearPinnedHeaderContactsCount(mHeader); } // Compute the item position where the current partition begins int partitionStart = getPositionForPartition(mIndexedPartition); if (hasHeader(mIndexedPartition)) { partitionStart++; } // Compute the item position where the next section begins int nextSectionPosition = partitionStart + getPositionForSection(section + 1); boolean isLastInSection = position == nextSectionPosition - 1; listView.setFadingHeader(index, listPosition, isLastInSection); } } }