summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2011-08-15 18:26:39 -0700
committerAdam Cohen <adamcohen@google.com>2011-08-16 12:58:18 -0700
commitc1997fd6debbc69b53be71b7d871657fd5843c7a (patch)
tree7b73d8161c39571b35523ab9ed7c55678e144ab8 /src
parent5b1ebd63825451fea6f52e4553e59e7645ca7b59 (diff)
downloadandroid_packages_apps_Trebuchet-c1997fd6debbc69b53be71b7d871657fd5843c7a.tar.gz
android_packages_apps_Trebuchet-c1997fd6debbc69b53be71b7d871657fd5843c7a.tar.bz2
android_packages_apps_Trebuchet-c1997fd6debbc69b53be71b7d871657fd5843c7a.zip
Fixing drag and drop crashes:
-> Issue 5058353 -> Issue 3470970 Change-Id: Id790595898e86052c33e6b2f0a122e1df009c9ca
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/CellLayout.java30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 6f59d1f3c..1841713f5 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -792,27 +792,35 @@ public class CellLayout extends ViewGroup {
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
+ // First we clear the tag to ensure that on every touch down we start with a fresh slate,
+ // even in the case where we return early. Not clearing here was causing bugs whereby on
+ // long-press we'd end up picking up an item from a previous drag operation.
+ final int action = ev.getAction();
+
+ if (action == MotionEvent.ACTION_DOWN) {
+ clearTagCellInfo();
+ }
+
if (mInterceptTouchListener != null && mInterceptTouchListener.onTouch(this, ev)) {
return true;
}
- final int action = ev.getAction();
- final CellInfo cellInfo = mCellInfo;
if (action == MotionEvent.ACTION_DOWN) {
setTagToCellInfoForPoint((int) ev.getX(), (int) ev.getY());
- } else if (action == MotionEvent.ACTION_UP) {
- cellInfo.cell = null;
- cellInfo.cellX = -1;
- cellInfo.cellY = -1;
- cellInfo.spanX = 0;
- cellInfo.spanY = 0;
- setTag(cellInfo);
}
-
return false;
}
- @Override
+ private void clearTagCellInfo() {
+ final CellInfo cellInfo = mCellInfo;
+ cellInfo.cell = null;
+ cellInfo.cellX = -1;
+ cellInfo.cellY = -1;
+ cellInfo.spanX = 0;
+ cellInfo.spanY = 0;
+ setTag(cellInfo);
+ }
+
public CellInfo getTag() {
return (CellInfo) super.getTag();
}