use of android.provider.ContactsContract.CommonDataKinds.Photo in project packages_apps_Contacts by AOKP.
the class CompactRawContactsEditorView method getPhotos.
/**
* Returns a data holder for every non-default/non-empty photo from each raw contact, whether
* the raw contact is writable or not.
*/
public ArrayList<CompactPhotoSelectionFragment.Photo> getPhotos() {
final ArrayList<CompactPhotoSelectionFragment.Photo> photos = new ArrayList<>();
final Bundle updatedPhotos = mListener == null ? null : mListener.getUpdatedPhotos();
final List<KindSectionData> kindSectionDataList = mKindSectionDataMap.get(Photo.CONTENT_ITEM_TYPE);
for (int i = 0; i < kindSectionDataList.size(); i++) {
final KindSectionData kindSectionData = kindSectionDataList.get(i);
final AccountType accountType = kindSectionData.getAccountType();
final List<ValuesDelta> valuesDeltas = kindSectionData.getNonEmptyValuesDeltas();
if (valuesDeltas.isEmpty())
continue;
for (int j = 0; j < valuesDeltas.size(); j++) {
final ValuesDelta valuesDelta = valuesDeltas.get(j);
final Bitmap bitmap = EditorUiUtils.getPhotoBitmap(valuesDelta);
if (bitmap == null)
continue;
final CompactPhotoSelectionFragment.Photo photo = new CompactPhotoSelectionFragment.Photo();
photo.titleRes = accountType.titleRes;
photo.iconRes = accountType.iconRes;
photo.syncAdapterPackageName = accountType.syncAdapterPackageName;
photo.valuesDelta = valuesDelta;
photo.primary = valuesDelta.isSuperPrimary();
photo.kindSectionDataListIndex = i;
photo.valuesDeltaListIndex = j;
photo.photoId = valuesDelta.getId();
if (updatedPhotos != null) {
photo.updatedPhotoUri = (Uri) updatedPhotos.get(String.valueOf(kindSectionData.getRawContactDelta().getRawContactId()));
}
final CharSequence accountTypeLabel = accountType.getDisplayLabel(getContext());
photo.accountType = accountTypeLabel == null ? "" : accountTypeLabel.toString();
final String accountName = kindSectionData.getRawContactDelta().getAccountName();
photo.accountName = accountName == null ? "" : accountName;
photos.add(photo);
}
}
return photos;
}
Aggregations