Merge "Fix crash during TextView.onCreateContextMenu" into oc-dev

am: 58df6ab93f

Change-Id: Ic6b3aa97edffd87e643a778d73aa61e890f52a4b
This commit is contained in:
Siyamed Sinir
2017-06-19 17:05:27 +00:00
committed by android-build-merger

View File

@@ -2584,14 +2584,18 @@ public class Editor {
if (offset == -1) {
return;
}
stopTextActionModeWithPreservingSelection();
final boolean isOnSelection = mTextView.hasSelection()
&& offset >= mTextView.getSelectionStart() && offset <= mTextView.getSelectionEnd();
if (!isOnSelection) {
// Right clicked position is not on the selection. Remove the selection and move the
// cursor to the right clicked position.
Selection.setSelection((Spannable) mTextView.getText(), offset);
stopTextActionMode();
if (mTextView.canSelectText()) {
final boolean isOnSelection = mTextView.hasSelection()
&& offset >= mTextView.getSelectionStart()
&& offset <= mTextView.getSelectionEnd();
if (!isOnSelection) {
// Right clicked position is not on the selection. Remove the selection and move the
// cursor to the right clicked position.
Selection.setSelection((Spannable) mTextView.getText(), offset);
stopTextActionMode();
}
}
if (shouldOfferToShowSuggestions()) {