Small changes to make this more easily integrated into apps.

1) created interface for old adapter and new adapter
to implement so they can be used interchangeable
2) did null checks for chips when getting data/ contacdt ids
Change-Id: I7f47230c5cf35426b73b477f374641b271455411
diff --git a/src/com/android/ex/chips/AccountSpecificAdapter.java b/src/com/android/ex/chips/AccountSpecificAdapter.java
new file mode 100644
index 0000000..b0d0e40
--- /dev/null
+++ b/src/com/android/ex/chips/AccountSpecificAdapter.java
@@ -0,0 +1,12 @@
+package com.android.ex.chips;
+
+import android.accounts.Account;
+
+/**
+ * The AccountSpecificAdapter interface describes an Adapter
+ * that can take an account to retrieve information tied to
+ * a specific account.
+ */
+public interface AccountSpecificAdapter {
+    public void setAccount(Account account);
+}
diff --git a/src/com/android/ex/chips/BaseRecipientAdapter.java b/src/com/android/ex/chips/BaseRecipientAdapter.java
index 811c120..dc96075 100644
--- a/src/com/android/ex/chips/BaseRecipientAdapter.java
+++ b/src/com/android/ex/chips/BaseRecipientAdapter.java
@@ -58,7 +58,8 @@
 /**
  * Adapter for showing a recipient list.
  */
-public abstract class BaseRecipientAdapter extends BaseAdapter implements Filterable {
+public abstract class BaseRecipientAdapter extends BaseAdapter implements Filterable,
+        AccountSpecificAdapter {
     private static final String TAG = "BaseRecipientAdapter";
     private static final boolean DEBUG = false;
 
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index 5a0049f..e20e843 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -603,9 +603,11 @@
     /** Returns a collection of contact Id for each chip inside this View. */
     /* package */ Collection<Long> getContactIds() {
         final Set<Long> result = new HashSet<Long>();
-        RecipientChip [] chips = getRecipients();
-        for (RecipientChip chip : chips) {
-            result.add(chip.getContactId());
+        RecipientChip[] chips = getRecipients();
+        if (chips != null) {
+            for (RecipientChip chip : chips) {
+                result.add(chip.getContactId());
+            }
         }
         return result;
     }
@@ -618,8 +620,10 @@
     /* package */ Collection<Long> getDataIds() {
         final Set<Long> result = new HashSet<Long>();
         RecipientChip [] chips = getRecipients();
-        for (RecipientChip chip : chips) {
-            result.add(chip.getDataId());
+        if (chips != null) {
+            for (RecipientChip chip : chips) {
+                result.add(chip.getDataId());
+            }
         }
         return result;
     }