从磁盘加载缓存图片与毕加索,如果离线 [英] Load images from disk cache with Picasso if offline
问题描述
我有我从不同的网站下载一些图片,当应用程序启动时,通过执行此操作:
I have some images that I download from different web sites when the app starts, by doing this:
Picasso.with(context).load(image_url).fetch();
现在,假设用户关闭应用程序,并打开离线。当应用程序重新开始,毕加索显示以这种方式将图像
Now, suppose the user closes the app and turns offline. When the app starts again, Picasso display the images in this way:
Picasso.with(ctx).load(image_url).placeholder(R.drawable.ph).into(imageView);
的问题是,一些图像从磁盘高速缓存(黄色三角形在调试模式)加载,并为其他毕加索显示占位符
The problem is that some images are loaded from the disk cache (yellow triangle in debug mode), and for the others Picasso shows the placeholder.
为什么呢?我期待每一个图像从磁盘缓存加载。
Why? I'm expecting that every image is loaded from the disk cache.
推荐答案
做到这一点:
Picasso.with(this)
.load(url)
.networkPolicy(NetworkPolicy.OFFLINE)
.into(imageView);
还检查我的previous答案,也许会帮助你: <一href="http://stackoverflow.com/questions/22016382/invalidate-cache-in-picasso/29812708#29812708">Invalidate在毕加索缓存
Also check my previous answer, maybe will help you: Invalidate cache in Picasso
这篇关于从磁盘加载缓存图片与毕加索,如果离线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!