Fixing launcher ANR (issue 6238175)

Change-Id: I6518ea9e6ce8b50a5f2a3b24e909e18c5b1bde51
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index fb319fe..79d8dc5 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -189,6 +189,8 @@
         mCountY = LauncherModel.getCellCountY();
         mOccupied = new boolean[mCountX][mCountY];
         mTmpOccupied = new boolean[mCountX][mCountY];
+        mPreviousReorderDirection[0] = INVALID_DIRECTION;
+        mPreviousReorderDirection[1] = INVALID_DIRECTION;
 
         a.recycle();
 
@@ -1564,7 +1566,8 @@
         float bestDistance = Float.MAX_VALUE;
 
         // We use this to march in a single direction
-        if (direction[0] != 0 && direction[1] != 0) { 
+        if ((direction[0] != 0 && direction[1] != 0) ||
+                (direction[0] == 0 && direction[1] == 0)) {
             return bestXY;
         }