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

Commit 74e7b26a authored by Roozbeh Pournader's avatar Roozbeh Pournader
Browse files

In onDragEvent(), don't assume text is Spannable

Previously, onDragEvent() tried to set the anchor even if
the text was not Spannable. Now we check to make sure it is
Spannable before trying to set the selection.

Test: cts-tradefed run cts-dev --module CtsTextTestCases
Change-Id: I835bf3d6024bf3c85e1d248458829eef496ad93d
Fixes: 37261326
parent e943a3cb
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -11227,8 +11227,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                return true;

            case DragEvent.ACTION_DRAG_LOCATION:
                if (mText instanceof Spannable) {
                    final int offset = getOffsetForPosition(event.getX(), event.getY());
                    Selection.setSelection((Spannable) mText, offset);
                }
                return true;

            case DragEvent.ACTION_DROP: