From 2c6196aa557e4eaf09d1ec3ad1347742f7f9f7b5 Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Fri, 10 Dec 2010 14:31:54 -0800 Subject: [PATCH] Fix a bug where the fast scroll track would be positioned incorrectly. Make fast scroll theme attributes public. Fix a bug where always-visible fast scrollers wouldn't appear on small lists. Change-Id: I377adf63d2fe88478f77b0b04466c6ae88557efe --- api/current.xml | 44 ++++++++++++++++++++++ core/java/android/widget/AbsListView.java | 4 ++ core/java/android/widget/FastScroller.java | 19 +++++++--- core/res/res/values/attrs.xml | 15 +++++--- core/res/res/values/public.xml | 4 ++ 5 files changed, 76 insertions(+), 10 deletions(-) diff --git a/api/current.xml b/api/current.xml index fb6b950517cfa..e76bd65d78e90 100644 --- a/api/current.xml +++ b/api/current.xml @@ -4211,6 +4211,50 @@ visibility="public" > + + + + + + + + implements Te } mRecycler.markChildrenDirty(); } + + if (mFastScroller != null && mItemCount != mOldItemCount) { + mFastScroller.onItemCountChanged(mOldItemCount, mItemCount); + } layoutChildren(); mInLayout = false; diff --git a/core/java/android/widget/FastScroller.java b/core/java/android/widget/FastScroller.java index f824ff468d0d0..4e3ef0c2fe2af 100644 --- a/core/java/android/widget/FastScroller.java +++ b/core/java/android/widget/FastScroller.java @@ -307,10 +307,13 @@ class FastScroller { } if (mTrackDrawable != null) { - final int left = mThumbDrawable.getBounds().left; + final Rect thumbBounds = mThumbDrawable.getBounds(); + final int left = thumbBounds.left; + final int halfThumbHeight = (thumbBounds.bottom - thumbBounds.top) / 2; final int trackWidth = mTrackDrawable.getIntrinsicWidth(); - final int trackLeft = (left + mThumbW) / 2 - trackWidth / 2; - mTrackDrawable.setBounds(trackLeft, 0, trackLeft + trackWidth, mList.getHeight()); + final int trackLeft = (left + mThumbW / 2) - trackWidth / 2; + mTrackDrawable.setBounds(trackLeft, halfThumbHeight, + trackLeft + trackWidth, mList.getHeight() - halfThumbHeight); mTrackDrawable.draw(canvas); } @@ -393,13 +396,19 @@ class FastScroller { } } } - + + void onItemCountChanged(int oldCount, int newCount) { + if (mAlwaysShow) { + mLongList = true; + } + } + void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { // Are there enough pages to require fast scroll? Recompute only if total count changes if (mItemCount != totalItemCount && visibleItemCount > 0) { mItemCount = totalItemCount; - mLongList = mItemCount / visibleItemCount >= MIN_PAGES; + mLongList = mAlwaysShow || mItemCount / visibleItemCount >= MIN_PAGES; } if (!mLongList) { if (mState != STATE_NONE) { diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index f399578d6908e..181bbcc50aa69 100755 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -520,15 +520,20 @@ - + + + - + - + - + - + diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 1f9cb6dbca3a4..6c76f572cd53d 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1403,6 +1403,10 @@ + + + +