Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.

Commit

Permalink
Allow ValueVelocityTracker methods to be called out of order.
Browse files Browse the repository at this point in the history
Summary:
This better guards against unexpected touch event streams.
Fixes #5

Reviewers: O2 Material Motion, O6 Material Android platform reviewers, #material_motion, randcode-generator

Reviewed By: randcode-generator

Tags: #material_motion

Differential Revision: http://codereview.cc/D3105
  • Loading branch information
Mark Wei committed Apr 24, 2017
1 parent ce93fb3 commit e0cbcce
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -119,6 +119,10 @@ public void onGestureMove(MotionEvent event, float value) {
* Must be balanced with a previous call to {@link #onGestureStart(MotionEvent, float)}.
*/
public void onGestureEnd(MotionEvent event, float value) {
if (velocityTracker == null) {
return;
}

addValueMovement(event, value);

velocityTracker.computeCurrentVelocity(PIXELS_PER_SECOND, maximumFlingVelocity);
Expand All @@ -129,6 +133,10 @@ public void onGestureEnd(MotionEvent event, float value) {
}

private void addValueMovement(MotionEvent event, float value) {
if (velocityTracker == null) {
return;
}

int valueMovementAction;

int action = MotionEventCompat.getActionMasked(event);
Expand Down

0 comments on commit e0cbcce

Please sign in to comment.