Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to inform Picasso that the image in the link changed?

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

I tried using : .skipMemoryCache() but it wasn't an ideal solution...

Is there a way to check if there's a new picture in the same link using picasso? Thanks!

like image 310
Fringo Avatar asked Dec 20 '22 11:12

Fringo


2 Answers

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

That aside, if you have control of the server side, you may want to think about your design decision to provide the changing profile picture at a constant URL.

An alternative would be: Include the current profile picture URL in the profile information you retrieve. This way, your cache can use the cached image - and as soon as the profile information provides a new URL, Picasso will fetch it. In all other cases, Picasso can leverage the cache.

like image 98
Patrick Avatar answered Jan 10 '23 15:01

Patrick


I got the answer from this link

change your URL as shown below:

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

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

this worked for me. thanks

like image 32
Nabeel K Avatar answered Jan 10 '23 17:01

Nabeel K