gpt4 book ai didi

java - 如何清除 picasso 的缓存?

转载 作者:行者123 更新时间:2023-11-30 01:42:38 25 4
gpt4 key购买 nike

我正在开发一个 android 应用程序。在该应用程序中,服务器存储要在 ListView 的 imageView 中显示的图像。我使用 picasso 从服务器获取图像并显示在 imageview 中。虽然我已经在服务器上载了新图片,但再次显示的只是旧图片。我怀疑这是由于 picasso 的缓存。我使用了 3 种方法来防止缓存:

Picasso.with(getActivity()).load(data.get(pos).getFeed_thumb_image()).skipMemoryCache().into(image);

Picasso.with(getActivity()).load(data.get(pos).getFeed_thumb_image()).memoryPolicy(MemoryPolicy.NO_CACHE).into(image);

Picasso.with(context).invalidate(imagePath);

但是没有结果。如何清除 picasso 中特定 url 的缓存?

最佳答案

这将在未来实现,但请参阅 post of Jake Wharton :

JakeWharton commented on 11 Dec 2014 Current best candidate:

picasso.load('http://example.com/')
.cachePolicy(NO_CACHE, NO_STORE)
.networkPolicy(NO_CACHE, NO_STORE, OFFLINE)
.into(imageView);

enum MemoryPolicy {
NO_CACHE, NO_STORE
}
enum NetworkPolicy {
NO_CACHE, NO_STORE, OFFLINE
}

This will be what's implemented unless anyone has other thoughts.

关于java - 如何清除 picasso 的缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34232683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com