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

Commit 237b7405 authored by Kyle Horimoto's avatar Kyle Horimoto
Browse files

Fix band select UI issue.

The issue was that scrolling past the top or bottom of the view caused the band
select rectangle to grow in the wrong direction. This was caused by adjusting
the origin of the band select rectangle based on the calculated number of pixels
to scroll instead of the actual number of pixels scrolled. There can be a
discrepancy when the calculated value is higher than the maximum that can be
scrolled (when the view is already scroll almost to the top or bottom of the
view).

Bug: 23081362

Change-Id: I343cdec89260ab0571a792009d0c08585ed41199
parent 62a7fd0e
Loading
Loading
Loading
Loading
+16 −6
Original line number Original line Diff line number Diff line
@@ -879,6 +879,7 @@ public final class MultiSelectManager {
     */
     */
    interface BandManagerHelper {
    interface BandManagerHelper {
        void drawBand(Rect rect);
        void drawBand(Rect rect);
        void addOnScrollListener(RecyclerView.OnScrollListener listener);
        int findEventPosition(MotionEvent e);
        int findEventPosition(MotionEvent e);
        int getHeight();
        int getHeight();
        void hideBand();
        void hideBand();
@@ -1164,7 +1165,8 @@ public final class MultiSelectManager {
     * and {@link MultiSelectManager}. This class is responsible for rendering the band select
     * and {@link MultiSelectManager}. This class is responsible for rendering the band select
     * overlay and selecting overlaid items via MultiSelectManager.
     * overlay and selecting overlaid items via MultiSelectManager.
     */
     */
    public class BandSelectManager implements BandSelectModel.OnSelectionChangedListener {
    public class BandSelectManager extends RecyclerView.OnScrollListener
            implements BandSelectModel.OnSelectionChangedListener {


        private static final int NOT_SET = -1;
        private static final int NOT_SET = -1;


@@ -1184,6 +1186,7 @@ public final class MultiSelectManager {
        public <T extends BandManagerHelper & BandModelHelper>
        public <T extends BandManagerHelper & BandModelHelper>
                BandSelectManager(T helper) {
                BandSelectManager(T helper) {
            mHelper = helper;
            mHelper = helper;
            mHelper.addOnScrollListener(this);
            mModel = new BandSelectModel(helper);
            mModel = new BandSelectModel(helper);
            mModel.addOnSelectionChangedListener(this);
            mModel.addOnSelectionChangedListener(this);
        }
        }
@@ -1316,11 +1319,6 @@ public final class MultiSelectManager {
                        pixelsPastView, System.currentTimeMillis() - mScrollStartTime);
                        pixelsPastView, System.currentTimeMillis() - mScrollStartTime);
                mHelper.scrollBy(numPixels);
                mHelper.scrollBy(numPixels);


                // Adjust the y-coordinate of the origin the opposite number of pixels so that the
                // origin remains in the same place relative to the view's items.
                mOrigin.y -= numPixels;
                resizeBandSelectRectangle();

                mHelper.removeCallback(mViewScroller);
                mHelper.removeCallback(mViewScroller);
                mHelper.postRunnable(this);
                mHelper.postRunnable(this);
            }
            }
@@ -1386,6 +1384,18 @@ public final class MultiSelectManager {
                return (float) Math.pow(ratio, 5);
                return (float) Math.pow(ratio, 5);
            }
            }
        };
        };

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            if (!mIsActive) {
                return;
            }

            // Adjust the y-coordinate of the origin the opposite number of pixels so that the
            // origin remains in the same place relative to the view's items.
            mOrigin.y -= dy;
            resizeBandSelectRectangle();
        }
    }
    }


    /**
    /**