Is it completely correct that Picasso understands NOT to upload if the presentation has been redesigned?

I'm a little confused: as a rule, when asynchronously loading images into some kind of list (whether on Android or iOS or in abstract on another platform), you essentially have to do this ..

-- make a note of "which" cell this is (say, #213) -- start getting the image from the net. -- it has loaded from the net. What cell are we now? -- if we are "still" 213, load the image to the image view! -- if we are "no longer" 213, just forget about it. 

This is the main delayed boot asynchronous image. For example, Lucas Rocha perfectly explains this in a famous article:

http://lucasr.org/2012/04/05/performance-tips-for-androids-listview/

(scroll down to "Here is just a simplified outline of the way you could do this:" ...)

Well, now, as I understand it, Picasso actually does this for you completely automatically.

Picasso himself “knows” whether the view has changed. If the view has changed, Picasso knows whether to download it

Am I completely right? This is Picasso's built-in feature and I don’t have to do anything else?

(In addition, I'm somewhat puzzled by how Picasso does it; looking at him, I don’t see any magic code in Picasso where he writes the identifier, or something like the owner’s “view”).)


Just to be clear, I am using Picasso in the usual way, just like it is, in fact, at the end of getView ...

 Picasso. with(State.mainContext). load(imageFile.getUrl()). placeholder(R.drawable.default). noFade(). into(v.hexaIV); 
+1
android picasso lazy-loading async-loading
source share
1 answer

Yes, Picasso is beautiful. You only need one line inside the getView () Picasso.with(c).load(url).into(img);

how they do it, I'm not sure, but before Picasso existed, I made my own image downloader, and it's not that difficult.

Say you have an Url map and an ImageView somewhere in your image downloader code.

Therefore, whenever the code passes img to it, it checks this map, if it already loads another URL for the same img , using the base Java mImg.equals(img) , if it matches, it knows that even you - This URL will still be cached, it should not deliver Drawable to ImageView.

There are a few rare cases where you can directly cancel the download, in cases where you can call Picasso.with(c).cancel(img); but it is rarely necessary.

+3
source share

All Articles