public class

DrawableUtils

extends Object
java.lang.Object
   ↳ com.facebook.drawee.drawable.DrawableUtils

Class Overview

Helper class containing functionality commonly used by drawables.

Summary

Public Constructors
DrawableUtils()
Public Methods
static Drawable cloneDrawable(Drawable drawable)
Clones the specified drawable.
static void copyProperties(Drawable to, Drawable from)
Copies various properties from one drawable to the other.
static int getOpacityFromColor(int color)
Gets the opacity from a color.
static int multiplyColorAlpha(int color, int alpha)
Multiplies the color with the given alpha.
static void setCallbacks(Drawable drawable, Drawable.Callback callback, TransformCallback transformCallback)
Sets callback to the drawable.
static void setDrawableProperties(Drawable drawable, DrawableProperties properties)
Sets various paint properties on the drawable
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public DrawableUtils ()

Public Methods

public static Drawable cloneDrawable (Drawable drawable)

Clones the specified drawable.

Parameters
drawable the drawable to clone.
Returns
  • a clone of the drawable or null if the drawable cannot be cloned.

public static void copyProperties (Drawable to, Drawable from)

Copies various properties from one drawable to the other.

Parameters
to drawable to copy properties to
from drawable to copy properties from

public static int getOpacityFromColor (int color)

Gets the opacity from a color. Inspired by Android ColorDrawable.

Returns
  • opacity expressed by one of PixelFormat constants

public static int multiplyColorAlpha (int color, int alpha)

Multiplies the color with the given alpha.

Parameters
color color to be multiplied
alpha value between 0 and 255
Returns
  • multiplied color

public static void setCallbacks (Drawable drawable, Drawable.Callback callback, TransformCallback transformCallback)

Sets callback to the drawable.

Parameters
drawable drawable to set callbacks to
callback standard Android Drawable.Callback
transformCallback TransformCallback used by TransformAwareDrawables

public static void setDrawableProperties (Drawable drawable, DrawableProperties properties)

Sets various paint properties on the drawable

Parameters
drawable Drawable on which to set the properties
properties wrapper around mValue values to set on the drawable