/** * Calls {@link #loadPhoto(ImageView, Uri, boolean, boolean, DefaultImageRequest, * DefaultImageProvider)} with {@link #DEFAULT_AVATAR} and with the assumption, that * the image is a thumbnail. * * @param defaultImageRequest {@link DefaultImageRequest} object that specifies how a default * letter tile avatar should be drawn. */ public final void loadDirectoryPhoto(ImageView view, Uri photoUri, boolean darkTheme, boolean isCircular, DefaultImageRequest defaultImageRequest) { loadPhoto(view, photoUri, -1, darkTheme, isCircular, defaultImageRequest, DEFAULT_AVATAR); }
/** * Calls {@link #loadThumbnail(ImageView, long, boolean, DefaultImageRequest, * DefaultImageProvider)} using the {@link DefaultImageProvider} {@link #DEFAULT_AVATAR}. */ public final void loadThumbnail(ImageView view, long photoId, boolean darkTheme, boolean isCircular, DefaultImageRequest defaultImageRequest) { loadThumbnail(view, photoId, darkTheme, isCircular, defaultImageRequest, DEFAULT_AVATAR); }
public static ContactPhotoManager getInstance(Context context) { if (sInstance == null) { Context applicationContext = context.getApplicationContext(); sInstance = createContactPhotoManager(applicationContext); applicationContext.registerComponentCallbacks(sInstance); if (PermissionsUtil.hasContactsPermissions(context)) { sInstance.preloadPhotosInBackground(); } } return sInstance; }
public void updatePhoto() { quickContactView.assignContactUri(info.lookupUri); final boolean isVoicemail = mCallLogCache.isVoicemailNumber(accountHandle, number); int contactType = ContactPhotoManager.TYPE_DEFAULT; if (isVoicemail) { contactType = ContactPhotoManager.TYPE_VOICEMAIL; } else if (isBusiness) { contactType = ContactPhotoManager.TYPE_BUSINESS; } final String lookupKey = info.lookupUri != null ? UriUtils.getLookupKeyFromUri(info.lookupUri) : null; final String displayName = TextUtils.isEmpty(info.name) ? displayNumber : info.name; final DefaultImageRequest request = new DefaultImageRequest( displayName, lookupKey, contactType, true /* isCircular */); if (info.photoId == 0 && info.photoUri != null) { ContactPhotoManager.getInstance(mContext).loadPhoto(quickContactView, info.photoUri, mPhotoSize, false /* darkTheme */, true /* isCircular */, request); } else { ContactPhotoManager.getInstance(mContext).loadThumbnail(quickContactView, info.photoId, false /* darkTheme */, true /* isCircular */, request); } if (mExtendedBlockingButtonRenderer != null) { mExtendedBlockingButtonRenderer.updatePhotoAndLabelIfNecessary( number, countryIso, quickContactView, phoneCallDetailsViews.callLocationAndDate); } }
protected void bindPhoto(final ContactListItemView view, int partitionIndex, Cursor cursor) { if (!isPhotoSupported(partitionIndex)) { view.removePhotoView(); return; } long photoId = 0; if (!cursor.isNull(PhoneQuery.PHOTO_ID)) { photoId = cursor.getLong(PhoneQuery.PHOTO_ID); } if (photoId != 0) { getPhotoLoader().loadThumbnail(view.getPhotoView(), photoId, false, getCircularPhotos(), null); } else { final String photoUriString = cursor.getString(PhoneQuery.PHOTO_URI); final Uri photoUri = photoUriString == null ? null : Uri.parse(photoUriString); DefaultImageRequest request = null; if (photoUri == null) { final String displayName = cursor.getString(PhoneQuery.DISPLAY_NAME); final String lookupKey = cursor.getString(PhoneQuery.LOOKUP_KEY); request = new DefaultImageRequest(displayName, lookupKey, getCircularPhotos()); } getPhotoLoader().loadDirectoryPhoto(view.getPhotoView(), photoUri, false, getCircularPhotos(), request); } }
protected void configurePhotoLoader() { if (isPhotoLoaderEnabled() && mContext != null) { if (mPhotoManager == null) { mPhotoManager = ContactPhotoManager.getInstance(mContext); } if (mListView != null) { mListView.setOnScrollListener(this); } if (mAdapter != null) { mAdapter.setPhotoLoader(mPhotoManager); } } }
getPhotoLoader().loadThumbnail(quickContact, photoId, mDarkTheme, mCircularPhotos, null); } else { lookUpKeyColumn); getPhotoLoader().loadPhoto(quickContact, photoUri, -1, mDarkTheme, mCircularPhotos, request);
private void loadContactPhoto(ContactInfo info, String displayName, QuickContactBadge badge) { final String lookupKey = info.lookupUri == null ? null : UriUtils.getLookupKeyFromUri(info.lookupUri); final int contactType = mContactInfoHelper.isBusiness(info.sourceType) ? ContactPhotoManager.TYPE_BUSINESS : ContactPhotoManager.TYPE_DEFAULT; final DefaultImageRequest request = new DefaultImageRequest(displayName, lookupKey, contactType, true /* isCircular */); badge.assignContactUri(info.lookupUri); badge.setContentDescription( mContext.getResources().getString(R.string.description_contact_details, displayName)); mContactPhotoManager.loadDirectoryPhoto(badge, info.photoUri, false /* darkTheme */, true /* isCircular */, request); }
@Override public void changeCursor(int partitionIndex, Cursor cursor) { if (partitionIndex >= getPartitionCount()) { // There is no partition for this data return; } Partition partition = getPartition(partitionIndex); if (partition instanceof DirectoryPartition) { ((DirectoryPartition)partition).setStatus(DirectoryPartition.STATUS_LOADED); } if (mDisplayPhotos && mPhotoLoader != null && isPhotoSupported(partitionIndex)) { mPhotoLoader.refreshCache(); } super.changeCursor(partitionIndex, cursor); if (isSectionHeaderDisplayEnabled() && partitionIndex == getIndexedPartition()) { updateIndexer(cursor); } // When the cursor changes, cancel any pending asynchronous photo loads. mPhotoLoader.cancelPendingRequests(mFragmentRootView); }
/** * Applies the default image to the current view. If the request is URI-based, looks for * the contact type encoded fragment to determine if this is a request for a business photo, * in which case we will load the default business photo. * * @param view The current image view to apply the image to. * @param isCircular Whether the image is circular or not. */ public void applyDefaultImage(ImageView view, boolean isCircular) { final DefaultImageRequest request; if (isCircular) { request = ContactPhotoManager.isBusinessContactUri(mUri) ? DefaultImageRequest.EMPTY_CIRCULAR_BUSINESS_IMAGE_REQUEST : DefaultImageRequest.EMPTY_CIRCULAR_DEFAULT_IMAGE_REQUEST; } else { request = ContactPhotoManager.isBusinessContactUri(mUri) ? DefaultImageRequest.EMPTY_DEFAULT_BUSINESS_IMAGE_REQUEST : DefaultImageRequest.EMPTY_DEFAULT_IMAGE_REQUEST; } mDefaultProvider.applyDefaultImage(view, mRequestedExtent, mDarkTheme, request); } }
private Drawable getPhotoDrawable(byte[] bitmapData, String displayName, String lookupKey) { if (bitmapData != null) { Bitmap bitmap = BitmapFactory.decodeByteArray(bitmapData, 0, bitmapData.length, null); return new BitmapDrawable(mContext.getResources(), bitmap); } else { return ContactPhotoManager.getDefaultAvatarDrawableForContact(mContext.getResources(), false, new DefaultImageRequest(displayName, lookupKey, false)); } }
ContactPhotoManager.getInstance(this).loadPhoto(mContactPhoto, photoUri, mPhotoSize, false /* darkTheme */, true /* isCircular */, request); } else { ContactPhotoManager.getInstance(this).loadThumbnail(mContactPhoto, photoId, false /* darkTheme */, true /* isCircular */, request);
protected void bindPhoto(final ContactListItemView view, int partitionIndex, Cursor cursor) { if (!isPhotoSupported(partitionIndex)) { view.removePhotoView(); return; } // Set the photo, if available long photoId = 0; if (!cursor.isNull(ContactQuery.CONTACT_PHOTO_ID)) { photoId = cursor.getLong(ContactQuery.CONTACT_PHOTO_ID); } if (photoId != 0) { getPhotoLoader().loadThumbnail(view.getPhotoView(), photoId, false, getCircularPhotos(), null); } else { final String photoUriString = cursor.getString(ContactQuery.CONTACT_PHOTO_URI); final Uri photoUri = photoUriString == null ? null : Uri.parse(photoUriString); DefaultImageRequest request = null; if (photoUri == null) { request = getDefaultImageRequestFromCursor(cursor, ContactQuery.CONTACT_DISPLAY_NAME, ContactQuery.CONTACT_LOOKUP_KEY); } getPhotoLoader().loadDirectoryPhoto(view.getPhotoView(), photoUri, false, getCircularPhotos(), request); } }
@Override public void onAttach(Activity activity) { if (DEBUG) Log.d(TAG, "onAttach()"); super.onAttach(activity); // Construct two base adapters which will become part of PhoneFavoriteMergedAdapter. // We don't construct the resultant adapter at this moment since it requires LayoutInflater // that will be available on onCreateView(). mContactTileAdapter = new PhoneFavoritesTileAdapter(activity, mContactTileAdapterListener, this); mContactTileAdapter.setPhotoLoader(ContactPhotoManager.getInstance(activity)); }
private void updateContactPhoto() { if (mDetails == null) { return; } final boolean isVoicemailNumber = PhoneNumberUtil.isVoicemailNumber(mContext, mDetails.accountHandle, mNumber); final boolean isBusiness = mContactInfoHelper.isBusiness(mDetails.sourceType); int contactType = ContactPhotoManager.TYPE_DEFAULT; if (isVoicemailNumber) { contactType = ContactPhotoManager.TYPE_VOICEMAIL; } else if (isBusiness) { contactType = ContactPhotoManager.TYPE_BUSINESS; } final String displayName = TextUtils.isEmpty(mDetails.namePrimary) ? mDetails.displayNumber : mDetails.namePrimary.toString(); final String lookupKey = mDetails.contactUri == null ? null : UriUtils.getLookupKeyFromUri(mDetails.contactUri); final DefaultImageRequest request = new DefaultImageRequest(displayName, lookupKey, contactType, true /* isCircular */); mQuickContactBadge.assignContactUri(mDetails.contactUri); mQuickContactBadge.setContentDescription( mResources.getString(R.string.description_contact_details, displayName)); mContactPhotoManager.loadDirectoryPhoto(mQuickContactBadge, mDetails.photoUri, false /* darkTheme */, true /* isCircular */, request); }
public static BlockedNumbersAdapter newBlockedNumbersAdapter( Context context, FragmentManager fragmentManager) { return new BlockedNumbersAdapter( context, fragmentManager, new ContactInfoHelper(context, GeoUtil.getCurrentCountryIso(context)), ContactPhotoManager.getInstance(context)); }
/** * Calls {@link #loadPhoto(ImageView, Uri, int, boolean, DefaultImageRequest, * DefaultImageProvider)} with {@link #DEFAULT_AVATAR} and {@code null} display names and * lookup keys. * * @param defaultImageRequest {@link DefaultImageRequest} object that specifies how a default * letter tile avatar should be drawn. */ public final void loadPhoto(ImageView view, Uri photoUri, int requestedExtent, boolean darkTheme, boolean isCircular, DefaultImageRequest defaultImageRequest) { loadPhoto(view, photoUri, requestedExtent, darkTheme, isCircular, defaultImageRequest, DEFAULT_AVATAR); }
public static ViewNumbersToImportAdapter newViewNumbersToImportAdapter( Context context, FragmentManager fragmentManager) { return new ViewNumbersToImportAdapter( context, fragmentManager, new ContactInfoHelper(context, GeoUtil.getCurrentCountryIso(context)), ContactPhotoManager.getInstance(context)); }
configureViewForImage(entry.photoUri == null); if (mPhoto != null) { mPhotoManager.loadPhoto(mPhoto, entry.photoUri, getApproximateImageSize(), isDarkTheme(), isContactPhotoCircular(), request); mPhotoManager.loadPhoto(mQuickContact, entry.photoUri, getApproximateImageSize(), isDarkTheme(), isContactPhotoCircular(), request);