Fix bug 5073637 - Market apps crashing FastScroller

It seems that some popular Market apps do not properly implement
SectionIndexer#getSectionForPosition and the framework did not
previously call it. Revert to more simplistic scrollbar behavior for
apps targeting sdk < Honeycomb.

Change-Id: If0b1f2b4db540de4bb8ba45798e498c09cddb42f
This commit is contained in:
Adam Powell
2011-08-03 22:38:48 -07:00
parent cf27a3ecc6
commit 568ccd88d7

View File

@@ -116,6 +116,8 @@ class FastScroller {
private int mOverlayPosition;
private boolean mMatchDragPosition;
private static final int FADE_TIMEOUT = 1500;
private final Rect mTmpRect = new Rect();
@@ -262,6 +264,9 @@ class FastScroller {
ta.recycle();
mMatchDragPosition = context.getApplicationInfo().targetSdkVersion >=
android.os.Build.VERSION_CODES.HONEYCOMB;
setScrollbarPosition(mList.getVerticalScrollbarPosition());
}
@@ -417,7 +422,7 @@ class FastScroller {
}
return;
}
if (totalItemCount - visibleItemCount > 0 && mState != STATE_DRAGGING ) {
if (totalItemCount - visibleItemCount > 0 && mState != STATE_DRAGGING) {
mThumbY = getThumbPositionForListPosition(firstVisibleItem, visibleItemCount,
totalItemCount);
if (mChangedBounds) {
@@ -595,7 +600,7 @@ class FastScroller {
if (mSectionIndexer == null) {
getSectionsFromIndexer();
}
if (mSectionIndexer == null) {
if (mSectionIndexer == null || !mMatchDragPosition) {
return ((mList.getHeight() - mThumbH) * firstVisibleItem)
/ (totalItemCount - visibleItemCount);
}