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

This commit is contained in:
Siyamed Sinir
2017-06-19 16:53:11 +00:00
committed by Android (Google) Code Review

View File

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