Back to Fresco

GenericDraweeHierarchy

docs/javadoc/reference/com/facebook/drawee/generic/GenericDraweeHierarchy.html

3.6.031.5 KB
Original Source

Fresco

|

|

Packages | Classes

Classes

Enums

Packages | Classes

Summary: Methods | Inherited Methods | [Expand All]

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. Rounding is supported.

Example hierarchy with a placeholder, retry, failure and the actual image:

o RootDrawable (top level drawable)
  |
  +--o FadeDrawable
     |
     +--o ScaleTypeDrawable (placeholder branch, optional)
     | |
     | +--o Drawable (placeholder image)
     |
     +--o ScaleTypeDrawable (actual image branch)
     | |
     | +--o ForwardingDrawable (actual image wrapper)
     | |
     | +--o Drawable (actual image)
     |
     +--o null (progress bar branch, optional)
     |
     +--o Drawable (retry image branch, optional)
     |
     +--o ScaleTypeDrawable (failure image branch, optional)
        |
        +--o Drawable (failure image)

Note:

  • RootDrawable and FadeDrawable are always created.
  • All branches except the actual image branch are optional (placeholder, failure, retry, progress bar). If some branch is not specified it won't be created. Index in FadeDrawable will still be reserved though.
  • If overlays and/or background are specified, they are added to the same fade drawable, and are always being displayed.
  • ScaleType and Matrix transformations will be added only if specified. If both are unspecified, then the branch for that image is attached to FadeDrawable directly. Matrix transformation is only supported for the actual image, and it is not recommended to be used.
  • Rounding, if specified, is applied to all layers. Rounded drawable can either wrap FadeDrawable, or if leaf rounding is specified, each leaf drawable will be rounded separately.
  • A particular drawable instance 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
Gets the non-cropped post-scaling bounds of the actual image.
PointF
ScalingUtils.ScaleType
Rect
int
Gets the fade duration.
RoundingParams
Gets the rounding params.
Drawable
Returns the top level drawable in the corresponding hierarchy.
boolean
boolean
void
Called by controller when the hierarchy should be reset to its initial state.
void
Sets the color filter to be applied on the actual image.
void
Sets the actual image focus point.
void
Sets the actual image scale type.
void
Sets the background image if allowed.
void
Called by controller if it needs to display some controller overlay.
void
Sets the fade duration.
void
Called by controller when the future that provides the actual image completes with failure.
void
Sets a new failure drawable with old scale type.
void
Sets a new failure drawable with scale type.
void
Sets a new failure drawable with scale type.
void
Sets a new failure drawable with old scale type.
void
Called by controller when the future that provides the actual image completes successfully.
void
void
Sets a new overlay image at the specified index.
void
Sets the overlay image if allowed.
void
Sets a new placeholder drawable with old scale type.
void
Sets a new placeholder drawable with scale type.
void
Sets a new placeholder drawable with scale type.
void
Sets a new placeholder drawable with old scale type.
void
Sets the placeholder image focus point.
void
Called by controller to update the progress.
void
Sets a new progress bar drawable with scale type.
void
Sets a new progress bar drawable with old scale type.
void
Sets a new progress bar drawable with scale type.
void
Sets a new progress bar drawable with old scale type.
void
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
Sets a new retry drawable with scale type.
void
Sets a new retry drawable with old scale type.
void
Sets a new retry drawable with scale type.
void
Sets a new retry drawable with old scale type.
void
Sets the rounding params.

| [Expand] Inherited Methods | | --- | | From class java.lang.Object

| Object | clone() | | boolean | equals(Object arg0) | | void | finalize() | | final Class<?> | getClass() | | int | hashCode() | | final void | notify() | | final void | notifyAll() | | String | toString() | | final void | wait(long arg0, int arg1) | | final void | wait(long arg0) | | final void | wait() |

| | From interface com.facebook.drawee.interfaces.DraweeHierarchy

| abstract Rect | getBounds() | | abstract Drawable | getTopLevelDrawable() Returns the top level drawable in the corresponding hierarchy. |

| | From interface com.facebook.drawee.interfaces.SettableDraweeHierarchy

| abstract void | reset() Called by controller when the hierarchy should be reset to its initial state. | | abstract void | setControllerOverlay(Drawable drawable) Called by controller if it needs to display some controller overlay. | | abstract void | setFailure(Throwable throwable) Called by controller when the future that provides the actual image completes with failure. | | abstract void | setImage(Drawable drawable, float progress, boolean immediate) Called by controller when the future that provides the actual image completes successfully. | | abstract void | setProgress(float progress, boolean immediate) Called by controller to update the progress. | | abstract 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. |

|

Public Methods

public void getActualImageBounds(RectF outBounds)

Gets the non-cropped post-scaling bounds of the actual image.

public PointF getActualImageFocusPoint()

public ScalingUtils.ScaleType getActualImageScaleType()

public Rect getBounds()

public int getFadeDuration()

Gets the fade duration.

public RoundingParams getRoundingParams()

Gets the 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 boolean hasImage()

public boolean hasPlaceholderImage()

Returns
  • true if there is a placeholder image set.

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 setBackgroundImage(Drawable drawable)

Sets the background image if allowed.

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 setFadeDuration(int durationMs)

Sets the fade duration.

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 setFailureImage(Drawable drawable)

Sets a new failure drawable with old scale type.

public void setFailureImage(Drawable drawable, ScalingUtils.ScaleType scaleType)

Sets a new failure drawable with scale type.

public void setFailureImage(int resourceId, ScalingUtils.ScaleType scaleType)

Sets a new failure drawable with scale type.

Parameters

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

public void setFailureImage(int resourceId)

Sets a new failure drawable with old scale type.

Parameters

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

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 setOnFadeListener(FadeDrawable.OnFadeListener onFadeFinished)

public void setOverlayImage(int index, Drawable drawable)

Sets a new overlay image at the specified index.

This method will throw if the given index is out of bounds.

Parameters

| drawable | background image |

public void setOverlayImage(Drawable drawable)

Sets the overlay image if allowed.

public void setPlaceholderImage(Drawable drawable)

Sets a new placeholder drawable with old scale type.

public void setPlaceholderImage(int resourceId, ScalingUtils.ScaleType scaleType)

Sets a new placeholder drawable with scale type.

Parameters

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

public void setPlaceholderImage(Drawable drawable, ScalingUtils.ScaleType scaleType)

Sets a new placeholder drawable with scale type.

public void setPlaceholderImage(int resourceId)

Sets a new placeholder drawable with old scale type.

Parameters

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

public void setPlaceholderImageFocusPoint(PointF focusPoint)

Sets the placeholder image focus point.

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 setProgressBarImage(int resourceId, ScalingUtils.ScaleType scaleType)

Sets a new progress bar drawable with scale type.

Parameters

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

public void setProgressBarImage(Drawable drawable)

Sets a new progress bar drawable with old scale type.

public void setProgressBarImage(Drawable drawable, ScalingUtils.ScaleType scaleType)

Sets a new progress bar drawable with scale type.

public void setProgressBarImage(int resourceId)

Sets a new progress bar drawable with old scale type.

Parameters

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

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 setRetryImage(int resourceId, ScalingUtils.ScaleType scaleType)

Sets a new retry drawable with scale type.

Parameters

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

public void setRetryImage(int resourceId)

Sets a new retry drawable with old scale type.

Parameters

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

public void setRetryImage(Drawable drawable, ScalingUtils.ScaleType scaleType)

Sets a new retry drawable with scale type.

public void setRetryImage(Drawable drawable)

Sets a new retry drawable with old scale type.

public void setRoundingParams(RoundingParams roundingParams)

Sets the rounding params.

+Generated by Doclava. +