Merge "Fix tapping on divider bar several times makes split sloggish" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-04-29 00:09:14 +00:00
committed by Android (Google) Code Review
3 changed files with 13 additions and 7 deletions

View File

@@ -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;
}
}
}

View File

@@ -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);

View File

@@ -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()