Fixing bug where widget could get added to drag layer and not removed (issue 6282757)

Change-Id: Ibc32b48f12e1c37267e140e82e1620bcb407963c
This commit is contained in:
Adam Cohen
2012-05-11 15:57:05 -07:00
parent 28b952ad3e
commit 0e56cc9fd6
2 changed files with 41 additions and 22 deletions

View File

@@ -42,6 +42,7 @@ public class PagedViewWidget extends LinearLayout {
CheckForShortPress mPendingCheckForShortPress = null;
ShortPressListener mShortPressListener = null;
boolean mShortPressTriggered = false;
static PagedViewWidget sShortpressTarget = null;
public PagedViewWidget(Context context) {
this(context, null);
@@ -141,13 +142,16 @@ public class PagedViewWidget extends LinearLayout {
class CheckForShortPress implements Runnable {
public void run() {
if (mShortPressListener != null) {
if (sShortpressTarget != null) return;
mShortPressListener.onShortPress(PagedViewWidget.this);
}
sShortpressTarget = PagedViewWidget.this;
mShortPressTriggered = true;
}
}
private void checkForShortPress() {
if (sShortpressTarget != null) return;
if (mPendingCheckForShortPress == null) {
mPendingCheckForShortPress = new CheckForShortPress();
}
@@ -173,6 +177,10 @@ public class PagedViewWidget extends LinearLayout {
}
}
static void resetShortPressTarget() {
sShortpressTarget = null;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);
@@ -190,6 +198,7 @@ public class PagedViewWidget extends LinearLayout {
case MotionEvent.ACTION_MOVE:
break;
}
// We eat up the touch events here, since the PagedView (which uses the same swiping
// touch code as Workspace previously) uses onInterceptTouchEvent() to determine when
// the user is scrolling between pages. This means that if the pages themselves don't