Пример #1
0
 public CharSequence getPhoneTypeLabel(Integer value) {
   if (value == null) {
     return StringUtil.EMPTY;
   }
   Context context = ContextHolder.get();
   return ContactsContract.CommonDataKinds.Phone.getTypeLabel(
       context.getResources(), value, StringUtil.EMPTY);
 }
Пример #2
0
 public List<ContentValues> getEmailsById(Long id) {
   String[] projection = EMAILS_PROJECTION;
   // String[] projection = null;
   return ContentUtils.getEntities(
       ContextHolder.get(),
       projection,
       ContactsContract.CommonDataKinds.Email.CONTENT_URI,
       null,
       EMAILS_SELECTION,
       new String[] {String.valueOf(id)});
 }
Пример #3
0
 public String initPhotoAndContactIdUri(String phone) {
   String resultUri = mPhotoUriCache.get(phone);
   if (resultUri == null) {
     resultUri = getContactIdFromNumber(phone);
     if (resultUri.equals(StringUtil.EMPTY)) {
       ColorUtils.getColorCircle(
           ContextHolder.get().getResources().getDimensionPixelSize(R.dimen.icon_size), phone);
     }
     mPhotoUriCache.put(phone, resultUri);
   }
   return resultUri;
 }
Пример #4
0
 private String getContactIdFromNumber(String number) {
   if (StringUtil.isEmpty(number)) {
     return StringUtil.EMPTY;
   }
   Uri uri =
       Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
   try {
     Cursor c = ContextHolder.get().getContentResolver().query(uri, PROJECTION, null, null, null);
     if (!CursorUtils.isEmpty(c) && c.moveToFirst()) {
       String photoUri = CursorUtils.getString(ContactsContract.Contacts.PHOTO_URI, c);
       Long id = CursorUtils.getLong(ContactsContract.Contacts._ID, c);
       mContactIdCache.put(number, id);
       CursorUtils.close(c);
       return photoUri == null ? StringUtil.EMPTY : photoUri;
     } else {
       CursorUtils.close(c);
     }
   } catch (IllegalArgumentException e) {
     Crashlytics.logException(new IllegalArgumentException("number:" + number, e));
   }
   return StringUtil.EMPTY;
 }
Пример #5
0
 public static Context getHolderContext() {
   return ContextHolder.get();
 }