diff options
author | linus_lee <llee@cyngn.com> | 2014-10-31 13:16:37 -0700 |
---|---|---|
committer | linus_lee <llee@cyngn.com> | 2014-11-20 12:51:36 -0800 |
commit | 9dcf86bfdb01bca31a241f236f2b86dd582d3599 (patch) | |
tree | 607fdfc2fcd75e637327cf0cdda648f1442b9aea | |
parent | 987b2801408db287c26f2bc87bc3913862570efc (diff) | |
download | android_packages_apps_Eleven-9dcf86bfdb01bca31a241f236f2b86dd582d3599.tar.gz android_packages_apps_Eleven-9dcf86bfdb01bca31a241f236f2b86dd582d3599.tar.bz2 android_packages_apps_Eleven-9dcf86bfdb01bca31a241f236f2b86dd582d3599.zip |
Eleven: Fix perf for rearranging a very long list
The scroller would want to scroll through the list too quickly and the logic
would execute too much logic during the layout phase - for now just cap the max
scroll speed
https://cyanogen.atlassian.net/browse/MUSIC-174
Change-Id: I61ac30feb43afe672a8a38637b97ee622e332268
-rw-r--r-- | src/com/cyngn/eleven/dragdrop/DragSortListView.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/com/cyngn/eleven/dragdrop/DragSortListView.java b/src/com/cyngn/eleven/dragdrop/DragSortListView.java index 86a2ddc..1e7acc1 100644 --- a/src/com/cyngn/eleven/dragdrop/DragSortListView.java +++ b/src/com/cyngn/eleven/dragdrop/DragSortListView.java @@ -1448,6 +1448,7 @@ public class DragSortListView extends ListView { } } mWidthMeasureSpec = widthMeasureSpec; + mDragScroller.setListHeight(getHeight()); } /** @@ -1888,6 +1889,8 @@ public class DragSortListView extends ListView { private boolean mScrolling = false; + private int mMaxScrollSpeed; + public boolean isScrolling() { return mScrolling; } @@ -1921,6 +1924,11 @@ public class DragSortListView extends ListView { } + public void setListHeight(final int height) { + // cap the max scroll speed per frame to be 1/5 of the list height + mMaxScrollSpeed = height / 5; + } + /** * {@inheritDoc} */ @@ -1976,6 +1984,9 @@ public class DragSortListView extends ListView { dy = Math.round(mScrollSpeed * dt); mScrollY += dy; + // cap the scroll speed + mScrollY = Math.max(Math.min(mScrollY, mMaxScrollSpeed), -mMaxScrollSpeed); + requestLayout(); mPrevTime += dt; |