OSDN Git Service

Fix NPE (issue 10708277)
authorAdam Cohen <adamcohen@google.com>
Mon, 16 Sep 2013 21:09:28 +0000 (14:09 -0700)
committerAdam Cohen <adamcohen@google.com>
Mon, 16 Sep 2013 21:35:25 +0000 (14:35 -0700)
Change-Id: I76cc74ae4e75bb9a0c1437c2f7d1c27b2fc6afd7

src/com/android/launcher3/Workspace.java

index 09f37c4..eed5b23 100644 (file)
@@ -1704,19 +1704,11 @@ public class Workspace extends SmoothPagedView
     protected void getOverviewModePages(int[] range) {
         int count = mScreenOrder.size();
 
-        int start = -1;
-        int end = -1;
-        //
-        for (int i = 0; i < count; i++) {
-            if (start < 0 && mScreenOrder.get(i) >= 0) {
-                start = i;
-            }
-            if (start >=0 && mScreenOrder.get(i) >= 0) {
-                end = i;
-            }
-        }
-        range[0] = start;
-        range[1] = end;
+        int start = hasCustomContent() ? 1 : 0;
+        int end = getChildCount() - 1;
+
+        range[0] = Math.max(0, Math.min(start, getChildCount() - 1));
+        range[1] = Math.max(0,  end);
      }
 
     protected void onStartReordering() {