Picasso封装优化.docVIP

  • 10
  • 0
  • 约1.56万字
  • 约 12页
  • 2017-01-22 发布于重庆
  • 举报
Picasso封装优化

Picasso封装优化 Picasso在使用过程中,经常忘记一些设置,比如图片的加载方式.centerCrop(),图片的加载优化.fit(),以及对图片的url的处理,因此对图片加载进行统一封装,使用相同的加载方式更有利于后期的维护和扩展。 图片的加载来源 图片的加载来源主要是String,file,Resource,我们都有相应的封装, 为了介绍方便 以下仅仅介绍String方式,以下同时有centerCrop和centerInside,同样我只是介绍centerCrop方式。 示例代码,对应三种加载方式: public static void loadCenterCrop(@NonNull Context context, String path, @DrawableRes int placeholderResId, @DrawableRes int errorResId, @NonNull ImageView target) { Picasso.with(context) .load(checkAndHandleUrl(path)) .placeholder(placeholderResId) .error(errorResId) .centerCrop()

文档评论(0)

1亿VIP精品文档

相关文档