您好我正在尝试下载并存储使用piccaso android检索到的图像并增加磁盘缓存但不幸的是,当我加载图像时,退出应用程序,下线然后重新启动应用程序,Picasso不会似乎加载了应该缓存的图像?
这是我的代码:
var picascoBuilder = Picasso.Builder(view.context)
.downloader(OkHttp3Downloader(view.context, Integer.MAX_VALUE.toLong()))
.build()
picascoBuilder.load(offer.imgUrl).into(view.productImage)
答案 0 :(得分:0)
在你的班级中定义这些变量
private static final int OFFLINE = 1 << 2;
private static final int NO_STORE = 1 << 1;
private static final int NO_CACHE = 1 << 0;
将此行用于离线模式:
var picascoBuilder = Picasso.Builder(view.context)
.downloader(OkHttp3Downloader(view.context, OFFLINE))
.build()
和在线模式的这一行:
var picascoBuilder = Picasso.Builder(view.context)
.downloader(OkHttp3Downloader(view.context, 0))
.build()