diff options
| author | 2013-10-13 17:19:10 -0700 | |
|---|---|---|
| committer | 2013-10-13 18:49:15 -0700 | |
| commit | 5db566f16a1b8f36e84a9be00cde40482d48466b (patch) | |
| tree | 8dd38aae7b017dd41328c455a5d1f476edf8063e | |
| parent | 4ebe57804d1421daef81add365cd94a9a8183bc8 (diff) | |
Fix updating fast scroll state for data set changes
Only looking for old/new count changes is incomplete with the current
state of things. The observer's onChanged method will update this in
some cases, stomping the different values needed to trigger a fast
scroller update. Also update the fast scroller if the data change flag
is set.
Also fix the positioning of the legacy text overlay.
Bug 11188512
Change-Id: I35b3915ce49f8494c6d82f6be6d6df7169deddd7
| -rw-r--r-- | core/java/android/widget/AbsListView.java | 4 | ||||
| -rw-r--r-- | core/java/android/widget/FastScroller.java | 6 | ||||
| -rw-r--r-- | core/java/android/widget/ListView.java | 1 |
3 files changed, 6 insertions, 5 deletions
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 2e77578eb4f1..3eb005214556 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -2084,8 +2084,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te mRecycler.markChildrenDirty(); } - if (mFastScroller != null && mItemCount != mOldItemCount) { - mFastScroller.onItemCountChanged(mOldItemCount, mItemCount); + if (mFastScroller != null && (mItemCount != mOldItemCount || mDataChanged)) { + mFastScroller.onItemCountChanged(mItemCount); } layoutChildren(); diff --git a/core/java/android/widget/FastScroller.java b/core/java/android/widget/FastScroller.java index 01a848f37a35..4614c53eb9b2 100644 --- a/core/java/android/widget/FastScroller.java +++ b/core/java/android/widget/FastScroller.java @@ -441,7 +441,7 @@ class FastScroller { updateLayout(); } - public void onItemCountChanged(int oldTotalItemCount, int totalItemCount) { + public void onItemCountChanged(int totalItemCount) { final int visibleItemCount = mList.getChildCount(); final boolean hasMoreItems = totalItemCount - visibleItemCount > 0; if (hasMoreItems && mState != STATE_DRAGGING) { @@ -1095,12 +1095,14 @@ class FastScroller { final float thumbMiddle = position * range + offset; thumbImage.setTranslationY(thumbMiddle - thumbImage.getHeight() / 2); + final float previewPos = mOverlayPosition == OVERLAY_AT_THUMB ? thumbMiddle : 0; + // Center the preview on the thumb, constrained to the list bounds. final ImageView previewImage = mPreviewImage; final float previewHalfHeight = previewImage.getHeight() / 2f; final float minP = top + previewHalfHeight; final float maxP = bottom - previewHalfHeight; - final float previewMiddle = MathUtils.constrain(thumbMiddle, minP, maxP); + final float previewMiddle = MathUtils.constrain(previewPos, minP, maxP); final float previewTop = previewMiddle - previewHalfHeight; previewImage.setTranslationY(previewTop); diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java index 4b00f90d13c3..78237c3e7801 100644 --- a/core/java/android/widget/ListView.java +++ b/core/java/android/widget/ListView.java @@ -508,7 +508,6 @@ public class ListView extends AbsListView { requestLayout(); } - /** * The list is empty. Clear everything out. */ |