Search in sources :

Example 1 with Photo

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;
}
Also used : Bundle(android.os.Bundle) ValuesDelta(com.android.contacts.common.model.ValuesDelta) ArrayList(java.util.ArrayList) Photo(android.provider.ContactsContract.CommonDataKinds.Photo) AccountType(com.android.contacts.common.model.account.AccountType) Bitmap(android.graphics.Bitmap)

Aggregations

Bitmap (android.graphics.Bitmap)1 Bundle (android.os.Bundle)1 Photo (android.provider.ContactsContract.CommonDataKinds.Photo)1 ValuesDelta (com.android.contacts.common.model.ValuesDelta)1 AccountType (com.android.contacts.common.model.account.AccountType)1 ArrayList (java.util.ArrayList)1