Fixing crash due to grabbing oob screen index. (Bug 10114488)

Change-Id: I9e0c3d9bfcf96f092260a82b930b7ea728b6e98d
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 2d23f36..9424eef 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -3717,15 +3717,15 @@
             final int page = getNextPage() +
                        (direction == DragController.SCROLL_LEFT ? -1 : 1);
 
-            // Ensure that we are not dragging over to the custom content screen
-            if (getScreenIdForPageIndex(page) == CUSTOM_CONTENT_SCREEN_ID) {
-                return false;
-            }
-
             // We always want to exit the current layout to ensure parity of enter / exit
             setCurrentDropLayout(null);
 
             if (0 <= page && page < getChildCount()) {
+                // Ensure that we are not dragging over to the custom content screen
+                if (getScreenIdForPageIndex(page) == CUSTOM_CONTENT_SCREEN_ID) {
+                    return false;
+                }
+
                 CellLayout layout = (CellLayout) getChildAt(page);
                 setCurrentDragOverlappingLayout(layout);