public class

GenericDraweeHierarchyBuilder

extends Object
java.lang.Object
   ↳ com.facebook.drawee.generic.GenericDraweeHierarchyBuilder

Class Overview

Class to construct a GenericDraweeHierarchy.

Drawables must not be reused by multiple hierarchies. Each hierarchy needs to have its own drawable instances. Since this builder does not do deep copies of the input parameters, it is the caller's responsibility to pass a different drawable instances for each hierarchy built. Likewise, hierarchies must not be reused by multiple views. Each view needs to have its own instance of a hierarchy. The caller is responsible for building a new hierarchy for each view.

Summary

Constants
int DEFAULT_FADE_DURATION
Fields
public static final ScalingUtils.ScaleType DEFAULT_ACTUAL_IMAGE_SCALE_TYPE
public static final ScalingUtils.ScaleType DEFAULT_SCALE_TYPE
Public Constructors
GenericDraweeHierarchyBuilder(Resources resources)
Public Methods
GenericDraweeHierarchy build()
Builds the hierarchy.
ColorFilter getActualImageColorFilter()
Gets the color filter for the actual image.
PointF getActualImageFocusPoint()
Gets the focus point for the actual image.
ScalingUtils.ScaleType getActualImageScaleType()
Gets the scale type for the actual image.
Drawable getBackground()
Gets the background.
float getDesiredAspectRatio()
Gets the desired aspect ratio.
int getFadeDuration()
Gets the duration of the fade animation.
Drawable getFailureImage()
Gets the failure image.
ScalingUtils.ScaleType getFailureImageScaleType()
Gets the failure image scale type.
List<Drawable> getOverlays()
Gets the overlays.
Drawable getPlaceholderImage()
Gets the placeholder image.
ScalingUtils.ScaleType getPlaceholderImageScaleType()
Gets the placeholder image scale type.
Drawable getPressedStateOverlay()
Gets the overlay for pressed state.
Drawable getProgressBarImage()
Gets the progress bar image.
ScalingUtils.ScaleType getProgressBarImageScaleType()
Gets the progress bar image scale type.
Resources getResources()
Gets resources.
Drawable getRetryImage()
Gets the retry image.
ScalingUtils.ScaleType getRetryImageScaleType()
Gets the retry image scale type.
RoundingParams getRoundingParams()
Gets the rounding params.
static GenericDraweeHierarchyBuilder newInstance(Resources resources)
GenericDraweeHierarchyBuilder reset()
Resets this builder to its initial values making it reusable.
GenericDraweeHierarchyBuilder setActualImageColorFilter(ColorFilter colorFilter)
Sets the color filter for the actual image.
GenericDraweeHierarchyBuilder setActualImageFocusPoint(PointF focusPoint)
Sets the focus point for the actual image.
GenericDraweeHierarchyBuilder setActualImageScaleType(ScalingUtils.ScaleType actualImageScaleType)
Sets the scale type for the actual image.
GenericDraweeHierarchyBuilder setBackground(Drawable background)
Sets a background.
GenericDraweeHierarchyBuilder setDesiredAspectRatio(float desiredAspectRatio)
Sets the desired aspect ratio.
GenericDraweeHierarchyBuilder setFadeDuration(int fadeDuration)
Sets the duration of the fade animation.
GenericDraweeHierarchyBuilder setFailureImage(Drawable failureDrawable, ScalingUtils.ScaleType failureImageScaleType)
Sets the failure image and its scale type.
GenericDraweeHierarchyBuilder setFailureImage(Drawable failureDrawable)
Sets the failure image.
GenericDraweeHierarchyBuilder setFailureImage(int resourceId, ScalingUtils.ScaleType failureImageScaleType)
Sets the failure image and its scale type.
GenericDraweeHierarchyBuilder setFailureImage(int resourceId)
Sets the failure image.
GenericDraweeHierarchyBuilder setFailureImageScaleType(ScalingUtils.ScaleType failureImageScaleType)
Sets the failure image scale type.
GenericDraweeHierarchyBuilder setOverlay(Drawable overlay)
Sets a single overlay.
GenericDraweeHierarchyBuilder setOverlays(List<Drawable> overlays)
Sets the overlays.
GenericDraweeHierarchyBuilder setPlaceholderImage(int resourceId, ScalingUtils.ScaleType placeholderImageScaleType)
Sets the placeholder image and its scale type.
GenericDraweeHierarchyBuilder setPlaceholderImage(Drawable placeholderDrawable, ScalingUtils.ScaleType placeholderImageScaleType)
Sets the placeholder image and its scale type.
GenericDraweeHierarchyBuilder setPlaceholderImage(int resourceId)
Sets the placeholder image.
GenericDraweeHierarchyBuilder setPlaceholderImage(Drawable placeholderDrawable)
Sets the placeholder image.
GenericDraweeHierarchyBuilder setPlaceholderImageScaleType(ScalingUtils.ScaleType placeholderImageScaleType)
Sets the placeholder image scale type.
GenericDraweeHierarchyBuilder setPressedStateOverlay(Drawable drawable)
Sets the overlay for pressed state.
GenericDraweeHierarchyBuilder setProgressBarImage(Drawable progressBarDrawable)
Sets the progress bar image.
GenericDraweeHierarchyBuilder setProgressBarImage(int resourceId)
Sets the progress bar image.
GenericDraweeHierarchyBuilder setProgressBarImage(int resourceId, ScalingUtils.ScaleType progressBarImageScaleType)
Sets the progress bar image and its scale type.
GenericDraweeHierarchyBuilder setProgressBarImage(Drawable progressBarDrawable, ScalingUtils.ScaleType progressBarImageScaleType)
Sets the progress bar image and its scale type.
GenericDraweeHierarchyBuilder setProgressBarImageScaleType(ScalingUtils.ScaleType progressBarImageScaleType)
Sets the progress bar image scale type.
GenericDraweeHierarchyBuilder setRetryImage(int resourceId, ScalingUtils.ScaleType retryImageScaleType)
Sets the retry image and its scale type.
GenericDraweeHierarchyBuilder setRetryImage(int resourceId)
Sets the retry image.
GenericDraweeHierarchyBuilder setRetryImage(Drawable retryDrawable)
Sets the retry image.
GenericDraweeHierarchyBuilder setRetryImage(Drawable retryDrawable, ScalingUtils.ScaleType retryImageScaleType)
Sets the retry image and its scale type.
GenericDraweeHierarchyBuilder setRetryImageScaleType(ScalingUtils.ScaleType retryImageScaleType)
Sets the retry image scale type.
GenericDraweeHierarchyBuilder setRoundingParams(RoundingParams roundingParams)
Sets the rounding params.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int DEFAULT_FADE_DURATION

Constant Value: 300 (0x0000012c)

Fields

public static final ScalingUtils.ScaleType DEFAULT_ACTUAL_IMAGE_SCALE_TYPE

public static final ScalingUtils.ScaleType DEFAULT_SCALE_TYPE

Public Constructors

public GenericDraweeHierarchyBuilder (Resources resources)

Public Methods

public GenericDraweeHierarchy build ()

Builds the hierarchy.

public ColorFilter getActualImageColorFilter ()

Gets the color filter for the actual image.

public PointF getActualImageFocusPoint ()

Gets the focus point for the actual image.

public ScalingUtils.ScaleType getActualImageScaleType ()

Gets the scale type for the actual image.

public Drawable getBackground ()

Gets the background.

public float getDesiredAspectRatio ()

Gets the desired aspect ratio.

public int getFadeDuration ()

Gets the duration of the fade animation.

public Drawable getFailureImage ()

Gets the failure image.

public ScalingUtils.ScaleType getFailureImageScaleType ()

Gets the failure image scale type.

public List<Drawable> getOverlays ()

Gets the overlays.

public Drawable getPlaceholderImage ()

Gets the placeholder image.

public ScalingUtils.ScaleType getPlaceholderImageScaleType ()

Gets the placeholder image scale type.

public Drawable getPressedStateOverlay ()

Gets the overlay for pressed state.

public Drawable getProgressBarImage ()

Gets the progress bar image.

public ScalingUtils.ScaleType getProgressBarImageScaleType ()

Gets the progress bar image scale type.

public Resources getResources ()

Gets resources.

Returns
  • resources

public Drawable getRetryImage ()

Gets the retry image.

public ScalingUtils.ScaleType getRetryImageScaleType ()

Gets the retry image scale type.

public RoundingParams getRoundingParams ()

Gets the rounding params.

public static GenericDraweeHierarchyBuilder newInstance (Resources resources)

public GenericDraweeHierarchyBuilder reset ()

Resets this builder to its initial values making it reusable.

Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setActualImageColorFilter (ColorFilter colorFilter)

Sets the color filter for the actual image.

Parameters
colorFilter color filter to be set
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setActualImageFocusPoint (PointF focusPoint)

Sets the focus point for the actual image.

If a focus point aware scale type is used (e.g. FOCUS_CROP), the focus point of the image will be attempted to be centered within a view. Each coordinate is a real number in [0, 1] range, in the coordinate system where top-left corner of the image corresponds to (0, 0) and the bottom-right corner corresponds to (1, 1).

Parameters
focusPoint focus point of the image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setActualImageScaleType (ScalingUtils.ScaleType actualImageScaleType)

Sets the scale type for the actual image.

If not set, the default value CENTER_CROP will be used.

Parameters
actualImageScaleType scale type for the actual image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setBackground (Drawable background)

Sets a background.

Parameters
background background drawable
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setDesiredAspectRatio (float desiredAspectRatio)

Sets the desired aspect ratio.

Note, the hierarchy itself cannot enforce the aspect ratio. This is merely a suggestion to the view if it supports it.

Parameters
desiredAspectRatio the desired aspect ratio
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setFadeDuration (int fadeDuration)

Sets the duration of the fade animation.

If not set, the default value of 300ms will be used.

Parameters
fadeDuration duration in milliseconds
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setFailureImage (Drawable failureDrawable, ScalingUtils.ScaleType failureImageScaleType)

Sets the failure image and its scale type.

Parameters
failureDrawable drawable to be used as failure image
failureImageScaleType scale type for the failure image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setFailureImage (Drawable failureDrawable)

Sets the failure image.

Parameters
failureDrawable drawable to be used as failure image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setFailureImage (int resourceId, ScalingUtils.ScaleType failureImageScaleType)

Sets the failure image and its scale type.

Parameters
resourceId an identifier of an Android drawable or color resource
failureImageScaleType scale type for the failure image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setFailureImage (int resourceId)

Sets the failure image.

Parameters
resourceId an identifier of an Android drawable or color resource
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setFailureImageScaleType (ScalingUtils.ScaleType failureImageScaleType)

Sets the failure image scale type.

If not set, the default value CENTER_INSIDE will be used.

Parameters
failureImageScaleType scale type for the failure image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setOverlay (Drawable overlay)

Sets a single overlay.

Parameters
overlay overlay drawable
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setOverlays (List<Drawable> overlays)

Sets the overlays.

Overlays are drawn in list order after the backgrounds and the rest of the hierarchy. The last overlay will be drawn at the top.

Parameters
overlays overlay drawables
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setPlaceholderImage (int resourceId, ScalingUtils.ScaleType placeholderImageScaleType)

Sets the placeholder image and its scale type.

Parameters
resourceId an identifier of an Android drawable or color resource
placeholderImageScaleType scale type for the placeholder image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setPlaceholderImage (Drawable placeholderDrawable, ScalingUtils.ScaleType placeholderImageScaleType)

Sets the placeholder image and its scale type.

Parameters
placeholderDrawable drawable to be used as placeholder image
placeholderImageScaleType scale type for the placeholder image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setPlaceholderImage (int resourceId)

Sets the placeholder image.

Parameters
resourceId an identifier of an Android drawable or color resource
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setPlaceholderImage (Drawable placeholderDrawable)

Sets the placeholder image.

Parameters
placeholderDrawable drawable to be used as placeholder image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setPlaceholderImageScaleType (ScalingUtils.ScaleType placeholderImageScaleType)

Sets the placeholder image scale type.

If not set, the default value CENTER_INSIDE will be used.

Parameters
placeholderImageScaleType scale type for the placeholder image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setPressedStateOverlay (Drawable drawable)

Sets the overlay for pressed state.

Parameters
drawable for pressed state

public GenericDraweeHierarchyBuilder setProgressBarImage (Drawable progressBarDrawable)

Sets the progress bar image.

Parameters
progressBarDrawable drawable to be used as progress bar image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setProgressBarImage (int resourceId)

Sets the progress bar image.

Parameters
resourceId an identifier of an Android drawable or color resource
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setProgressBarImage (int resourceId, ScalingUtils.ScaleType progressBarImageScaleType)

Sets the progress bar image and its scale type.

Parameters
resourceId an identifier of an Android drawable or color resource
progressBarImageScaleType scale type for the progress bar image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setProgressBarImage (Drawable progressBarDrawable, ScalingUtils.ScaleType progressBarImageScaleType)

Sets the progress bar image and its scale type.

Parameters
progressBarDrawable drawable to be used as progress bar image
progressBarImageScaleType scale type for the progress bar image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setProgressBarImageScaleType (ScalingUtils.ScaleType progressBarImageScaleType)

Sets the progress bar image scale type.

If not set, the default value CENTER_INSIDE will be used.

Parameters
progressBarImageScaleType scale type for the progress bar image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setRetryImage (int resourceId, ScalingUtils.ScaleType retryImageScaleType)

Sets the retry image and its scale type.

Parameters
resourceId an identifier of an Android drawable or color resource
retryImageScaleType scale type for the retry image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setRetryImage (int resourceId)

Sets the retry image.

Parameters
resourceId an identifier of an Android drawable or color resource
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setRetryImage (Drawable retryDrawable)

Sets the retry image.

Parameters
retryDrawable drawable to be used as retry image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setRetryImage (Drawable retryDrawable, ScalingUtils.ScaleType retryImageScaleType)

Sets the retry image and its scale type.

Parameters
retryDrawable drawable to be used as retry image
retryImageScaleType scale type for the retry image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setRetryImageScaleType (ScalingUtils.ScaleType retryImageScaleType)

Sets the retry image scale type.

If not set, the default value CENTER_INSIDE will be used.

Parameters
retryImageScaleType scale type for the retry image
Returns
  • modified instance of this builder

public GenericDraweeHierarchyBuilder setRoundingParams (RoundingParams roundingParams)

Sets the rounding params.

Parameters
roundingParams rounding params to be set
Returns
  • modified instance of this builder