I am using Picasso in my android application for image caching. But whenever i open app the images starts loading from the server. But i want to use cached images from disk and simultaneously it should check for new image on server as well. Same like whatsapp do.
If i am using Network Policy to Offline it doesn't load the new image from server it just using the offline images.
url = Static.url+"users/image?id="+id;
profileImg = R.drawable.user;
Picasso.with(activity)
.load(url)
.placeholder(profileImg)
.into(imageView, new Callback() {
@Override
public void onSuccess() {
Picasso.with(activity)
.load(url)
.networkPolicy(NetworkPolicy.OFFLINE)
.placeholder(profileImg)
.error(profileImg)
.into(imageView);
}
@Override
public void onError() {
// Try again online if cache failed
}
});
The above code is working but image loading is still not very much quick. The image should be immediately loaded from cache and also it should check online at the same moment for new image.
Please guide.