我应该错开了大量的图像加载电话? [英] Should I stagger a large number of image load calls?

查看:112
本文介绍了我应该错开了大量的图像加载电话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有〜100大图像的ListView控件。每幅图像约为640.640 JPG和显示1/2的屏幕尺寸。典型的画廊。

我现在用的是美妙的当前加载图像的通用图像装载-1.9.2。

  ParseFile photoFile = p.getParseFile(镜像文件);
ImageLoader的ImageLoader的= ImageLoader.getInstance();
imageLoader.displayImage(photoFile.getUrl(),theImageView);
 

现在,你有点口吃上的ListView,当他们被加载。

现在,巧合的是,我的手机一个非常缓慢的WiFi网络上。事实上,它是柔滑如丝。

起初,我不能工作了,为什么突然改善!情缘!

其实然后,在这种情况下:是否值得错开调用加载图像

所以,我可以离开0.1每次调用之间,例如。

或者实在的,我应该只是做他们一个跟随其他可能?!

这是怎么回事呢? 是不是所有的Andr​​oid工程师做这一切的时候?干杯!

我已经应用了所有其它传统的技术我用Google搜索了的黄油流畅的ListView滚动。干杯

(请注意,我已经尝试了许多系统加载图像,并没有发挥作用,这不是一个问题,通用图像装载机,其中岩石。)


ashishduh,这里是由getView的code ......你看,这是微不足道的。

(注意 - 设置大小没有什么区别,如果我尝试它说500.500固定的,它是相同的。)

  ...
v.someTextView.setText(等等);
v.someTextView.setText(等等);

//现在的大图
如果(p.containsKey(镜像文件))
    {
    //这个单元有一个大的图像

    v.mainImage.setVisibility(View.VISIBLE);
    ParseFile photoFile = p.getParseFile(镜像文件);

    // ...使用p.getNumber(ImageWidth等)的floatValue();和高度
    //从云计算在手机上所需的宽/高...

    。v.mainImage.getLayoutParams()宽度= Math.round(desiredGlassWidth);
    。v.mainImage.getLayoutParams()高度= Math.round(desiredGlassHeight);

    ImageLoader的ImageLoader的= ImageLoader.getInstance();
    imageLoader.displayImage(photoFile.getUrl(),v.mainImage);
    }
其他
    {
    //这个PCELL没有大图
    v.mainImageIV.setVisibility(View.GONE);
    }
...
 

解决方案

有关记录的人使用Google这里...

我只是想毕加索 ...每个注释中的建议(感谢)

说真的,这真是太棒了。只有凌空效果会更好。

毕加索的作品这么好,我的问题有关惊人的形象要求是没有意义的。

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

希望它可以帮助别人!

任何更好的答案,张贴'时间在这里点!


PS1的一个重要的一点是,毕加索有一个获取命令,这是一个$ P $对 - 温暖。您可以使用此为更大的成果,在某些情况下。

我上面提到的PS2,显而易见的事实是,唯一比毕加索好,正在向排球。希望它可以帮助别人。

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);
    }
...

解决方案

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.

这篇关于我应该错开了大量的图像加载电话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆