Skip to content

Commit e136a72

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Text layout in switch may be null when accessibility events are fired." into jb-mr1-dev
2 parents 0dbc410 + b8c50e8 commit e136a72

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

core/java/android/widget/Switch.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,9 @@ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
508508
@Override
509509
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
510510
super.onPopulateAccessibilityEvent(event);
511-
CharSequence text = isChecked() ? mOnLayout.getText() : mOffLayout.getText();
512-
if (!TextUtils.isEmpty(text)) {
513-
event.getText().add(text);
511+
Layout layout = isChecked() ? mOnLayout : mOffLayout;
512+
if (layout != null && !TextUtils.isEmpty(layout.getText())) {
513+
event.getText().add(layout.getText());
514514
}
515515
}
516516

0 commit comments

Comments
 (0)