Cleanup swipe detector in case of double cancel

We manually dispatch cancel when returning to the previous state in
onDragEnd(), but could end in a bad state if getting a second,
external cancel (e.g. by pressing home). Thus, we restore the
onCancelListener after manually dispatching cancel.

Bug: 79258868
Change-Id: Idc4c33cede1d8af1829a4a744b9348d379bcf8f7
This commit is contained in:
Tony Wickham
2018-05-04 13:17:46 -07:00
parent 4c7507571c
commit fa6cbbe15b
2 changed files with 9 additions and 0 deletions

View File

@@ -244,8 +244,13 @@ public abstract class AbstractStateChangeTouchController
endProgress - Math.max(progress, 0));
}
} else {
// Let the state manager know that the animation didn't go to the target state,
// but don't cancel ourselves (we already clean up when the animation completes).
Runnable onCancel = mCurrentAnimation.getOnCancelRunnable();
mCurrentAnimation.setOnCancelRunnable(null);
mCurrentAnimation.dispatchOnCancel();
mCurrentAnimation.setOnCancelRunnable(onCancel);
endProgress = 0;
if (progress <= 0) {
duration = 0;