Picasso processes the same url, but the resource changes, picassourl
Problem: After the Avatar is uploaded successfully, the Avatar url remains unchanged. When the Avatar is loaded, the previous image is still loaded from the cache according to the url.
Many people have encountered this problem. It is also inspired by many colleagues.
The image url remains unchanged, and it is not very reasonable. This will mess up the cache.
However, as a programmer, I still have to think about how to solve this problem.
1. Since it is a problem caused by caching, the first thing I should consider is clearing the cache.
Using Picasso. with (context). invalidate (path) has no effect,
In addition, mClient. cache (). delete (); is powerless.
I think this should be because the memory cache still has the corresponding image problem...
But it seems that there is no way to clear the memory cache...
This question is too difficult. It is too difficult. I will not do it...
Let's change your mind.
2. The path for clearing the cache cannot be reached, so you can change the path.
Can I directly remove images from the network without reading data from the cache?
This is relatively simple. Picasso provides the following methods:
Picasso. with (context)
. Load (url)
. Fit ()
. MemoryPolicy (MemoryPolicy. NO_CACHE)
. NetworkPolicy (NetworkPolicy. NO_CACHE)
. Into (imageView)
After a try, the Avatar can be loaded normally.
However, it is a waste of traffic to download images from the Internet every time, and the user experience is not very good.
I only force the image to be retrieved from the network after the image is uploaded successfully, and cache is used in other places.
I think this has already met my current needs.
Tips ~~~