From a1567d50d0cbf4ed91207e005870a688a63a5f04 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Wed, 15 Apr 2020 16:00:01 -0700 Subject: [PATCH] Prevent two overlapping long press actions. We add a check in CheckLongPressHelper to not trigger long press if the view is already in the pressed state. This fixes the bug where a stranded DragView is left in the DragLayer. Repo's every 50 tries: - Open folder - Long click and slightly drag the same item over and over in slightly different directions. Logs show that long click on folder item initiates the first long click, and then later on CheckLongPressHelper triggers another long press before the initial one is finished. Bug: 151053858 Change-Id: Ifbb6919e4f0153aaef2904f704baa284e78f1e83 --- src/com/android/launcher3/CheckLongPressHelper.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/CheckLongPressHelper.java b/src/com/android/launcher3/CheckLongPressHelper.java index ef353f9404..ff405ece3e 100644 --- a/src/com/android/launcher3/CheckLongPressHelper.java +++ b/src/com/android/launcher3/CheckLongPressHelper.java @@ -113,7 +113,10 @@ public class CheckLongPressHelper { } private void triggerLongPress() { - if ((mView.getParent() != null) && mView.hasWindowFocus() && !mHasPerformedLongPress) { + if ((mView.getParent() != null) + && mView.hasWindowFocus() + && (!mView.isPressed() || mListener == null) + && !mHasPerformedLongPress) { boolean handled; if (mListener != null) { handled = mListener.onLongClick(mView);