Merge "Text layout in switch may be null when accessibility events are fired." into jb-mr1-dev

This commit is contained in:
Svetoslav Ganov
2012-09-14 11:37:15 -07:00
committed by Android (Google) Code Review

View File

@@ -508,9 +508,9 @@ public class Switch extends CompoundButton {
@Override
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
super.onPopulateAccessibilityEvent(event);
CharSequence text = isChecked() ? mOnLayout.getText() : mOffLayout.getText();
if (!TextUtils.isEmpty(text)) {
event.getText().add(text);
Layout layout = isChecked() ? mOnLayout : mOffLayout;
if (layout != null && !TextUtils.isEmpty(layout.getText())) {
event.getText().add(layout.getText());
}
}