public static Drawable getGroupContactPhoto(Context context, @Nullable byte[] avatar) { if (avatar == null) return getDefaultGroupPhoto(context); return RoundedDrawable.fromBitmap(BitmapFactory.decodeByteArray(avatar, 0, avatar.length)) .setScaleType(ImageView.ScaleType.CENTER_CROP) .setOval(true); }
public static Drawable getContactPhoto(Context context, Uri uri, String name) { final InputStream inputStream = getContactPhotoStream(context, uri); final int targetSize = context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size); if (inputStream != null) { try { return RoundedDrawable.fromBitmap( BitmapUtil.createScaledBitmap( inputStream, getContactPhotoStream(context, uri), targetSize, targetSize)) .setScaleType(ImageView.ScaleType.CENTER_CROP) .setOval(true); } catch (BitmapDecodingException bde) { Log.w(TAG, bde); } } return getDefaultContactPhoto(context, name); }