android – 如果離線,從Picasso磁碟快取載入映像
我有一些影象,從應用程式啟動時,從不同的網站下載,通過這樣做:
Picasso.with(context).load(image_url).fetch();
現在,假設使用者關閉應用並離線.當應用程式再次啟動時,Picasso以這種方式顯示影象:
Picasso.with(ctx).load(image_url).placeholder(R.drawable.ph).into(imageView);
問題是某些影象是從磁碟快取(除錯模式中的黃色三角形)載入的,而其他的畢加索則顯示佔位符.
為什麼?我期望每個影象都從磁碟快取載入.
Picasso.with(context) .load(Uri.parse(getItem(position).getStoryBigThumbUrl())) .networkPolicy(NetworkPolicy.OFFLINE) .into(holder.storyBigThumb, new Callback() { @Override public void onSuccess() { } @Override public void onError() { // Try again online if cache failed Picasso.with(context) .load(Uri.parse(getItem(position) .getStoryBigThumbUrl())) .placeholder(R.drawable.user_placeholder) .error(R.drawable.user_placeholder_error) .into(holder.storyBigThumb); } });
http://stackoverflow.com/questions/23391523/load-images-from-disk-cache-with-picasso-if-offline