Send cancel event to recycled views instead of an up.
Bug #2309387
This was a problem in lists with list items that would cause notifyDatasetChanged()
interleaved with a series of up/down motion events. This is a pretty rare case
but it's worth fixing it to avoid getting views in a weird state.
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 03b569d..11b0b14 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -1507,6 +1507,13 @@
private static final int PREPRESSED = 0x02000000;
/**
+ * Indicates whether the view is temporarily detached.
+ *
+ * @hide
+ */
+ static final int CANCEL_NEXT_UP_EVENT = 0x04000000;
+
+ /**
* Always allow a user to overscroll this view, provided it is a
* view that can scroll.
*/
@@ -3668,6 +3675,7 @@
*/
public void onStartTemporaryDetach() {
removeUnsetPressCallback();
+ mPrivateFlags |= CANCEL_NEXT_UP_EVENT;
}
/**
@@ -5913,6 +5921,7 @@
* @see #onAttachedToWindow()
*/
protected void onDetachedFromWindow() {
+ mPrivateFlags &= ~CANCEL_NEXT_UP_EVENT;
removeUnsetPressCallback();
removeLongPressCallback();
destroyDrawingCache();