Convert valid email addresses to a chip. am: dbe88c3002
am: 5c36439515

Change-Id: Ia22def4231f8ff80d5a24aa1d33bafe1fdb344aa
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index 966325b..3cd0f41 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -1518,18 +1518,17 @@
     private boolean commitChip(int start, int end, Editable editable) {
         int position = positionOfFirstEntryWithTypePerson();
         if (position != -1 && enoughToFilter()
-            && end == getSelectionEnd() && !isPhoneQuery()) {
+                && end == getSelectionEnd() && !isPhoneQuery()
+                && !isValidEmailAddress(editable.toString().substring(start, end).trim())) {
             // let's choose the selected or first entry if only the input text is NOT an email
             // address so we won't try to replace the user's potentially correct but
             // new/unencountered email input
-            if (!isValidEmailAddress(editable.toString().substring(start, end).trim())) {
-                final int selectedPosition = getListSelection();
-                if (selectedPosition == -1 || !isEntryAtPositionTypePerson(selectedPosition)) {
-                    // Nothing is selected or selected item is not type person; use the first item
-                    submitItemAtPosition(position);
-                } else {
-                    submitItemAtPosition(selectedPosition);
-                }
+            final int selectedPosition = getListSelection();
+            if (selectedPosition == -1 || !isEntryAtPositionTypePerson(selectedPosition)) {
+                // Nothing is selected or selected item is not type person; use the first item
+                submitItemAtPosition(position);
+            } else {
+                submitItemAtPosition(selectedPosition);
             }
             dismissDropDown();
             return true;