OSDN Git Service

Handling getLastItem when the folder is closed
authorSunny Goyal <sunnygoyal@google.com>
Fri, 6 Mar 2015 00:56:12 +0000 (16:56 -0800)
committerSunny Goyal <sunnygoyal@google.com>
Fri, 6 Mar 2015 02:03:08 +0000 (18:03 -0800)
Change-Id: I6afebd7c0a92edb25e3658e7f860244d7457c852

src/com/android/launcher3/FolderCellLayout.java

index e6e9199..b354ec7 100644 (file)
@@ -245,7 +245,13 @@ public class FolderCellLayout extends CellLayout implements Folder.FolderContent
     @Override
     public View getLastItem() {
         int lastRank = getShortcutsAndWidgets().getChildCount() - 1;
-        return getShortcutsAndWidgets().getChildAt(lastRank % getCountX(), lastRank / getCountX());
+        // count can be zero if the folder is not yet laid out.
+        int count = getCountX();
+        if (count > 0) {
+            return getShortcutsAndWidgets().getChildAt(lastRank % count, lastRank / count);
+        } else {
+            return getShortcutsAndWidgets().getChildAt(lastRank);
+        }
     }
 
     @Override