Merge "Check for null view root before checking for accessibility focus"
This commit is contained in:
committed by
Android (Google) Code Review
commit
35e2721399
@@ -1335,6 +1335,7 @@ public class GridView extends AbsListView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to restore accessibility focus, if necessary.
|
// Attempt to restore accessibility focus, if necessary.
|
||||||
|
if (viewRootImpl != null) {
|
||||||
final View newAccessibilityFocusedView = viewRootImpl.getAccessibilityFocusedHost();
|
final View newAccessibilityFocusedView = viewRootImpl.getAccessibilityFocusedHost();
|
||||||
if (newAccessibilityFocusedView == null) {
|
if (newAccessibilityFocusedView == null) {
|
||||||
if (accessibilityFocusLayoutRestoreView != null
|
if (accessibilityFocusLayoutRestoreView != null
|
||||||
@@ -1352,13 +1353,15 @@ public class GridView extends AbsListView {
|
|||||||
} else if (accessibilityFocusPosition != INVALID_POSITION) {
|
} else if (accessibilityFocusPosition != INVALID_POSITION) {
|
||||||
// Bound the position within the visible children.
|
// Bound the position within the visible children.
|
||||||
final int position = MathUtils.constrain(
|
final int position = MathUtils.constrain(
|
||||||
accessibilityFocusPosition - mFirstPosition, 0, getChildCount() - 1);
|
accessibilityFocusPosition - mFirstPosition, 0,
|
||||||
|
getChildCount() - 1);
|
||||||
final View restoreView = getChildAt(position);
|
final View restoreView = getChildAt(position);
|
||||||
if (restoreView != null) {
|
if (restoreView != null) {
|
||||||
restoreView.requestAccessibilityFocus();
|
restoreView.requestAccessibilityFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mLayoutMode = LAYOUT_NORMAL;
|
mLayoutMode = LAYOUT_NORMAL;
|
||||||
mDataChanged = false;
|
mDataChanged = false;
|
||||||
|
|||||||
@@ -1738,6 +1738,7 @@ public class ListView extends AbsListView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to restore accessibility focus, if necessary.
|
// Attempt to restore accessibility focus, if necessary.
|
||||||
|
if (viewRootImpl != null) {
|
||||||
final View newAccessibilityFocusedView = viewRootImpl.getAccessibilityFocusedHost();
|
final View newAccessibilityFocusedView = viewRootImpl.getAccessibilityFocusedHost();
|
||||||
if (newAccessibilityFocusedView == null) {
|
if (newAccessibilityFocusedView == null) {
|
||||||
if (accessibilityFocusLayoutRestoreView != null
|
if (accessibilityFocusLayoutRestoreView != null
|
||||||
@@ -1755,13 +1756,15 @@ public class ListView extends AbsListView {
|
|||||||
} else if (accessibilityFocusPosition != INVALID_POSITION) {
|
} else if (accessibilityFocusPosition != INVALID_POSITION) {
|
||||||
// Bound the position within the visible children.
|
// Bound the position within the visible children.
|
||||||
final int position = MathUtils.constrain(
|
final int position = MathUtils.constrain(
|
||||||
accessibilityFocusPosition - mFirstPosition, 0, getChildCount() - 1);
|
accessibilityFocusPosition - mFirstPosition, 0,
|
||||||
|
getChildCount() - 1);
|
||||||
final View restoreView = getChildAt(position);
|
final View restoreView = getChildAt(position);
|
||||||
if (restoreView != null) {
|
if (restoreView != null) {
|
||||||
restoreView.requestAccessibilityFocus();
|
restoreView.requestAccessibilityFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tell focus view we are done mucking with it, if it is still in
|
// Tell focus view we are done mucking with it, if it is still in
|
||||||
// our view hierarchy.
|
// our view hierarchy.
|
||||||
|
|||||||
Reference in New Issue
Block a user