Skip to content

Commit 9834851

Browse files
committed
DO NOT MERGE AdapterView#isScrollableForAccessibility does not handle null adapter.
Cherry picking since branching caught us in the middle of review. 1. If an AdapterView has no adapter and the view tries to fire an accessibility event we get a null pointer exception. bug:5439321 Change-Id: Ia3d7a5ad852ef42422d10d8a62c4d3af6792313b
1 parent 99f3668 commit 9834851

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

core/java/android/widget/AdapterView.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -928,9 +928,13 @@ public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
928928
}
929929

930930
private boolean isScrollableForAccessibility() {
931-
final int itemCount = getAdapter().getCount();
932-
return itemCount > 0
933-
&& (getFirstVisiblePosition() > 0 || getLastVisiblePosition() < itemCount - 1);
931+
T adapter = getAdapter();
932+
if (adapter != null) {
933+
final int itemCount = adapter.getCount();
934+
return itemCount > 0
935+
&& (getFirstVisiblePosition() > 0 || getLastVisiblePosition() < itemCount - 1);
936+
}
937+
return false;
934938
}
935939

936940
@Override

0 commit comments

Comments
 (0)