Loading core/java/android/view/textclassifier/TextClassifierImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -201,7 +201,7 @@ final class TextClassifierImpl implements TextClassifier { Preconditions.checkArgument(text != null); Preconditions.checkArgument(startIndex >= 0); Preconditions.checkArgument(endIndex <= text.length()); Preconditions.checkArgument(endIndex >= startIndex); Preconditions.checkArgument(endIndex > startIndex); } /** Loading core/java/android/widget/SelectionActionModeHelper.java +11 −4 Original line number Diff line number Diff line Loading @@ -60,14 +60,14 @@ final class SelectionActionModeHelper { mEditor = Preconditions.checkNotNull(editor); final TextView textView = mEditor.getTextView(); mTextClassificationHelper = new TextClassificationHelper( textView.getTextClassifier(), textView.getText(), textView.getSelectionStart(), textView.getSelectionEnd()); textView.getTextClassifier(), textView.getText(), 0, 1); } public void startActionModeAsync() { cancelAsyncTask(); if (isNoOpTextClassifier()) { if (isNoOpTextClassifier() || !hasSelection()) { // No need to make an async call for a no-op TextClassifier. // Do not call the TextClassifier if there is no selection. startActionMode(null); } else { resetTextClassificationHelper(); Loading @@ -84,8 +84,9 @@ final class SelectionActionModeHelper { public void invalidateActionModeAsync() { cancelAsyncTask(); if (isNoOpTextClassifier()) { if (isNoOpTextClassifier() || !hasSelection()) { // No need to make an async call for a no-op TextClassifier. // Do not call the TextClassifier if there is no selection. invalidateActionMode(null); } else { resetTextClassificationHelper(); Loading Loading @@ -126,6 +127,11 @@ final class SelectionActionModeHelper { return mEditor.getTextView().getTextClassifier() == TextClassifier.NO_OP; } private boolean hasSelection() { final TextView textView = mEditor.getTextView(); return textView.getSelectionEnd() > textView.getSelectionStart(); } private void startActionMode(@Nullable SelectionResult result) { final TextView textView = mEditor.getTextView(); final CharSequence text = textView.getText(); Loading Loading @@ -311,6 +317,7 @@ final class SelectionActionModeHelper { CharSequence text, int selectionStart, int selectionEnd) { mTextClassifier = Preconditions.checkNotNull(textClassifier); mText = Preconditions.checkNotNull(text).toString(); Preconditions.checkArgument(selectionEnd > selectionStart); mSelectionStart = selectionStart; mSelectionEnd = selectionEnd; } Loading Loading
core/java/android/view/textclassifier/TextClassifierImpl.java +1 −1 Original line number Diff line number Diff line Loading @@ -201,7 +201,7 @@ final class TextClassifierImpl implements TextClassifier { Preconditions.checkArgument(text != null); Preconditions.checkArgument(startIndex >= 0); Preconditions.checkArgument(endIndex <= text.length()); Preconditions.checkArgument(endIndex >= startIndex); Preconditions.checkArgument(endIndex > startIndex); } /** Loading
core/java/android/widget/SelectionActionModeHelper.java +11 −4 Original line number Diff line number Diff line Loading @@ -60,14 +60,14 @@ final class SelectionActionModeHelper { mEditor = Preconditions.checkNotNull(editor); final TextView textView = mEditor.getTextView(); mTextClassificationHelper = new TextClassificationHelper( textView.getTextClassifier(), textView.getText(), textView.getSelectionStart(), textView.getSelectionEnd()); textView.getTextClassifier(), textView.getText(), 0, 1); } public void startActionModeAsync() { cancelAsyncTask(); if (isNoOpTextClassifier()) { if (isNoOpTextClassifier() || !hasSelection()) { // No need to make an async call for a no-op TextClassifier. // Do not call the TextClassifier if there is no selection. startActionMode(null); } else { resetTextClassificationHelper(); Loading @@ -84,8 +84,9 @@ final class SelectionActionModeHelper { public void invalidateActionModeAsync() { cancelAsyncTask(); if (isNoOpTextClassifier()) { if (isNoOpTextClassifier() || !hasSelection()) { // No need to make an async call for a no-op TextClassifier. // Do not call the TextClassifier if there is no selection. invalidateActionMode(null); } else { resetTextClassificationHelper(); Loading Loading @@ -126,6 +127,11 @@ final class SelectionActionModeHelper { return mEditor.getTextView().getTextClassifier() == TextClassifier.NO_OP; } private boolean hasSelection() { final TextView textView = mEditor.getTextView(); return textView.getSelectionEnd() > textView.getSelectionStart(); } private void startActionMode(@Nullable SelectionResult result) { final TextView textView = mEditor.getTextView(); final CharSequence text = textView.getText(); Loading Loading @@ -311,6 +317,7 @@ final class SelectionActionModeHelper { CharSequence text, int selectionStart, int selectionEnd) { mTextClassifier = Preconditions.checkNotNull(textClassifier); mText = Preconditions.checkNotNull(text).toString(); Preconditions.checkArgument(selectionEnd > selectionStart); mSelectionStart = selectionStart; mSelectionEnd = selectionEnd; } Loading