diff options
| -rw-r--r-- | api/current.xml | 44 | ||||
| -rw-r--r-- | core/java/android/widget/AbsListView.java | 4 | ||||
| -rw-r--r-- | core/java/android/widget/FastScroller.java | 19 | ||||
| -rwxr-xr-x | core/res/res/values/attrs.xml | 15 | ||||
| -rw-r--r-- | 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 fb6b950517cf..e76bd65d78e9 100644 --- a/api/current.xml +++ b/api/current.xml @@ -4211,6 +4211,50 @@ visibility="public" > </field> +<field name="fastScrollOverlayPosition" + type="int" + transient="false" + volatile="false" + value="16843592" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="fastScrollPreviewBackgroundLeft" + type="int" + transient="false" + volatile="false" + value="16843590" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="fastScrollThumbDrawable" + type="int" + transient="false" + volatile="false" + value="16843589" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> +<field name="fastScrollTrackDrawable" + type="int" + transient="false" + volatile="false" + value="16843591" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="fillAfter" type="int" transient="false" diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 30dd17b34f87..87e4b5a8c473 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -1779,6 +1779,10 @@ public abstract class AbsListView extends AdapterView<ListAdapter> 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 f824ff468d0d..4e3ef0c2fe2a 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 f399578d6908..181bbcc50aa6 100755 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -520,15 +520,20 @@ <attr name="dayPickerWeekDayViewStyle" format="reference" /> <!-- Fast scroller styles --> - <!-- @hide --> + <eat-comment /> + + <!-- Drawable to use as the fast scroll thumb. --> <attr name="fastScrollThumbDrawable" format="reference" /> - <!-- @hide --> + <!-- Drawable to use as the fast scroll index preview window background + when shown on the right. --> <attr name="fastScrollPreviewBackgroundRight" format="reference" /> - <!-- @hide --> + <!-- Drawable to use as the fast scroll index preview window background + when shown on the left. --> <attr name="fastScrollPreviewBackgroundLeft" format="reference" /> - <!-- @hide --> + <!-- Drawable to use as the track for the fast scroll thumb. + This may be null. --> <attr name="fastScrollTrackDrawable" format="reference" /> - <!-- @hide --> + <!-- Position of the fast scroll index overlay window. --> <attr name="fastScrollOverlayPosition"> <enum name="floating" value="0" /> <enum name="atThumb" value="1" /> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 1f9cb6dbca3a..6c76f572cd53 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1403,6 +1403,10 @@ <public type="attr" name="isAlwaysSyncable" /> <public type="attr" name="verticalScrollbarPosition" /> <public type="attr" name="fastScrollAlwaysVisible" /> + <public type="attr" name="fastScrollThumbDrawable" /> + <public type="attr" name="fastScrollPreviewBackgroundLeft" /> + <public type="attr" name="fastScrollTrackDrawable" /> + <public type="attr" name="fastScrollOverlayPosition" /> <public type="anim" name="animator_fade_in" /> <public type="anim" name="animator_fade_out" /> |