我必须使用定制的OkHttpClient,以便在图像请求中添加头信息。问题是由于这个原因,Picasso不会将任何图像缓存到磁盘上。我已经使用了setIndicatorsEnabled(true)
来检查缓存情况,结果只显示红色指示器。当我使用默认的OkHttpDownloader时一切都正常。以下是我的Picasso初始化代码。是否有人遇到过相同的问题?
public static void init(Context context) {
Picasso.Builder builder = new Picasso.Builder(context);
OkHttpClient client = new OkHttpClient();
client.interceptors().add(new AuthInterceptor());
Downloader downloader = new OkHttpDownloader(client);
Picasso.setSingletonInstance(builder.downloader(downloader).build());
Picasso.with(context).setIndicatorsEnabled(true);
}
同时,这是我的图像下载代码。
public static void load(final ImageView imageView, final Image image) {
Picasso.with(imageView.getContext())
.load(image.getUrl())
.resize(400, 0)
.memoryPolicy(MemoryPolicy.NO_CACHE)
.into(imageView);
}
.memoryPolicy(MemoryPolicy.NO_CACHE)
操作? - Bhargav