Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9dcf86bf authored by linus_lee's avatar linus_lee
Browse files

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
parent 987b2801
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -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;