Should I stagger a large number of image load calls?

谁都会走 提交于 2019-12-22 00:58:34

问题


I have a ListView with ~100 large images. Each image is about 640.640 jpg and is shown 1/2 screen size. Typical gallery.

I am currently loading the images using the wonderful universal-image-loader-1.9.2.

ParseFile photoFile = p.getParseFile("imageFile");
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.displayImage( photoFile.getUrl(), theImageView );

Now, you get a bit of stutter on the ListView, when they are loading.

Now, coincidentally, I had the phone on a very slow WiFi network. IN FACT, IT WAS SMOOTH AS SILK.

At first, I couldn't work out why the sudden improvement! Serendipity!

In fact then, in that situation: is it worth staggering the calls to load the images?

So, I could leave 0.1" between each call, for example.

Or indeed, should I just do them one follows the other maybe?!

What's the deal there? Do all android engineers do this all the time? Cheers!

I've already applied all the other classical techniques I have googled up for buttery smooth ListView scrolling. Cheers

(Note that I have tried a number of systems to load the images, doesn't make a difference, it's not an issue with Universal Image Loader, which rocks.)


ashishduh, here's the code from getView ... as you see, it's trivial.

(note - setting the size makes no difference. if i try it with say 500.500 fixed, it's the same)

...
v.someTextView.setText(blah);
v.someTextView.setText(blah);

// and now the big image
if (p.containsKey("imageFile"))
    {
    // this cell has a big image

    v.mainImage.setVisibility(View.VISIBLE);
    ParseFile photoFile = p.getParseFile("imageFile");

    // ...using p.getNumber("imageWidth").floatValue(); and height
    // from the cloud, calculate needed width/height on the phone...

    v.mainImage.getLayoutParams().width = Math.round(desiredGlassWidth);
    v.mainImage.getLayoutParams().height = Math.round(desiredGlassHeight);

    ImageLoader imageLoader = ImageLoader.getInstance();
    imageLoader.displayImage( photoFile.getUrl(), v.mainImage );
    }
else
    {
    // this pcell has no big image
    v.mainImageIV.setVisibility(View.GONE);
    }
...

回答1:


For the record for anyone googling here ...

I just tried Picasso ... per the suggestion in the comment (thanks)

Really, it's fantastic. Only Volley would be better.

Picasso works so well, my question about staggering image calls is pointless.

http://square.github.io/picasso/

Hope it helps someone!

Any better answers, post 'em here for points!


PS1 an important point is that Picasso has a "fetch" command, which is a pre-warm. You can use this for even greater results, in some case.

PS2 as I mention above, the plain fact is the only thing better than Picasso, is moving to Volley. Hope it helps someone.



来源:https://stackoverflow.com/questions/24017667/should-i-stagger-a-large-number-of-image-load-calls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!