/**
  * Iterates over all data items that represent phone numbers are tries to calculate a formatted
  * number. This function can safely be called several times as no unformatted data is overwritten
  */
 private void computeFormattedPhoneNumbers(Contact contactData) {
   final String countryIso = GeoUtil.getCurrentCountryIso(getContext());
   final ImmutableList<RawContact> rawContacts = contactData.getRawContacts();
   final int rawContactCount = rawContacts.size();
   for (int rawContactIndex = 0; rawContactIndex < rawContactCount; rawContactIndex++) {
     final RawContact rawContact = rawContacts.get(rawContactIndex);
     final List<DataItem> dataItems = rawContact.getDataItems();
     final int dataCount = dataItems.size();
     for (int dataIndex = 0; dataIndex < dataCount; dataIndex++) {
       final DataItem dataItem = dataItems.get(dataIndex);
       if (dataItem instanceof PhoneDataItem) {
         final PhoneDataItem phoneDataItem = (PhoneDataItem) dataItem;
         phoneDataItem.computeFormattedPhoneNumber(countryIso);
       }
     }
   }
 }
  private void loadThumbnailBinaryData(Contact contactData) {
    final long photoId = contactData.getPhotoId();
    if (photoId <= 0) {
      // No photo ID
      return;
    }

    for (RawContact rawContact : contactData.getRawContacts()) {
      for (DataItem dataItem : rawContact.getDataItems()) {
        if (dataItem.getId() == photoId) {
          if (!(dataItem instanceof PhotoDataItem)) {
            break;
          }

          final PhotoDataItem photo = (PhotoDataItem) dataItem;
          contactData.setThumbnailPhotoBinaryData(photo.getPhoto());
          break;
        }
      }
    }
  }