Picasso processes the same url, but the resource changes, picassourl

Source: Internet
Author: User

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 ~~~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.