Created
April 3, 2020 01:06
-
-
Save zeeshanaslam78/0371d7c4f6e282d778ede3a0bc6a9b3d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void convertToCircularBitmapDrawable(final Context context, Object url, ImageView imageView, int placeHolderResourceId) { | |
Bitmap placeholder = BitmapFactory.decodeResource(context.getResources(), placeHolderResourceId); | |
RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), placeholder); | |
circularBitmapDrawable.setCircular(true); | |
Glide | |
.with(context) | |
.load(url) | |
.apply(new RequestOptions() | |
.circleCrop(context) | |
.diskCacheStrategy(DiskCacheStrategy.RESOURCE) | |
.centerCrop(context) | |
.error(circularBitmapDrawable) | |
.placeholder(circularBitmapDrawable) | |
) | |
.apply(RequestOptions.circleCropTransform(context)) | |
.listener(new RequestListener<Drawable>() { | |
@Override | |
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { | |
if (e != null) | |
L.e(e); | |
return false; | |
} | |
@Override | |
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { | |
return false; | |
} | |
}) | |
.into(imageView) | |
; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment