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

Commit 59f0ef35 authored by Jerry Chang's avatar Jerry Chang
Browse files

Fix tapping on divider bar several times makes split sloggish

Make sure it won't introduce redundant fling animation when touch on
divider bar didn't exceed tap threshold. This make sure it won't queue
extra sync transactions with SyncTransactionQueue. Also skip redundant
checks after detected double tap in staged split.

Fix: 186626153
Fix: 179004532
Test: tapping on divider bar of legacy and staged split, it won't make
split sloggish.

Change-Id: I2a326f54f25d77e86fa51bca67b68daca21dedfc
parent 8a170b2e
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -110,6 +110,10 @@ public class DividerView extends FrameLayout implements View.OnTouchListener,
            return false;
        }

        if (mDoubleTapDetector.onTouchEvent(event)) {
            return true;
        }

        final int action = event.getAction() & MotionEvent.ACTION_MASK;
        final boolean isLandscape = isLandscape();
        // Using raw xy to prevent lost track of motion events while moving divider bar.
@@ -136,21 +140,22 @@ public class DividerView extends FrameLayout implements View.OnTouchListener,
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                mVelocityTracker.addMovement(event);
                releaseTouching();

                if (!mMoving) break;

                mVelocityTracker.computeCurrentVelocity(1000 /* units */);
                final float velocity = isLandscape
                        ? mVelocityTracker.getXVelocity()
                        : mVelocityTracker.getYVelocity();
                releaseTouching();
                mMoving = false;

                final int position = mSplitLayout.getDividePosition() + touchPos - mStartPos;
                final DividerSnapAlgorithm.SnapTarget snapTarget =
                        mSplitLayout.findSnapTarget(position, velocity, false /* hardDismiss */);
                mSplitLayout.snapToTarget(position, snapTarget);
                mMoving = false;
                break;
        }

        mDoubleTapDetector.onTouchEvent(event);
        return true;
    }

@@ -229,7 +234,7 @@ public class DividerView extends FrameLayout implements View.OnTouchListener,
            if (mSplitLayout != null) {
                mSplitLayout.onDoubleTappedDivider();
            }
            return false;
            return true;
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -231,6 +231,7 @@ public class SplitLayout {
    }

    private void flingDividePosition(int from, int to) {
        if (from == to) return;
        ValueAnimator animator = ValueAnimator
                .ofInt(from, to)
                .setDuration(250);
+2 −2
Original line number Diff line number Diff line
@@ -49,7 +49,6 @@ import android.view.VelocityTracker;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewConfiguration;
import android.view.ViewRootImpl;
import android.view.ViewTreeObserver.InternalInsetsInfo;
import android.view.ViewTreeObserver.OnComputeInternalInsetsListener;
import android.view.WindowManager;
@@ -524,9 +523,10 @@ public class DividerView extends FrameLayout implements OnTouchListener,
            case MotionEvent.ACTION_CANCEL:
                mVelocityTracker.addMovement(event);

                if (!mMoving) break;

                x = (int) event.getRawX();
                y = (int) event.getRawY();

                mVelocityTracker.computeCurrentVelocity(1000);
                int position = calculatePosition(x, y);
                stopDragging(position, isHorizontalDivision() ? mVelocityTracker.getYVelocity()