How to make Picasso load images faster?

2020-08-02 01:56发布

I use Picasso (image downloading library for Android). Picasso website

I charge my image like this:

Picasso.get().load("http://i.imgur.com/myImage.png").into(imageView);

But, if myImage.png is too big, the download become slow. (With bad internet connection of course)

How to make Picasso load images faster?

Can I just make the quality lower by Picasso? Or can I charge them "early" a few seconds before using them?

Note that I cannot touch the file myImage.png

---------------------

EDIT

Any idea how to charge an image "early"? Should I use invisible view and load image into it, then use the same image in my View? How to add an image to cash (By Picasso always)?

4条回答
爷、活的狠高调
2楼-- · 2020-08-02 02:21

Picasso has no control over the server fulfilling the network request or the internet connection itself. Using a service like Thumbor might help: https://github.com/thumbor/thumbor

查看更多
3楼-- · 2020-08-02 02:21

You could try to add this to your android manifest

<application android:hardwareAccelerated="true" ...>

i use this to load videos faster, and it works for me ;) Maybe it'll also work for you

查看更多
劫难
4楼-- · 2020-08-02 02:22

Picasso optimize the image automatically loading a smaller version of the image into the ImageView, but if the source image is "big", the load will become slow so i recommend to you optimize the source images.

Check this articles:

Image Optimization

Automating Image Optimization

查看更多
等我变得足够好
5楼-- · 2020-08-02 02:28

No, Picasso loads a smaller version of that image into the view to use less memory, However it has to download the full source image before hand.

Consider uploading smaller images to have shorter download time, You may use multiple versions of your image:

image_thumbnail.png
image_small.png
image_medium.png
image_orginal.png

Download the thumbnail first and then download the small image, Use the bigger images for bigger views.

Yes it is possible to download them "early" but it's not recommend to waste the precious battery and bandwidth on mobile phones.

查看更多
登录 后发表回答