How do I tell Picasso that the image in the link has changed?

im using picasso library to load images. However, in my application, users can have profile pictures, and the link for the picture is persistent ... Picasso has no idea that the picture has changed ...

I tried using:, .skipMemoryCache()

but it was not a perfect solution ...

Is there a way to check if there is a new image in the same link using picasso? Thank you!

+3


source to share


4 answers


Apparently in the current version (2.3.2) of Picasso there is no API in the API (but this is work in progress - see this bug).

As an aside, if you have control over the back end, you might want to consider your design decision to ensure that the profile of the image is changed with a persistent url.



An alternative might be to: Include the current profile picture URL in the profile information you are retrieving. This way your cache can use the cached image - and as soon as the profile information provides a new URL, Picasso will pick it up. In all other cases, Picasso can use the cache.

+4


source


I got a response from link

change your url like below:



String imageurl = url + "?time=" + System.currentTimeMillis();

Picasso.with(getContext()).load(imageurl).into(imageView);

      

it worked for me. thank

+3


source


Picasso.with(context)
.load(url)
.memoryPolicy(MemoryPolicy.NO_CACHE)
.networkPolicy(NetworkPolicy.NO_CACHE)
.fit()
.placeholder(YOUR PLACE HOLDER RESOURCE)
.centerCrop()
.into(imageView);

      

+3


source


One solution is to invalidate the cache this way

Picasso.with(context).invalidate(imagePath);

      

Another way is to force the download of an image, which is then cached for later use in quality in code.

Picasso.with(context)
        .load(imagePath)
        .networkPolicy(NetworkPolicy.NO_CACHE)
        .into(userAvatar);

      

+1


source







All Articles