Search in sources :

Example 1 with RoundedColorDrawable

use of com.facebook.drawee.drawable.RoundedColorDrawable in project fresco by facebook.

the class WrappingUtils method applyLeafRounding.

/**
   * 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;
}
Also used : RoundedColorDrawable(com.facebook.drawee.drawable.RoundedColorDrawable) RoundedBitmapDrawable(com.facebook.drawee.drawable.RoundedBitmapDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) RoundedColorDrawable(com.facebook.drawee.drawable.RoundedColorDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) RoundedBitmapDrawable(com.facebook.drawee.drawable.RoundedBitmapDrawable)

Aggregations

BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 RoundedBitmapDrawable (com.facebook.drawee.drawable.RoundedBitmapDrawable)1 RoundedColorDrawable (com.facebook.drawee.drawable.RoundedColorDrawable)1