Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1e79b45 authored by Gilles Debunne's avatar Gilles Debunne
Browse files

Fix NPE on Activity start in TextView

Bug 6065279

The selection can be created programatically, and mEditor may be null
when it happens.

Make sure mEditor is created to display the selection highlight.

Change-Id: Idd66a5fd4ad327f9b390b539574e6878c794ba4a
parent a16c98c1
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -2980,8 +2980,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                          "/" + ss.selEnd + " out of range for " + restored +
                          "text " + mText);
                } else {
                    Selection.setSelection((Spannable) mText, ss.selStart,
                                           ss.selEnd);
                    Selection.setSelection((Spannable) mText, ss.selStart, ss.selEnd);

                    if (ss.frozenWithFocus) {
                        createEditorIfNeeded("restore instance with focus");
@@ -6983,6 +6982,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     */
    protected void onSelectionChanged(int selStart, int selEnd) {
        sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED);
        // mEditor may be null if selection is created programatically.
        createEditorIfNeeded("onSelectionChanged");
        // Invalidate even when selection range is empty, to remove previous highlight
        getEditor().mTextDisplayListIsValid = false;
    }