我知道Picasso可以自动下载和缓存图片,但是如果我重新启动手机,而且我没有上网,我该如何访问相同的图片?
这是我的实施
// Picasso doesn't process URIs as strings, but as files
if(songObject.albumArtURI != null){
File f = new File(songObject.albumArtURI);
Picasso.with(viewHolder.albumArt.getContext())
.load(f)
.transform(new CircleTransform())
.placeholder(R.drawable.blackcircle)
.into(viewHolder.albumArt);
// If songObject doesn't have URI but it has a URL do this
} else if(songObject.albumURL != null){
Picasso.with(viewHolder.albumArt.getContext())
.load(songObject.albumURL)
.transform(new CircleTransform())
.placeholder(R.drawable.blackcircle)
.into(viewHolder.albumArt);
// Otherwise download the URL
} else {
String JSONURL = "https://itunes.apple.com/search?term=michael+jackson";
getRequestQueue();
GsonRequest<SongInfo> myReq = new GsonRequest<SongInfo>(
Request.Method.GET,
JSONURL,
SongInfo.class,
null,
createMyReqSuccessListener(songObject),
createMyReqErrorListener());
mRequestQueue.add(myReq);
Picasso.with(viewHolder.albumArt.getContext())
.load(R.drawable.blackcircle)
.transform(new CircleTransform())
.placeholder(R.drawable.blackcircle)
.into(viewHolder.albumArt);
}