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
diff --git a/src/com/android/launcher2/CustomizePagedView.java b/src/com/android/launcher2/CustomizePagedView.java
index 2f2cb24..2b54e3f 100644
--- a/src/com/android/launcher2/CustomizePagedView.java
+++ b/src/com/android/launcher2/CustomizePagedView.java
@@ -337,14 +337,15 @@
 
     /**
      * 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 @@
 
         // 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);