Fix swipe-to-dismiss to properly react to swipe gestures.

Test: manual test
Bug: 33588580
Change-Id: If8d03f90a25e989e254e3a21bafef4e76bab5d7b
This commit is contained in:
Michael Kwan
2016-12-13 17:10:12 -08:00
parent 3350ae9c82
commit 8a9b27773b

View File

@@ -330,18 +330,16 @@ public class SwipeDismissLayout extends FrameLayout {
mVelocityTracker.addMovement(ev);
mVelocityTracker.computeCurrentVelocity(1000);
if (!mDismissed) {
if (deltaX > (getWidth() * DISMISS_MIN_DRAG_WIDTH_RATIO) &&
ev.getRawX() >= mLastX) {
if ((deltaX > (getWidth() * DISMISS_MIN_DRAG_WIDTH_RATIO) &&
ev.getRawX() >= mLastX)
|| mVelocityTracker.getXVelocity() >= mMinFlingVelocity) {
mDismissed = true;
}
}
// Check if the user tried to undo this.
if (mDismissed && mSwiping) {
// Check if the user's finger is actually back
if (deltaX < (getWidth() * DISMISS_MIN_DRAG_WIDTH_RATIO) ||
// or user is flinging back left
mVelocityTracker.getXVelocity() < -mMinFlingVelocity) {
// Check if the user's finger is actually flinging back to left
if (mVelocityTracker.getXVelocity() < -mMinFlingVelocity) {
mDismissed = false;
}
}