目录:A.简介及使用
PART_ 源码
- 我们可以使用如下方法加载网络图片,之后会详解各个调用到的链式方法的内部实现
Picasso.get() .load(url) .placeholder(R.mipmap.ic_launcher) // 加载过程占位图 .error(R.mipmap.ic_launcher_round) // 加载错误占位图 .into(iv);
-
Picasso.get()
public static Picasso get() { /* 通过单例获取Picasso实例 */ if (singleton == null) { synchronized (Picasso.class) { if (singleton == null) { // context是在ContentProvider的onCreate()中通过getContext()获取 if (PicassoProvider.context == null) { throw new IllegalStateException("context == null"); } singleton = new Builder(PicassoProvider.context).build(); } } } return singleton; }