Skip to content

Commit 5cd164c

Browse files
Gilles DebunneAndroid (Google) Code Review
authored andcommitted
Merge "Fix NPE on Activity start in TextView"
2 parents 93d083b + c1e79b4 commit 5cd164c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/java/android/widget/TextView.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2980,8 +2980,7 @@ public void onRestoreInstanceState(Parcelable state) {
29802980
"/" + ss.selEnd + " out of range for " + restored +
29812981
"text " + mText);
29822982
} else {
2983-
Selection.setSelection((Spannable) mText, ss.selStart,
2984-
ss.selEnd);
2983+
Selection.setSelection((Spannable) mText, ss.selStart, ss.selEnd);
29852984

29862985
if (ss.frozenWithFocus) {
29872986
createEditorIfNeeded("restore instance with focus");
@@ -6983,6 +6982,9 @@ protected void onTextChanged(CharSequence text, int start, int lengthBefore, int
69836982
*/
69846983
protected void onSelectionChanged(int selStart, int selEnd) {
69856984
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED);
6985+
// mEditor may be null if selection is created programatically.
6986+
createEditorIfNeeded("onSelectionChanged");
6987+
// Invalidate even when selection range is empty, to remove previous highlight
69866988
getEditor().mTextDisplayListIsValid = false;
69876989
}
69886990

0 commit comments

Comments
 (0)