From cd8308a9a2971975acb3a606dee02f246d01c109 Mon Sep 17 00:00:00 2001 From: ptwoms Date: Wed, 7 Jan 2015 23:36:01 +0800 Subject: [PATCH] Attempt to fix the overlapping section headers when the list view reach near the end --- library/src/com/hb/views/PinnedSectionListView.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/library/src/com/hb/views/PinnedSectionListView.java b/library/src/com/hb/views/PinnedSectionListView.java index 41cce45..f23d29d 100644 --- a/library/src/com/hb/views/PinnedSectionListView.java +++ b/library/src/com/hb/views/PinnedSectionListView.java @@ -278,9 +278,14 @@ void ensureShadowForPosition(int sectionPosition, int firstVisibleItem, int visi int findFirstVisibleSectionPosition(int firstVisibleItem, int visibleItemCount) { ListAdapter adapter = getAdapter(); - - if (firstVisibleItem + visibleItemCount >= adapter.getCount()) return -1; // dataset has changed, no candidate - + + int adapterDataCount = adapter.getCount(); + if (getLastVisiblePosition() >= adapterDataCount) return -1; // dataset has changed, no candidate + + if (firstVisibleItem+visibleItemCount >= adapterDataCount){//added to prevent index Outofbound (in case) + visibleItemCount = adapterDataCount-firstVisibleItem; + } + for (int childIndex = 0; childIndex < visibleItemCount; childIndex++) { int position = firstVisibleItem + childIndex; int viewType = adapter.getItemViewType(position);