Merge "Fix crash after smart selection animation" into pi-dev

This commit is contained in:
Mihai Popa
2018-05-22 11:19:24 +00:00
committed by Android (Google) Code Review

View File

@@ -284,7 +284,12 @@ public final class SelectionActionModeHelper {
@Nullable SelectionResult result) {
final Layout layout = mTextView.getLayout();
final Runnable onAnimationEndCallback = () -> startSelectionActionMode(result);
final Runnable onAnimationEndCallback = () -> {
if (result.mStart >= 0 && result.mEnd <= getText(mTextView).length()
&& result.mStart <= result.mEnd) {
startSelectionActionMode(result);
}
};
// TODO do not trigger the animation if the change included only non-printable characters
final boolean didSelectionChange =
result != null && (mTextView.getSelectionStart() != result.mStart