From 1ac777c42e5eb9f17337a55b66e741d0272ac641 Mon Sep 17 00:00:00 2001 From: Raj Yengisetty Date: Wed, 8 Jul 2015 16:40:32 -0700 Subject: FocusHelper: handle NPE with when getting workspace child Change-Id: I1955f4ea83f260272b29e93bf3346ed642f4ae95 --- src/com/android/launcher3/FocusHelper.java | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/com/android/launcher3') diff --git a/src/com/android/launcher3/FocusHelper.java b/src/com/android/launcher3/FocusHelper.java index d529b3901..d4a908f64 100644 --- a/src/com/android/launcher3/FocusHelper.java +++ b/src/com/android/launcher3/FocusHelper.java @@ -492,14 +492,18 @@ public class FocusHelper { if (workspace != null) { int pageIndex = workspace.getCurrentPage(); CellLayout topLayout = (CellLayout) workspace.getChildAt(pageIndex); - ShortcutAndWidgetContainer children = topLayout.getShortcutsAndWidgets(); - final View newIcon = getIconInDirection(layout, children, -1, 1); - // Select the first bubble text view in the current page of the workspace - if (newIcon != null) { - newIcon.requestFocus(); - v.playSoundEffect(SoundEffectConstants.NAVIGATION_UP); - } else { - workspace.requestFocus(); + ShortcutAndWidgetContainer children = topLayout != null ? + topLayout.getShortcutsAndWidgets() : null; + if (children != null) { + final View newIcon = getIconInDirection(layout, children, -1, 1); + // Select the first bubble text view in the current page of the + // workspace + if (newIcon != null) { + newIcon.requestFocus(); + v.playSoundEffect(SoundEffectConstants.NAVIGATION_UP); + } else { + workspace.requestFocus(); + } } } } -- cgit v1.2.3