Is there a way get the progress of the queued downloads in Picasso?

倾然丶 夕夏残阳落幕 提交于 2019-12-08 10:45:01

问题


I'm developing an app which should be able to pre-download all images used from within the dataset so that the app can function fully offline.

It should download about 600 images of each 500KB (~300 MB in total).

For this I'd want to loop through all url's and execute Picasso fetch() method. This will fetch all images, which is great.

The only thing I'm missing is a way to see what the progress is of all the image downloads. Is there any way to see the progress of the download queue of Picasso? This way I can notify the user when the downloads are done, and inform what the current status is.

What I've found so far:

  • I can use a Target to load the image into. Only this will also decode to an Bitmap, which is not yet required and takes too much resources.
  • I can somehow read the cache folder to check the progress. But I think this is not a clean way...

回答1:


First of all, you should not preload all images. If you are using Picasso or Universal Image Loader than both of them are caching your images. In that way you are sure (or almost) about OutOfMemoryException.

But if you really want to do this, check Universal Image Loader loadImage(String uri, ImageLoadingListener listener)

https://github.com/nostra13/Android-Universal-Image-Loader

imageLoader.loadImage(imageUri, new SimpleImageLoadingListener() {
    @Override
    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
       // Do whatever you want with Bitmap
     }
});


来源:https://stackoverflow.com/questions/26425549/is-there-a-way-get-the-progress-of-the-queued-downloads-in-picasso

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