diff options
author | Alan Viverette <alanv@google.com> | 2014-02-24 19:09:59 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-02-24 19:09:59 +0000 |
commit | 35e27213990d182c5085a16dc7bb0e8d2ce69e90 (patch) | |
tree | 8407f22471c954f4ddbb1d723bd58b7ccf668b54 /core/java | |
parent | 688084914dad7f6d043e5134d47a02bf119c1a42 (diff) | |
parent | 2e6fc8ca5696367a680656f73c1b9b95648eb6fa (diff) | |
download | frameworks_base-35e27213990d182c5085a16dc7bb0e8d2ce69e90.zip frameworks_base-35e27213990d182c5085a16dc7bb0e8d2ce69e90.tar.gz frameworks_base-35e27213990d182c5085a16dc7bb0e8d2ce69e90.tar.bz2 |
Merge "Check for null view root before checking for accessibility focus"
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/widget/GridView.java | 45 | ||||
-rw-r--r-- | core/java/android/widget/ListView.java | 45 |
2 files changed, 48 insertions, 42 deletions
diff --git a/core/java/android/widget/GridView.java b/core/java/android/widget/GridView.java index 4ed48ff..04b18c1 100644 --- a/core/java/android/widget/GridView.java +++ b/core/java/android/widget/GridView.java @@ -1335,27 +1335,30 @@ public class GridView extends AbsListView { } // Attempt to restore accessibility focus, if necessary. - final View newAccessibilityFocusedView = viewRootImpl.getAccessibilityFocusedHost(); - if (newAccessibilityFocusedView == null) { - if (accessibilityFocusLayoutRestoreView != null - && accessibilityFocusLayoutRestoreView.isAttachedToWindow()) { - final AccessibilityNodeProvider provider = - accessibilityFocusLayoutRestoreView.getAccessibilityNodeProvider(); - if (accessibilityFocusLayoutRestoreNode != null && provider != null) { - final int virtualViewId = AccessibilityNodeInfo.getVirtualDescendantId( - accessibilityFocusLayoutRestoreNode.getSourceNodeId()); - provider.performAction(virtualViewId, - AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null); - } else { - accessibilityFocusLayoutRestoreView.requestAccessibilityFocus(); - } - } else if (accessibilityFocusPosition != INVALID_POSITION) { - // Bound the position within the visible children. - final int position = MathUtils.constrain( - accessibilityFocusPosition - mFirstPosition, 0, getChildCount() - 1); - final View restoreView = getChildAt(position); - if (restoreView != null) { - restoreView.requestAccessibilityFocus(); + if (viewRootImpl != null) { + final View newAccessibilityFocusedView = viewRootImpl.getAccessibilityFocusedHost(); + if (newAccessibilityFocusedView == null) { + if (accessibilityFocusLayoutRestoreView != null + && accessibilityFocusLayoutRestoreView.isAttachedToWindow()) { + final AccessibilityNodeProvider provider = + accessibilityFocusLayoutRestoreView.getAccessibilityNodeProvider(); + if (accessibilityFocusLayoutRestoreNode != null && provider != null) { + final int virtualViewId = AccessibilityNodeInfo.getVirtualDescendantId( + accessibilityFocusLayoutRestoreNode.getSourceNodeId()); + provider.performAction(virtualViewId, + AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null); + } else { + accessibilityFocusLayoutRestoreView.requestAccessibilityFocus(); + } + } else if (accessibilityFocusPosition != INVALID_POSITION) { + // Bound the position within the visible children. + final int position = MathUtils.constrain( + accessibilityFocusPosition - mFirstPosition, 0, + getChildCount() - 1); + final View restoreView = getChildAt(position); + if (restoreView != null) { + restoreView.requestAccessibilityFocus(); + } } } } diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java index 63e1358..5de67c8 100644 --- a/core/java/android/widget/ListView.java +++ b/core/java/android/widget/ListView.java @@ -1738,27 +1738,30 @@ public class ListView extends AbsListView { } // Attempt to restore accessibility focus, if necessary. - final View newAccessibilityFocusedView = viewRootImpl.getAccessibilityFocusedHost(); - if (newAccessibilityFocusedView == null) { - if (accessibilityFocusLayoutRestoreView != null - && accessibilityFocusLayoutRestoreView.isAttachedToWindow()) { - final AccessibilityNodeProvider provider = - accessibilityFocusLayoutRestoreView.getAccessibilityNodeProvider(); - if (accessibilityFocusLayoutRestoreNode != null && provider != null) { - final int virtualViewId = AccessibilityNodeInfo.getVirtualDescendantId( - accessibilityFocusLayoutRestoreNode.getSourceNodeId()); - provider.performAction(virtualViewId, - AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null); - } else { - accessibilityFocusLayoutRestoreView.requestAccessibilityFocus(); - } - } else if (accessibilityFocusPosition != INVALID_POSITION) { - // Bound the position within the visible children. - final int position = MathUtils.constrain( - accessibilityFocusPosition - mFirstPosition, 0, getChildCount() - 1); - final View restoreView = getChildAt(position); - if (restoreView != null) { - restoreView.requestAccessibilityFocus(); + if (viewRootImpl != null) { + final View newAccessibilityFocusedView = viewRootImpl.getAccessibilityFocusedHost(); + if (newAccessibilityFocusedView == null) { + if (accessibilityFocusLayoutRestoreView != null + && accessibilityFocusLayoutRestoreView.isAttachedToWindow()) { + final AccessibilityNodeProvider provider = + accessibilityFocusLayoutRestoreView.getAccessibilityNodeProvider(); + if (accessibilityFocusLayoutRestoreNode != null && provider != null) { + final int virtualViewId = AccessibilityNodeInfo.getVirtualDescendantId( + accessibilityFocusLayoutRestoreNode.getSourceNodeId()); + provider.performAction(virtualViewId, + AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null); + } else { + accessibilityFocusLayoutRestoreView.requestAccessibilityFocus(); + } + } else if (accessibilityFocusPosition != INVALID_POSITION) { + // Bound the position within the visible children. + final int position = MathUtils.constrain( + accessibilityFocusPosition - mFirstPosition, 0, + getChildCount() - 1); + final View restoreView = getChildAt(position); + if (restoreView != null) { + restoreView.requestAccessibilityFocus(); + } } } } |