make sure there is a position after the comma before moving to it.

Fixes Bug:4948080 ANR when tried to attach a picture in Gmail Compose

Change-Id: Idf13eec6bf36cba14fae2c633de98049b04c3f8f
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index 682549a..02fd9d5 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -469,15 +469,17 @@
                     String current = mPendingChips.get(i);
                     int tokenStart = editable.toString().indexOf(current);
                     int tokenEnd = tokenStart + current.length();
-                    // Always include seperators with the token to the
-                    // left.
-                    if (tokenEnd < editable.length() - 1
-                            && editable.charAt(tokenEnd) == COMMIT_CHAR_COMMA) {
-                        tokenEnd++;
+                    if (tokenStart >= 0) {
+                        // When we have a valid token, include it with the token
+                        // to the left.
+                        if (tokenEnd < editable.length() - 2
+                                && editable.charAt(tokenEnd) == COMMIT_CHAR_COMMA) {
+                            tokenEnd++;
+                        }
+                        String token = editable.toString().substring(tokenStart, tokenEnd);
+                        editable.replace(tokenStart, tokenEnd, createChip(RecipientEntry
+                                .constructFakeEntry(token), false));
                     }
-                    String token = editable.toString().substring(tokenStart, tokenEnd);
-                    editable.replace(tokenStart, tokenEnd, createChip(RecipientEntry
-                            .constructFakeEntry(token), false));
                 }
                 mPendingChipsCount--;
             }