Fix monkey crash in smart selection animation

In Id65443e93d277c106ea955c867d39e94192cc55d we fixed a monkey crash
happening when the smart selected text had changed while the smart
selection animation was running. However, the change introduced a new
crash, happening when the smart selection result was null. This CL fixes
it, and lets startSelectionActionMode run even when the result is null,
as there seems to be some logic there which should happen in this case.

Bug: 80244201
Test: none
Change-Id: I7f0304446dec85578bdcd5011d2e9ea2737d3c36
This commit is contained in:
Mihai Popa
2018-05-25 11:57:17 +01:00
parent a41a7094ac
commit a9d27ea869

View File

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