Passing proper velocity information when simulating touch events on recents view

Change-Id: I488b8d61c47e49dbdc65b16e2470b171912efc3f
This commit is contained in:
Sunny Goyal
2019-01-28 16:46:31 -08:00
parent 0428616762
commit 703ee9f675
4 changed files with 51 additions and 13 deletions

View File

@@ -1134,9 +1134,7 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
final int activePointerId = mActivePointerId;
final int pointerIndex = ev.findPointerIndex(activePointerId);
final float x = ev.getX(pointerIndex);
final VelocityTracker velocityTracker = mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
int velocityX = (int) velocityTracker.getXVelocity(activePointerId);
int velocityX = computeXVelocity();
final int deltaX = (int) (x - mDownMotionX);
final int pageWidth = getPageAt(mCurrentPage).getMeasuredWidth();
boolean isSignificantMove = Math.abs(deltaX) > pageWidth *
@@ -1240,6 +1238,12 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
return true;
}
protected int computeXVelocity() {
final VelocityTracker velocityTracker = mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
return (int) velocityTracker.getXVelocity(mActivePointerId);
}
protected boolean shouldFlingForVelocity(int velocityX) {
return Math.abs(velocityX) > mFlingThresholdVelocity;
}