0
在我的應用程序中,我使用自定義下載程序來下載圖像,因爲服務器需要請求標頭中的額外授權。我正嘗試在離線模式下載入下載的圖像,但是當我使用此自定義下載程序時,畢加索不加載圖像。任何人可以幫忙?使用自定義下載程序在離線下載中緩存的圖像
OkHttpClient picassoClient = new OkHttpClient();
picassoClient.interceptors().add(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request newRequest = chain.request().newBuilder()
.addHeader(RestUtils.HEADER, hash)
.build();
return chain.proceed(newRequest);
}
}
);
Picasso picasso = new Picasso.Builder(mContext)
.downloader(new OkHttpDownloader(picassoClient)).build();
picasso.setIndicatorsEnabled(true);
picasso.invalidate(RestUtils.getUrl(url));
if (DeviceUtility.isOnline(mContext)) {
picasso.load(RestUtils.getUrl(url))
.networkPolicy(
DeviceUtility.isOnline(mContext) ?
NetworkPolicy.NO_CACHE : NetworkPolicy.OFFLINE)
.resize(200, 200)
.centerCrop()
.into(viewHolder.mImgvPicture);
} else {
picasso.load(RestUtils.getUrl(url))
.networkPolicy(
DeviceUtility.isOnline(mContext) ?
NetworkPolicy.NO_CACHE : NetworkPolicy.OFFLINE)
.resize(200, 200)
.centerCrop()
.into(viewHolder.mImgvPicture);
}