Loading core/java/android/widget/AbsListView.java +6 −5 Original line number Original line Diff line number Diff line Loading @@ -2076,22 +2076,23 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te protected void onLayout(boolean changed, int l, int t, int r, int b) { protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); super.onLayout(changed, l, t, r, b); mInLayout = true; mInLayout = true; final int childCount = getChildCount(); if (changed) { if (changed) { int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { for (int i = 0; i < childCount; i++) { getChildAt(i).forceLayout(); getChildAt(i).forceLayout(); } } mRecycler.markChildrenDirty(); mRecycler.markChildrenDirty(); } } if (mFastScroller != null && (mItemCount != mOldItemCount || mDataChanged)) { mFastScroller.onItemCountChanged(mItemCount); } layoutChildren(); layoutChildren(); mInLayout = false; mInLayout = false; mOverscrollMax = (b - t) / OVERSCROLL_LIMIT_DIVISOR; mOverscrollMax = (b - t) / OVERSCROLL_LIMIT_DIVISOR; // TODO: Move somewhere sane. This doesn't belong in onLayout(). if (mFastScroller != null) { mFastScroller.onItemCountChanged(getChildCount(), mItemCount); } } } /** /** Loading core/java/android/widget/FastScroller.java +19 −11 Original line number Original line Diff line number Diff line Loading @@ -224,6 +224,8 @@ class FastScroller { mHasPendingDrag = false; mHasPendingDrag = false; } } }; }; private int mOldItemCount; private int mOldChildCount; /** /** * Used to delay hiding fast scroll decorations. * Used to delay hiding fast scroll decorations. Loading @@ -248,6 +250,8 @@ class FastScroller { public FastScroller(AbsListView listView) { public FastScroller(AbsListView listView) { mList = listView; mList = listView; mOverlay = listView.getOverlay(); mOverlay = listView.getOverlay(); mOldItemCount = listView.getCount(); mOldChildCount = listView.getChildCount(); final Context context = listView.getContext(); final Context context = listView.getContext(); mScaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mScaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); Loading @@ -258,6 +262,7 @@ class FastScroller { final ImageView trackImage = new ImageView(context); final ImageView trackImage = new ImageView(context); mTrackImage = trackImage; mTrackImage = trackImage; updateLongList(mOldChildCount, mOldItemCount); int width = 0; int width = 0; // Add track to overlay if it has an image. // Add track to overlay if it has an image. Loading Loading @@ -445,20 +450,23 @@ class FastScroller { updateLayout(); updateLayout(); } } public void onItemCountChanged(int totalItemCount) { public void onItemCountChanged(int childCount, int itemCount) { final int visibleItemCount = mList.getChildCount(); if (mOldItemCount != itemCount || mOldChildCount != childCount) { final boolean hasMoreItems = totalItemCount - visibleItemCount > 0; mOldItemCount = itemCount; mOldChildCount = childCount; final boolean hasMoreItems = itemCount - childCount > 0; if (hasMoreItems && mState != STATE_DRAGGING) { if (hasMoreItems && mState != STATE_DRAGGING) { final int firstVisibleItem = mList.getFirstVisiblePosition(); final int firstVisibleItem = mList.getFirstVisiblePosition(); setThumbPos(getPosFromItemCount(firstVisibleItem, visibleItemCount, totalItemCount)); setThumbPos(getPosFromItemCount(firstVisibleItem, childCount, itemCount)); } } updateLongList(visibleItemCount, totalItemCount); updateLongList(childCount, itemCount); } } } private void updateLongList(int visibleItemCount, int totalItemCount) { private void updateLongList(int childCount, int itemCount) { final boolean longList = visibleItemCount > 0 final boolean longList = childCount > 0 && itemCount / childCount >= MIN_PAGES; && totalItemCount / visibleItemCount >= MIN_PAGES; if (mLongList != longList) { if (mLongList != longList) { mLongList = longList; mLongList = longList; Loading Loading
core/java/android/widget/AbsListView.java +6 −5 Original line number Original line Diff line number Diff line Loading @@ -2076,22 +2076,23 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te protected void onLayout(boolean changed, int l, int t, int r, int b) { protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); super.onLayout(changed, l, t, r, b); mInLayout = true; mInLayout = true; final int childCount = getChildCount(); if (changed) { if (changed) { int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { for (int i = 0; i < childCount; i++) { getChildAt(i).forceLayout(); getChildAt(i).forceLayout(); } } mRecycler.markChildrenDirty(); mRecycler.markChildrenDirty(); } } if (mFastScroller != null && (mItemCount != mOldItemCount || mDataChanged)) { mFastScroller.onItemCountChanged(mItemCount); } layoutChildren(); layoutChildren(); mInLayout = false; mInLayout = false; mOverscrollMax = (b - t) / OVERSCROLL_LIMIT_DIVISOR; mOverscrollMax = (b - t) / OVERSCROLL_LIMIT_DIVISOR; // TODO: Move somewhere sane. This doesn't belong in onLayout(). if (mFastScroller != null) { mFastScroller.onItemCountChanged(getChildCount(), mItemCount); } } } /** /** Loading
core/java/android/widget/FastScroller.java +19 −11 Original line number Original line Diff line number Diff line Loading @@ -224,6 +224,8 @@ class FastScroller { mHasPendingDrag = false; mHasPendingDrag = false; } } }; }; private int mOldItemCount; private int mOldChildCount; /** /** * Used to delay hiding fast scroll decorations. * Used to delay hiding fast scroll decorations. Loading @@ -248,6 +250,8 @@ class FastScroller { public FastScroller(AbsListView listView) { public FastScroller(AbsListView listView) { mList = listView; mList = listView; mOverlay = listView.getOverlay(); mOverlay = listView.getOverlay(); mOldItemCount = listView.getCount(); mOldChildCount = listView.getChildCount(); final Context context = listView.getContext(); final Context context = listView.getContext(); mScaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mScaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); Loading @@ -258,6 +262,7 @@ class FastScroller { final ImageView trackImage = new ImageView(context); final ImageView trackImage = new ImageView(context); mTrackImage = trackImage; mTrackImage = trackImage; updateLongList(mOldChildCount, mOldItemCount); int width = 0; int width = 0; // Add track to overlay if it has an image. // Add track to overlay if it has an image. Loading Loading @@ -445,20 +450,23 @@ class FastScroller { updateLayout(); updateLayout(); } } public void onItemCountChanged(int totalItemCount) { public void onItemCountChanged(int childCount, int itemCount) { final int visibleItemCount = mList.getChildCount(); if (mOldItemCount != itemCount || mOldChildCount != childCount) { final boolean hasMoreItems = totalItemCount - visibleItemCount > 0; mOldItemCount = itemCount; mOldChildCount = childCount; final boolean hasMoreItems = itemCount - childCount > 0; if (hasMoreItems && mState != STATE_DRAGGING) { if (hasMoreItems && mState != STATE_DRAGGING) { final int firstVisibleItem = mList.getFirstVisiblePosition(); final int firstVisibleItem = mList.getFirstVisiblePosition(); setThumbPos(getPosFromItemCount(firstVisibleItem, visibleItemCount, totalItemCount)); setThumbPos(getPosFromItemCount(firstVisibleItem, childCount, itemCount)); } } updateLongList(visibleItemCount, totalItemCount); updateLongList(childCount, itemCount); } } } private void updateLongList(int visibleItemCount, int totalItemCount) { private void updateLongList(int childCount, int itemCount) { final boolean longList = visibleItemCount > 0 final boolean longList = childCount > 0 && itemCount / childCount >= MIN_PAGES; && totalItemCount / visibleItemCount >= MIN_PAGES; if (mLongList != longList) { if (mLongList != longList) { mLongList = longList; mLongList = longList; Loading