summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick Dubroy <dubroy@google.com>2011-02-24 12:16:12 -0800
committerPatrick Dubroy <dubroy@google.com>2011-02-24 16:50:55 -0800
commit6f13342ffd3f968de9ff86b988621cc91d94adff (patch)
tree1ff2bc870a47f3fb909d60a670f7d55e6ce19b72 /src
parenta0aa0121b91fde17e427ab2763ce312e64cf5d33 (diff)
downloadandroid_packages_apps_Trebuchet-6f13342ffd3f968de9ff86b988621cc91d94adff.tar.gz
android_packages_apps_Trebuchet-6f13342ffd3f968de9ff86b988621cc91d94adff.tar.bz2
android_packages_apps_Trebuchet-6f13342ffd3f968de9ff86b988621cc91d94adff.zip
Fix 3482911: NPE in CustomizePagedView.resetCheckedItem
Also fixes an issue where quick swipes on an item could cause it to animate in from (0, 0) sometimes. Change-Id: Ie3312389bcb5109f4b26ec518a29b4aa88161377
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/CustomizePagedView.java16
-rw-r--r--src/com/android/launcher2/DragView.java8
-rw-r--r--src/com/android/launcher2/PagedView.java10
3 files changed, 17 insertions, 17 deletions
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index 2f2cb24ab..2b54e3f3c 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -337,14 +337,15 @@ public class CustomizePagedView extends PagedViewWithDraggableItems
/**
* Similar to resetCheckedGrandchildren, but allows us to specify that it's not animated.
- * NOTE: This assumes that only a single item can be checked.
*/
private void resetCheckedItem(boolean animated) {
- Checkable checkable = getCheckedGrandchildren().get(0);
- if (checkable instanceof PagedViewWidget) {
- ((PagedViewWidget) checkable).setChecked(false, animated);
- } else {
- ((PagedViewIcon) checkable).setChecked(false, animated);
+ final Checkable checkable = getSingleCheckedGrandchild();
+ if (checkable != null) {
+ if (checkable instanceof PagedViewWidget) {
+ ((PagedViewWidget) checkable).setChecked(false, animated);
+ } else {
+ ((PagedViewIcon) checkable).setChecked(false, animated);
+ }
}
}
@@ -353,8 +354,7 @@ public class CustomizePagedView extends PagedViewWithDraggableItems
// Create a view, identical to the drag view, that is only used for animating the
// item onto the home screen (or back to its original position, if the drop failed).
- final int[] pos = new int[2];
- mDragController.getDragView().getLocationOnScreen(pos);
+ final int[] pos = mDragController.getDragView().getPosition(null);
final View animView = dragLayer.createDragView(mDragBitmap, pos[0], pos[1]);
animView.setVisibility(View.VISIBLE);
diff --git a/src/com/android/launcher2/DragView.java b/src/com/android/launcher2/DragView.java
index c0776a9f2..45620b90b 100644
--- a/src/com/android/launcher2/DragView.java
+++ b/src/com/android/launcher2/DragView.java
@@ -245,5 +245,13 @@ public class DragView extends View {
void remove() {
mWindowManager.removeView(this);
}
+
+ int[] getPosition(int[] result) {
+ WindowManager.LayoutParams lp = mLayoutParams;
+ if (result == null) result = new int[2];
+ result[0] = lp.x;
+ result[1] = lp.y;
+ return result;
+ }
}
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 41521041d..66383cb6b 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -1420,7 +1420,7 @@ public abstract class PagedView extends ViewGroup {
* Otherwise, returns null.
*/
protected Checkable getSingleCheckedGrandchild() {
- if (mChoiceMode == CHOICE_MODE_SINGLE) {
+ if (mChoiceMode != CHOICE_MODE_MULTIPLE) {
final int childCount = getChildCount();
for (int i = 0; i < childCount; ++i) {
Page layout = (Page) getChildAt(i);
@@ -1436,14 +1436,6 @@ public abstract class PagedView extends ViewGroup {
return null;
}
- public Object getChosenItem() {
- View checkedView = (View) getSingleCheckedGrandchild();
- if (checkedView != null) {
- return checkedView.getTag();
- }
- return null;
- }
-
protected void resetCheckedGrandchildren() {
// loop through children, and set all of their children to _not_ be checked
final ArrayList<Checkable> checked = getCheckedGrandchildren();