Fresco源码之DraweeHierachy

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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值