android - 检查缓存 picasso 中是否存在图像

标签 android picasso

我想检查图像 url 是否包含在缓存中。我正在使用 Picasso 图像加载器。

这是我的代码

new Picasso.Builder(this).downloader(new OkHttpDownloader(client)).build();

现在 Picasso.getCache() 没有 get(key)

虽然 Cache 类在内部使用 LRUDiskCache 但它的 private

有什么想法吗??

最佳答案

Jake 已经在 Twitter ( https://twitter.com/JakeWharton/status/679403330809028608 ) 上回答了这个问题,但我在这里重新发布答案以提高可见性。

You could make a request with a network policy of OFFLINE and if it fails then the image is not in the disk cache.

关于android - 检查缓存 picasso 中是否存在图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34417976/

相关文章:

android - 如何通过 XML 布局显示 Android UI?

android - 关闭 PreferenceFragment

android - 使 picasso 中的缓存无效

android - 捕获图像后尝试设置图像时获取 "Caused by: java.lang.NullPointerException: uri"

android - Picasso 中 skipMemoryCache() 的潜在问题?

java - 如何刷新Listview始终选项卡式布局?

java - Android Tabhost刷新

android - LeetCode 错误 : Warning : Classpath entry points to a non-existent location:

android - 如何使用 Picasso 将歌曲专辑封面加载到 ImageView?

java - 使用 picasso 将图像大小调整为全宽和固定高度