From ffe00d22a60cc512080b0ea4f242f1ed5216bcb4 Mon Sep 17 00:00:00 2001 From: linus_lee Date: Mon, 26 Jan 2015 15:44:21 -0800 Subject: Chips: Fix some crashes and missing default icon scenario Handle a NPE when directoryId is null Handle a NPE when the contact has no address Set the default icon for SINGLE_RECIPIENT or else there is a blank space Change-Id: Ic1231ed5d25cb4a567898f7b72abeb8880b3256c --- src/com/android/ex/chips/DropdownChipLayouter.java | 1 + .../android/ex/chips/RecipientEditTextView.java | 23 ++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/com/android/ex/chips/DropdownChipLayouter.java b/src/com/android/ex/chips/DropdownChipLayouter.java index 170008f..3c6d988 100644 --- a/src/com/android/ex/chips/DropdownChipLayouter.java +++ b/src/com/android/ex/chips/DropdownChipLayouter.java @@ -231,6 +231,7 @@ public class DropdownChipLayouter { break; case SINGLE_RECIPIENT: default: + view.setImageResource(getDefaultPhotoResId()); break; } view.setVisibility(View.VISIBLE); diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java index 2308da0..92bd65c 100644 --- a/src/com/android/ex/chips/RecipientEditTextView.java +++ b/src/com/android/ex/chips/RecipientEditTextView.java @@ -2884,16 +2884,19 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements .getContactId()) && getSpannable().getSpanStart(temp) != -1) { // Replace this. - final RecipientEntry entry = createValidatedEntry(entries - .get(tokenizeAddress(temp.getEntry().getDestination()) - .toLowerCase())); - if (entry != null) { - mHandler.post(new Runnable() { - @Override - public void run() { - replaceChip(temp, entry); - } - }); + final String address = tokenizeAddress( + temp.getEntry().getDestination()); + if (!TextUtils.isEmpty(address)) { + final RecipientEntry entry = createValidatedEntry(entries + .get(address.toLowerCase())); + if (entry != null) { + mHandler.post(new Runnable() { + @Override + public void run() { + replaceChip(temp, entry); + } + }); + } } } } -- cgit v1.2.3