Is there any way from which we can detect images are loading from cache in picasso?

匿名 (未验证) 提交于 2019-12-03 08:28:06

问题:

as title suggest I want to check whether images are loading from cache or not.

I've done something like this but couldn't succeeded.

Picasso.with(getApplicationContext())                 .load(data.get(position).get("product_image"))                 .into(viewHolder.imgViewIcon, new Callback() {                      @Override                     public void onSuccess() {                         viewHolder.imgViewIcon.setVisibility(View.VISIBLE);                         if (Picasso.LoadedFrom.NETWORK != null)                             YoYo.with(Techniques.ZoomIn).duration(1200)                                     .playOn(viewHolder.imgViewIcon);                         viewHolder.placeholder.setVisibility(View.GONE);                     }                      @Override                     public void onError() {                      }                 }); 

Please anyone have batter option then tell me. Thanks.

回答1:

Use Picasso's setIndicatorEnabled(true) to detect where the image is loaded from.

Picasso picasso = Picasso.with(context); picasso.setIndicatorsEnabled(true);  //... picasso.load("http://example.com/image.jpg").into(myImageView); 

A colored ribbon will appear in the top left corner.

  • Red: network
  • Yellow: disk
  • Green: memory

Source: Picasso - Debug Indicators



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!