From d259fd2d897c741fa5ca1067a4596beeb2e0a938 Mon Sep 17 00:00:00 2001 From: Paul Westbrook Date: Mon, 22 Apr 2013 12:27:35 -0700 Subject: Prevent IOOB exception The chips code was expecting a space after an email address when replacing it with a chip. If there is no extra space (which can happen when receiving an intent) don't walk off the end of the string Bug: 8635860 Change-Id: I1d40a08f1cbf11740172b0ea62ab11d656fb23f9 --- chips/src/com/android/ex/chips/RecipientEditTextView.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'chips') diff --git a/chips/src/com/android/ex/chips/RecipientEditTextView.java b/chips/src/com/android/ex/chips/RecipientEditTextView.java index 8b6367f..62a60b0 100644 --- a/chips/src/com/android/ex/chips/RecipientEditTextView.java +++ b/chips/src/com/android/ex/chips/RecipientEditTextView.java @@ -2566,7 +2566,8 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements if (start != -1) { // Replacing the entirety of what the chip represented, // including the extra space dividing it from other chips. - final int end = text.getSpanEnd(chip) + 1; + final int end = + Math.min(text.getSpanEnd(chip) + 1, text.length()); text.removeSpan(chip); // Make sure we always have just 1 space at the end to // separate this chip from the next chip. -- cgit v1.2.3