From 1c0e633bd59e0f14f799cbb6aee33266032998fa Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Thu, 5 Mar 2015 16:56:12 -0800 Subject: [PATCH] Handling getLastItem when the folder is closed Change-Id: I6afebd7c0a92edb25e3658e7f860244d7457c852 --- src/com/android/launcher3/FolderCellLayout.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/FolderCellLayout.java b/src/com/android/launcher3/FolderCellLayout.java index e6e9199e83..b354ec74e9 100644 --- a/src/com/android/launcher3/FolderCellLayout.java +++ b/src/com/android/launcher3/FolderCellLayout.java @@ -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