am 1c0e633b: Handling getLastItem when the folder is closed
* commit '1c0e633bd59e0f14f799cbb6aee33266032998fa':
Handling getLastItem when the folder is closed
diff --git a/src/com/android/launcher3/FolderCellLayout.java b/src/com/android/launcher3/FolderCellLayout.java
index e6e9199..b354ec7 100644
--- a/src/com/android/launcher3/FolderCellLayout.java
+++ b/src/com/android/launcher3/FolderCellLayout.java
@@ -245,7 +245,13 @@
@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