How to add FadeInBitmapDisplayer and RoundedBitmapDisplayer to my image?
There was also a problem. I used NOSTRA's great suggestion, and here is my custom class:
public class FadeInRoundedBitmapDisplayer extends RoundedBitmapDisplayer { int durationMillis; String noRoundedCornersTag; public FadeInRoundedBitmapDisplayer(int durationMillis, int roundPixels, String noRoundedCornersTag) { super(roundPixels); this.durationMillis = durationMillis; this.noRoundedCornersTag = noRoundedCornersTag; } @Override public Bitmap display(Bitmap bitmap, ImageView imageView, LoadedFrom loadedFrom) { imageView.setImageBitmap((imageView.getTag() != null && imageView .getTag().equals(noRoundedCornersTag)) ? bitmap : super .display(bitmap, imageView, loadedFrom)); animate(imageView, durationMillis); return bitmap; } public static void animate(ImageView imageView, int durationMillis) { AlphaAnimation fadeImage = new AlphaAnimation(0, 1); fadeImage.setDuration(durationMillis); fadeImage.setInterpolator(new DecelerateInterpolator()); imageView.startAnimation(fadeImage); } }
You can pass String noRoundedCornersTag to the constructor. This allows you to specify a single imageView tag in your XML layout to skip the corner radius procedure (useful for background images, etc.), for example:
<ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:tag="@string/no_rounded_corners_tag" />
The constructor call will look like this:
new FadeInRoundedBitmapDisplayer(Constants.IMAGE_FADING_TIME, getResources().getDimension(R.dimen.image_corner_radius), getResources().getString(R.string.no_rounded_corners_tag))
source share