Handling getLastItem when the folder is closed

Change-Id: I6afebd7c0a92edb25e3658e7f860244d7457c852
This commit is contained in:
Sunny Goyal
2015-03-05 16:56:12 -08:00
parent ee995106d8
commit 1c0e633bd5
@@ -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