From 4fc2fa65805c57cad2902b4707caa84578752002 Mon Sep 17 00:00:00 2001 From: Vairavan Srinivasan Date: Mon, 4 Mar 2013 20:34:46 -0800 Subject: [PATCH] FastScroller: Fix to use appropriate index Fix FastScroller to use appropriate index to determine the the position of a section while calculating the y coordinates of thumb. In case of last section, use totalItemCount to determine next section position. Change-Id: I89bfd483949b5c14f85303b50380a73b4a4e635e --- core/java/android/widget/FastScroller.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/java/android/widget/FastScroller.java b/core/java/android/widget/FastScroller.java index d2139af22ea12..2dac2c468789e 100644 --- a/core/java/android/widget/FastScroller.java +++ b/core/java/android/widget/FastScroller.java @@ -646,8 +646,13 @@ class FastScroller { final int section = mSectionIndexer.getSectionForPosition(firstVisibleItem); final int sectionPos = mSectionIndexer.getPositionForSection(section); - final int nextSectionPos = mSectionIndexer.getPositionForSection(section + 1); + final int nextSectionPos; final int sectionCount = mSections.length; + if (section + 1 < sectionCount) { + nextSectionPos = mSectionIndexer.getPositionForSection(section + 1); + } else { + nextSectionPos = totalItemCount - 1; + } final int positionsInSection = nextSectionPos - sectionPos; final View child = mList.getChildAt(0);