public class

DraweeHolder

extends Object
implements VisibilityCallback
java.lang.Object
   ↳ com.facebook.drawee.view.DraweeHolder<DH extends com.facebook.drawee.interfaces.DraweeHierarchy>

Class Overview

A holder class for Drawee controller and hierarchy.

Drawee users, should, as a rule, use DraweeView or its subclasses. There are situations where custom views are required, however, and this class is for those circumstances.

Each DraweeHierarchy object should be contained in a single instance of this class.

Users of this class must call setBounds(Rect) on the top-level drawable of the DraweeHierarchy. Otherwise the drawable will not be drawn.

The containing view must also call onDetach() from its onStartTemporaryDetach() and onDetachedFromWindow() methods. It must call onAttach() from its onFinishTemporaryDetach() and onAttachedToWindow() methods.

Summary

Public Constructors
DraweeHolder(DH hierarchy)
Creates a new instance of DraweeHolder.
Public Methods
static <DH extends DraweeHierarchy> DraweeHolder<DH> create(DH hierarchy, Context context)
Creates a new instance of DraweeHolder that detaches / attaches controller whenever context notifies it about activity's onStop and onStart callbacks.
DraweeController getController()
Gets the controller if set, null otherwise.
DH getHierarchy()
Gets the drawee hierarchy if set, throws NPE otherwise.
Drawable getTopLevelDrawable()
Gets the top-level drawable if hierarchy is set, null otherwise.
boolean hasHierarchy()
Returns whether the hierarchy is set or not.
boolean isAttached()
Checks whether the view that uses this holder is currently attached to a window.
boolean isControllerValid()
Returns whether currently set controller is valid: not null and attached to the hierarchy that is held by the holder
void onAttach()
Gets the controller ready to display the image.
void onDetach()
Releases resources used to display the image.
void onDraw()
Callback used to notify about top-level-drawable being drawn.
boolean onTouchEvent(MotionEvent event)
Forwards the touch event to the controller.
void onVisibilityChange(boolean isVisible)
Callback used to notify about top-level-drawable's visibility changes.
void registerWithContext(Context context)
For future use.
void setController(DraweeController draweeController)
Sets a new controller.
void setHierarchy(DH hierarchy)
Sets the drawee hierarchy.
String toString()
Protected Methods
DraweeEventTracker getDraweeEventTracker()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.facebook.drawee.drawable.VisibilityCallback

Public Constructors

public DraweeHolder (DH hierarchy)

Creates a new instance of DraweeHolder.

Public Methods

public static DraweeHolder<DH> create (DH hierarchy, Context context)

Creates a new instance of DraweeHolder that detaches / attaches controller whenever context notifies it about activity's onStop and onStart callbacks.

public DraweeController getController ()

Gets the controller if set, null otherwise.

public DH getHierarchy ()

Gets the drawee hierarchy if set, throws NPE otherwise.

public Drawable getTopLevelDrawable ()

Gets the top-level drawable if hierarchy is set, null otherwise.

public boolean hasHierarchy ()

Returns whether the hierarchy is set or not.

public boolean isAttached ()

Checks whether the view that uses this holder is currently attached to a window.

Returns
  • true if the holder is currently attached

public boolean isControllerValid ()

Returns whether currently set controller is valid: not null and attached to the hierarchy that is held by the holder

public void onAttach ()

Gets the controller ready to display the image.

The containing view must call this method from both onFinishTemporaryDetach() and onAttachedToWindow().

public void onDetach ()

Releases resources used to display the image.

The containing view must call this method from both onStartTemporaryDetach() and onDetachedFromWindow().

public void onDraw ()

Callback used to notify about top-level-drawable being drawn.

public boolean onTouchEvent (MotionEvent event)

Forwards the touch event to the controller.

Parameters
event touch event to handle
Returns
  • whether the event was handled or not

public void onVisibilityChange (boolean isVisible)

Callback used to notify about top-level-drawable's visibility changes.

Parameters
isVisible whether or not the drawable is visible

public void registerWithContext (Context context)

For future use.

public void setController (DraweeController draweeController)

Sets a new controller.

public void setHierarchy (DH hierarchy)

Sets the drawee hierarchy.

public String toString ()

Protected Methods

protected DraweeEventTracker getDraweeEventTracker ()