public class

ForwardingDrawable

extends Drawable
implements Drawable.Callback DrawableParent TransformAwareDrawable TransformCallback
java.lang.Object
   ↳ android.graphics.drawable.Drawable
     ↳ com.facebook.drawee.drawable.ForwardingDrawable
Known Direct Subclasses

Class Overview

A forwarding drawable class - the goal is to forward (delegate) drawable functionality to an inner drawable instance. ForwardingDrawable intercepts the public (and protected) methods of Drawable, maintains local state if needed.

Design note: It would have been very helpful to re-use Android library classes like DrawableContainer, LevelListDrawable etc. DrawableContainer is not directly subclassable, and the others don't allow changing the member drawables.

Summary

Fields
protected TransformCallback mTransformCallback
Public Constructors
ForwardingDrawable(Drawable drawable)
Constructs a new forwarding drawable.
Public Methods
void draw(Canvas canvas)
Drawable getCurrent()
Drawable getDrawable()
Gets the child drawable.
int getIntrinsicHeight()
int getIntrinsicWidth()
int getOpacity()
boolean getPadding(Rect padding)
void getRootBounds(RectF bounds)
Called when the drawable needs to get its root bounds.
void getTransform(Matrix transform)
Called when the drawable needs to get all matrices applied to it.
void getTransformedBounds(RectF outBounds)
Gets the transformed bounds of this drawable.
void invalidateDrawable(Drawable who)
boolean isStateful()
Drawable mutate()
void scheduleDrawable(Drawable who, Runnable what, long when)
void setAlpha(int alpha)
void setColorFilter(ColorFilter colorFilter)
Drawable setCurrent(Drawable newDelegate)
Sets a new drawable to be the delegate, and returns the old one (or null).
void setDither(boolean dither)
Drawable setDrawable(Drawable newDrawable)
Sets the new child drawable.
void setFilterBitmap(boolean filterBitmap)
void setHotspot(float x, float y)
void setTransformCallback(TransformCallback transformCallback)
Sets a transform callback.
boolean setVisible(boolean visible, boolean restart)
void unscheduleDrawable(Drawable who, Runnable what)
Protected Methods
void getParentTransform(Matrix transform)
void onBoundsChange(Rect bounds)
boolean onLevelChange(int level)
boolean onStateChange(int[] state)
Drawable setCurrentWithoutInvalidate(Drawable newDelegate)
As setCurrent, but without invalidating a drawable.
[Expand]
Inherited Methods
From class android.graphics.drawable.Drawable
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface com.facebook.drawee.drawable.DrawableParent
From interface com.facebook.drawee.drawable.TransformAwareDrawable
From interface com.facebook.drawee.drawable.TransformCallback

Fields

protected TransformCallback mTransformCallback

Public Constructors

public ForwardingDrawable (Drawable drawable)

Constructs a new forwarding drawable.

Parameters
drawable drawable that this forwarding drawable will forward to

Public Methods

public void draw (Canvas canvas)

public Drawable getCurrent ()

public Drawable getDrawable ()

Gets the child drawable.

Returns
  • the current child drawable

public int getIntrinsicHeight ()

public int getIntrinsicWidth ()

public int getOpacity ()

public boolean getPadding (Rect padding)

public void getRootBounds (RectF bounds)

Called when the drawable needs to get its root bounds.

Parameters
bounds The root bounds of the drawable.

public void getTransform (Matrix transform)

Called when the drawable needs to get all matrices applied to it.

Parameters
transform Matrix that is applied to the drawable by the parent drawables.

public void getTransformedBounds (RectF outBounds)

Gets the transformed bounds of this drawable. Note: bounds are not cropped (otherwise they would likely be the same as drawable's bounds).

Parameters
outBounds rect to fill with bounds

public void invalidateDrawable (Drawable who)

public boolean isStateful ()

public Drawable mutate ()

public void scheduleDrawable (Drawable who, Runnable what, long when)

public void setAlpha (int alpha)

public void setColorFilter (ColorFilter colorFilter)

public Drawable setCurrent (Drawable newDelegate)

Sets a new drawable to be the delegate, and returns the old one (or null).

This method will cause the drawable to be invalidated.

Returns
  • the previous delegate

public void setDither (boolean dither)

public Drawable setDrawable (Drawable newDrawable)

Sets the new child drawable.

Parameters
newDrawable a new child drawable to set
Returns
  • the old child drawable

public void setFilterBitmap (boolean filterBitmap)

public void setHotspot (float x, float y)

public void setTransformCallback (TransformCallback transformCallback)

Sets a transform callback.

Parameters
transformCallback the transform callback to be set

public boolean setVisible (boolean visible, boolean restart)

public void unscheduleDrawable (Drawable who, Runnable what)

Protected Methods

protected void getParentTransform (Matrix transform)

protected void onBoundsChange (Rect bounds)

protected boolean onLevelChange (int level)

protected boolean onStateChange (int[] state)

protected Drawable setCurrentWithoutInvalidate (Drawable newDelegate)

As setCurrent, but without invalidating a drawable. Subclasses are responsible to call invalidateSelf on their own.

Returns
  • the previous delegate