From f49971ec06e65ee2a0f0fd48a615b89c677086e7 Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Tue, 14 Jun 2011 22:00:01 -0700 Subject: Make FastScroller behave kinder and gentler when an app decides to return null from SectionIndexer#getSections() Change-Id: I9132073f149e13051db13d2e563bd7c1a316046e --- core/java/android/widget/FastScroller.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'core/java/android/widget/FastScroller.java') diff --git a/core/java/android/widget/FastScroller.java b/core/java/android/widget/FastScroller.java index fb57ce0..00ebe0d 100644 --- a/core/java/android/widget/FastScroller.java +++ b/core/java/android/widget/FastScroller.java @@ -468,7 +468,9 @@ class FastScroller { mListAdapter = (BaseAdapter) adapter; mSectionIndexer = (SectionIndexer) adapter; mSections = mSectionIndexer.getSections(); - + if (mSections == null) { + mSections = new String[] { " " }; + } } else { mListAdapter = (BaseAdapter) adapter; mSections = new String[] { " " }; @@ -609,7 +611,7 @@ class FastScroller { final int section = mSectionIndexer.getSectionForPosition(firstVisibleItem); final int sectionPos = mSectionIndexer.getPositionForSection(section); final int nextSectionPos = mSectionIndexer.getPositionForSection(section + 1); - final int sectionCount = mSectionIndexer.getSections().length; + final int sectionCount = mSections.length; final int positionsInSection = nextSectionPos - sectionPos; final View child = mList.getChildAt(0); -- cgit v1.1