/** * Rounds the given drawable with a {@link RoundedBitmapDrawable} or {@link RoundedColorDrawable}. * * <p> If the given drawable is not a {@link BitmapDrawable} or a {@link ColorDrawable}, it is * returned without being rounded. * * @return the rounded drawable, or the original drawable if rounding didn't take place */ private static Drawable applyLeafRounding( Drawable drawable, RoundingParams roundingParams, Resources resources) { if (drawable instanceof BitmapDrawable) { final BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; RoundedBitmapDrawable roundedBitmapDrawable = new RoundedBitmapDrawable( resources, bitmapDrawable.getBitmap(), bitmapDrawable.getPaint()); applyRoundingParams(roundedBitmapDrawable, roundingParams); return roundedBitmapDrawable; } if (drawable instanceof ColorDrawable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { RoundedColorDrawable roundedColorDrawable = RoundedColorDrawable.fromColorDrawable((ColorDrawable) drawable); applyRoundingParams(roundedColorDrawable, roundingParams); return roundedColorDrawable; } return drawable; }
public static Drawable applyRounding( @Nullable RoundingParams roundingParams, Resources resources, Drawable drawable) { if (drawable instanceof BitmapDrawable) { RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawable.fromBitmapDrawable(resources, (BitmapDrawable) drawable); applyRoundingParams(roundedBitmapDrawable, roundingParams); return roundedBitmapDrawable; } if (drawable instanceof ColorDrawable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { RoundedColorDrawable roundedColorDrawable = RoundedColorDrawable.fromColorDrawable((ColorDrawable) drawable); applyRoundingParams(roundedColorDrawable, roundingParams); return roundedColorDrawable; } return drawable; }