diff --git a/src/com/android/launcher3/util/FocusLogic.java b/src/com/android/launcher3/util/FocusLogic.java index b80e94d15e..b793f5481f 100644 --- a/src/com/android/launcher3/util/FocusLogic.java +++ b/src/com/android/launcher3/util/FocusLogic.java @@ -177,7 +177,10 @@ public class FocusLogic { } int cx = ((CellLayout.LayoutParams) cell.getLayoutParams()).cellX; int cy = ((CellLayout.LayoutParams) cell.getLayoutParams()).cellY; - matrix[invert ? (m - cx - 1) : cx][cy] = i; + int x = invert ? (m - cx - 1) : cx; + if (x < m && cy < n) { // check if view fits into matrix, else skip + matrix[x][cy] = i; + } } if (DEBUG) { printMatrix(matrix);