Sometimes Picasso doesn't load the image from memory cache

不问归期 提交于 2019-12-03 10:09:19

Your Target is being garbage collected because nothing is holding a reference to it. Picasso uses a WeakReference when holding ImageViews or Targets.

However, you need not use Target at all. Simply use the callback of .into and pass the ImageView directly.

Picasso.with(context).load(url).into(imageView, new Callback() {
  @Override public void onSuccess() {
    imageView.setVisibility(VISIBLE);
    textView.setVisibility(GONE);
  }

  @Override public void onError() {
    imageView.setVisibility(GONE);
    textView.setVisibility(VISIBLE);
  }
});
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!