Prevent race condition when cancelling long-press for scroll.
When dragging between workspaces in rapid succession, the canceling of the original long-press timer wasn't being triggered correctly. (When the timer fires, it might read an invalid Workspace.allowLongPress() value.) This patchset correctly cancels any pending long-press timers once a desktop scroll begins, and we don't need to rely on the allowLongPress() value.
This commit is contained in:
1 parent
ecadabf578
commit
83f111d129
2 files changed
+22
No files matched your search
@@ -98,6 +98,18 @@ public class CellLayout extends ViewGroup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancelLongPress() {
|
||||||
|
super.cancelLongPress();
|
||||||
|
|
||||||
|
// Cancel long press for all children
|
||||||
|
final int count = getChildCount();
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
final View child = getChildAt(i);
|
||||||
|
child.cancelLongPress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int getCountX() {
|
int getCountX() {
|
||||||
return mPortrait ? mShortAxisCells : mLongAxisCells;
|
return mPortrait ? mShortAxisCells : mLongAxisCells;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,4 +98,14 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView {
|
|||||||
mPendingCheckForLongPress.rememberWindowAttachCount();
|
mPendingCheckForLongPress.rememberWindowAttachCount();
|
||||||
postDelayed(mPendingCheckForLongPress, ViewConfiguration.getLongPressTimeout());
|
postDelayed(mPendingCheckForLongPress, ViewConfiguration.getLongPressTimeout());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancelLongPress() {
|
||||||
|
super.cancelLongPress();
|
||||||
|
|
||||||
|
mHasPerformedLongPress = false;
|
||||||
|
if (mPendingCheckForLongPress != null) {
|
||||||
|
removeCallbacks(mPendingCheckForLongPress);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user