public class

GenericDraweeHierarchy

extends Object
implements SettableDraweeHierarchy
java.lang.Object
   ↳ com.facebook.drawee.generic.GenericDraweeHierarchy

Class Overview

A SettableDraweeHierarchy that displays placeholder image until the actual image is set. If provided, failure image will be used in case of failure (placeholder otherwise). If provided, retry image will be used in case of failure when retrying is enabled. If provided, progressbar will be displayed until fully loaded. Each image can be displayed with a different scale type (or no scaling at all). Fading between the layers is supported.

Example hierarchy with placeholder, retry, failure and one actual image:

     o FadeDrawable (top level drawable)
     |
     +--o ScaleTypeDrawable
     |  |
     |  +--o Drawable (placeholder image)
     |
     +--o ScaleTypeDrawable
     |  |
     |  +--o SettableDrawable
     |     |
     |     +--o Drawable (actual image)
     |
     +--o ScaleTypeDrawable
     |  |
     |  +--o Drawable (retry image)
     |
     +--o ScaleTypeDrawable
        |
        +--o Drawable (failure image)
  

Note: - ScaleType and Matrix transformations will be added only if specified. If both are unspecified, then the branch for that image will be attached directly. - It is not permitted to set both ScaleType transformation and Matrix transformation for the same image. - A Matrix transformation is only supported for actual image. - All branches (placeholder, failure, retry, actual image, progressBar) are optional. If some branch is not specified it won't be created. The exception is placeholder branch, which will, if not specified, be created with a transparent drawable. - If overlays and/or backgrounds are specified, they are added to the same fade drawable, and are always displayed. - Instance of some drawable should be used by only one DH. If more than one DH is being built with the same builder, different drawable instances must be specified for each DH.

Summary

Public Methods
void getActualImageBounds(RectF outBounds)
Gets the post-scaling bounds of the actual image.
RoundingParams getRoundingParams()
Gets the rounding params.
Drawable getTopLevelDrawable()
Returns the top level drawable in the corresponding hierarchy.
void reset()
Called by controller when the hierarchy should be reset to its initial state.
void setActualImageColorFilter(ColorFilter colorfilter)
Sets the color filter to be applied on the actual image.
void setActualImageFocusPoint(PointF focusPoint)
Sets the actual image focus point.
void setActualImageScaleType(ScalingUtils.ScaleType scaleType)
Sets the actual image scale type.
void setControllerOverlay(Drawable drawable)
Called by controller if it needs to display some controller overlay.
void setFailure(Throwable throwable)
Called by controller when the future that provides the actual image completes with failure.
void setImage(Drawable drawable, float progress, boolean immediate)
Called by controller when the future that provides the actual image completes successfully.
void setPlaceholderImage(int resourceId)
Sets a new placeholder drawable using the supplied resource ID.
void setPlaceholderImage(Drawable drawable)
Sets a new placeholder drawable.
void setProgress(float progress, boolean immediate)
Called by controller to update the progress.
void setRetry(Throwable throwable)
Called by controller when the future that provides the actual image completes with failure, but the controller is prepared to kick off a retry when the user clicks on the image.
void setRoundingParams(RoundingParams roundingParams)
Sets the rounding params.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.facebook.drawee.interfaces.DraweeHierarchy
From interface com.facebook.drawee.interfaces.SettableDraweeHierarchy

Public Methods

public void getActualImageBounds (RectF outBounds)

Gets the post-scaling bounds of the actual image.

Note: the returned bounds are not cropped.

Parameters
outBounds rect to fill with bounds

public RoundingParams getRoundingParams ()

Gets the rounding params.

Returns
  • rounding params

public Drawable getTopLevelDrawable ()

Returns the top level drawable in the corresponding hierarchy. Hierarchy should always have the same instance of its top level drawable.

Returns
  • top level drawable

public void reset ()

Called by controller when the hierarchy should be reset to its initial state. Any image previously set by setImage should be detached and not used anymore.

public void setActualImageColorFilter (ColorFilter colorfilter)

Sets the color filter to be applied on the actual image.

public void setActualImageFocusPoint (PointF focusPoint)

Sets the actual image focus point.

public void setActualImageScaleType (ScalingUtils.ScaleType scaleType)

Sets the actual image scale type.

public void setControllerOverlay (Drawable drawable)

Called by controller if it needs to display some controller overlay.

Parameters
drawable drawable to be displayed as controller overlay

public void setFailure (Throwable throwable)

Called by controller when the future that provides the actual image completes with failure. Hierarchy can choose to display between different images based on cause of failure.

Parameters
throwable cause of failure

public void setImage (Drawable drawable, float progress, boolean immediate)

Called by controller when the future that provides the actual image completes successfully. Hierarchy should display the actual image.

Parameters
drawable drawable to be set as the temporary image
progress number in range [0, 1] that indicates progress
immediate if true, image will be shown immediately (without fade effect)

public void setPlaceholderImage (int resourceId)

Sets a new placeholder drawable using the supplied resource ID.

The placeholder scale type will not be changed.

Parameters
resourceId an identifier of an Android drawable or color resource.

public void setPlaceholderImage (Drawable drawable)

Sets a new placeholder drawable.

The placeholder scale type will not be changed.

public void setProgress (float progress, boolean immediate)

Called by controller to update the progress. Hierarchy can choose to hide the progressbar when progress is set to its final value of 1.

Parameters
progress number in range [0, 1] that indicates progress
immediate if true, progressbar will be shown/hidden immediately (without fade effect)

public void setRetry (Throwable throwable)

Called by controller when the future that provides the actual image completes with failure, but the controller is prepared to kick off a retry when the user clicks on the image. Hierarchy can choose to display a retry image.

Parameters
throwable cause of failure

public void setRoundingParams (RoundingParams roundingParams)

Sets the rounding params.