diff options
| author | Bill Yi <byi@google.com> | 2014-04-29 16:07:29 -0700 |
|---|---|---|
| committer | Bill Yi <byi@google.com> | 2014-04-29 16:07:29 -0700 |
| commit | 293513a59d36cd96a3e474dde5981380d372d8c9 (patch) | |
| tree | 4268c9994be194a7f4fccdecd089af58516d0953 /core/java/android/widget/FastScroller.java | |
| parent | 1866e5dc8bb04b58a67e54f66cb4ec22e878667d (diff) | |
| parent | 0b62467b142b61ee1e449ba958ba37dfd961ef56 (diff) | |
| download | frameworks_base-293513a59d36cd96a3e474dde5981380d372d8c9.zip frameworks_base-293513a59d36cd96a3e474dde5981380d372d8c9.tar.gz frameworks_base-293513a59d36cd96a3e474dde5981380d372d8c9.tar.bz2 | |
Merge commit '0b62467b142b61ee1e449ba958ba37dfd961ef56' into HEAD
Diffstat (limited to 'core/java/android/widget/FastScroller.java')
| -rw-r--r-- | core/java/android/widget/FastScroller.java | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/core/java/android/widget/FastScroller.java b/core/java/android/widget/FastScroller.java index 01ac8fd..4379bf6 100644 --- a/core/java/android/widget/FastScroller.java +++ b/core/java/android/widget/FastScroller.java @@ -224,6 +224,8 @@ class FastScroller { mHasPendingDrag = false; } }; + private int mOldItemCount; + private int mOldChildCount; /** * Used to delay hiding fast scroll decorations. @@ -248,6 +250,8 @@ class FastScroller { public FastScroller(AbsListView listView) { mList = listView; mOverlay = listView.getOverlay(); + mOldItemCount = listView.getCount(); + mOldChildCount = listView.getChildCount(); final Context context = listView.getContext(); mScaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); @@ -258,6 +262,7 @@ class FastScroller { final ImageView trackImage = new ImageView(context); mTrackImage = trackImage; + updateLongList(mOldChildCount, mOldItemCount); int width = 0; // Add track to overlay if it has an image. @@ -445,20 +450,23 @@ class FastScroller { updateLayout(); } - public void onItemCountChanged(int totalItemCount) { - final int visibleItemCount = mList.getChildCount(); - final boolean hasMoreItems = totalItemCount - visibleItemCount > 0; - if (hasMoreItems && mState != STATE_DRAGGING) { - final int firstVisibleItem = mList.getFirstVisiblePosition(); - setThumbPos(getPosFromItemCount(firstVisibleItem, visibleItemCount, totalItemCount)); - } + public void onItemCountChanged(int childCount, int itemCount) { + if (mOldItemCount != itemCount || mOldChildCount != childCount) { + mOldItemCount = itemCount; + mOldChildCount = childCount; - updateLongList(visibleItemCount, totalItemCount); + final boolean hasMoreItems = itemCount - childCount > 0; + if (hasMoreItems && mState != STATE_DRAGGING) { + final int firstVisibleItem = mList.getFirstVisiblePosition(); + setThumbPos(getPosFromItemCount(firstVisibleItem, childCount, itemCount)); + } + + updateLongList(childCount, itemCount); + } } - private void updateLongList(int visibleItemCount, int totalItemCount) { - final boolean longList = visibleItemCount > 0 - && totalItemCount / visibleItemCount >= MIN_PAGES; + private void updateLongList(int childCount, int itemCount) { + final boolean longList = childCount > 0 && itemCount / childCount >= MIN_PAGES; if (mLongList != longList) { mLongList = longList; |
