Fresco源码之DraweeHierachy

来源:互联网 发布:淘宝上远程降级可靠吗 编辑:程序博客网 时间:2024/04/29 01:52

DraweeHierachy源码查看

看DraweeHierachy源码之前,我们先看一下DraweeHierachy的继承体系
DraweeHierachy (I)
–| SettableDraweeHierarchy (I)
——| GenericDraweeHierarchy

GenericDraweeHierarchy

GenericDraweeHierarchy是一个顶级接口,只有获取顶层的Drawable方法getTopLevelDrawable

public interface DraweeHierarchy {  /**   * Returns the top level drawable in the corresponding hierarchy. Hierarchy should always have   * the same instance of its top level drawable.   * @return top level drawable   */  Drawable getTopLevelDrawable();}

SettableDraweeHierarchy

SettableDraweeHierarchy继承与DraweeHierachy,也是一个接口:
用于获取顶层的drawable
图像可以被重置
图像可以设置进度
设置失败
设置重试
设置controllerOverlay

 /**   * Called by controller when the hierarchy should be reset to its initial state. Any image   * previously set by {@code setImage} should be detached and not used anymore.   */  void reset();  /**   * Called by controller when the future that provides the actual image completes successfully.   * Hierarchy should display the actual image.   * @param drawable drawable to be set as the temporary image   * @param progress number in range [0, 1] that indicates progress   * @param immediate if true, image will be shown immediately (without fade effect)   */  void setImage(Drawable drawable, 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.   * @param progress number in range [0, 1] that indicates progress   * @param immediate if true, progressbar will be shown/hidden immediately (without fade effect)   */  void setProgress(float progress, boolean immediate);  /**   * 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.   * @param throwable cause of failure   */  void setFailure(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.   * @param throwable cause of failure   */  void setRetry(Throwable throwable);  /**   * Called by controller if it needs to display some controller overlay.   * @param drawable drawable to be displayed as controller overlay   */  void setControllerOverlay(Drawable drawable);

GenericDraweeHierarchy

GenericDraweeHierarchy是SettableDraweeHierarchy的实现类,用来实现:
图像可以被重置
图像可以设置进度
设置失败
设置重试
设置controllerOverlay

这里就不再赘述。

0 0