Esempio n. 1
0
 public static ContactList getByNumbers(Iterable<String> numbers, boolean canBlock) {
   ContactList list = new ContactList();
   for (String number : numbers) {
     if (!TextUtils.isEmpty(number)) {
       list.add(Contact.get(number, canBlock));
     }
   }
   return list;
 }
Esempio n. 2
0
 /**
  * Returns a ContactList for the corresponding recipient ids passed in. This method will create
  * the contact if it doesn't exist, and would inject the recipient id into the contact.
  */
 public static ContactList getByIds(String spaceSepIds, boolean canBlock) {
   ContactList list = new ContactList();
   for (RecipientIdCache.Entry entry : RecipientIdCache.getAddresses(spaceSepIds)) {
     if (entry != null && !TextUtils.isEmpty(entry.number)) {
       Contact contact = Contact.get(entry.number, canBlock);
       contact.setRecipientId(entry.id);
       list.add(contact);
     }
   }
   return list;
 }
Esempio n. 3
0
 public static ContactList getByNumbers(
     String semiSepNumbers, boolean canBlock, boolean replaceNumber) {
   ContactList list = new ContactList();
   for (String number : semiSepNumbers.split(";")) {
     if (!TextUtils.isEmpty(number)) {
       Contact contact = Contact.get(number, canBlock);
       if (replaceNumber) {
         contact.setNumber(number);
       }
       list.add(contact);
     }
   }
   return list;
 }
Esempio n. 4
0
 /**
  * Returns a ContactList for the corresponding recipient URIs passed in. This method will always
  * block to query provider. The given URIs could be the phone data URIs or tel URI for the numbers
  * don't belong to any contact.
  *
  * @param uris phone URI to create the ContactList
  */
 public static ContactList blockingGetByUris(Parcelable[] uris) {
   ContactList list = new ContactList();
   if (uris != null && uris.length > 0) {
     for (Parcelable p : uris) {
       Uri uri = (Uri) p;
       if ("tel".equals(uri.getScheme())) {
         Contact contact = Contact.get(uri.getSchemeSpecificPart(), true);
         list.add(contact);
       }
     }
     final List<Contact> contacts = Contact.getByPhoneUris(uris);
     if (contacts != null) {
       list.addAll(contacts);
     }
   }
   return list;
 }
Esempio n. 5
0
  @Override
  public boolean equals(Object obj) {
    try {
      ContactList other = (ContactList) obj;
      // If they're different sizes, the contact
      // set is obviously different.
      if (size() != other.size()) {
        return false;
      }

      // Make sure all the individual contacts are the same.
      for (Contact c : this) {
        if (!other.contains(c)) {
          return false;
        }
      }

      return true;
    } catch (ClassCastException e) {
      return false;
    }
  }