summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMindy Pereira <mindyp@google.com>2011-09-20 08:13:39 -0700
committerMindy Pereira <mindyp@google.com>2011-09-20 08:45:13 -0700
commitc10739cc694a0248b6187de2d7b9e8d2298bf0d3 (patch)
treec9188885352e1cc10d2693aac5d391108ecb84da
parent020460ff2d3d055bd4e2f3794480e8adb63b8ff6 (diff)
downloadandroid_frameworks_ex-c10739cc694a0248b6187de2d7b9e8d2298bf0d3.tar.gz
android_frameworks_ex-c10739cc694a0248b6187de2d7b9e8d2298bf0d3.tar.bz2
android_frameworks_ex-c10739cc694a0248b6187de2d7b9e8d2298bf0d3.zip
Fix monkey crash related to empty recips array/ bad tokenization.
Fixes bug:5343254 java.lang.ArrayIndexOutOfBoundsException: length=0; index=-1 at com.android.ex.chips.RecipientEditTextView.removeMoreChip(RecipientEditTextView.java:1408) Fixes bug:5345831 ArrayIndexOutOfBoundsException in RecipientEditTextView.createDisplayText Change-Id: Ie487c23dc54449d53f68d73c33e18cb946ec4284
-rw-r--r--chips/src/com/android/ex/chips/RecipientEditTextView.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/chips/src/com/android/ex/chips/RecipientEditTextView.java b/chips/src/com/android/ex/chips/RecipientEditTextView.java
index f0daf07..be65a37 100644
--- a/chips/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/chips/src/com/android/ex/chips/RecipientEditTextView.java
@@ -1221,7 +1221,10 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
if (address != null) {
// Tokenize out the address in case the address already
// contained the username as well.
- address = Rfc822Tokenizer.tokenize(address)[0].getAddress();
+ Rfc822Token[] tokenized = Rfc822Tokenizer.tokenize(address);
+ if (tokenized != null && tokenized.length > 0) {
+ address = tokenized[0].getAddress();
+ }
}
Rfc822Token token = new Rfc822Token(display, address, null);
String displayText = token.toString();
@@ -1466,9 +1469,12 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
// Re-add the spans that were removed.
if (mRemovedSpans != null && mRemovedSpans.size() > 0) {
// Recreate each removed span.
- RecipientChip[] recipients = getRecipients();
+ RecipientChip[] recipients = getSortedRecipients();
// Start the search for tokens after the last currently visible
// chip.
+ if (recipients == null || recipients.length == 0) {
+ return;
+ }
int end = span.getSpanEnd(recipients[recipients.length - 1]);
Editable editable = getText();
for (RecipientChip chip : mRemovedSpans) {