How to retrieve images from cache memory in picasso?

后端 未结 2 1596
盖世英雄少女心
盖世英雄少女心 2020-12-10 18:18

I am using picasso library for loading images .In default picasso, It uses internal cache memory for loading images.But as per my app configuration ,i have to use external c

相关标签:
2条回答
  • 2020-12-10 18:27

    You can supply your own Cache implementation when building your Picasso instance. This way you can provide extra methods that you can call to retrieve bitmaps directly from your memory cache. Use Picasso.Builder to provide your own implementation for it. When you use with() you are using a static singleton internal instance thats setup with most of the default values (most apps need the default values anyway.)

    Keep a reference of your Cache implementation around and directly interact with it. Picasso is meant to handle the loading/decoding and caching for you but there is no reason you cant build around it.

    If you are referring about the disk cache, then no Picasso does not support that at the moment. This is by design because the disk layer cache is done by the HTTP layer and makes no distinction about it.

    You could however, change the path of the disk cache. If you are using OkHttpDownloader then supply a different file when you construct your Downloader. Similarly for UrlConnectionDownloader you could extend it and override the load() method.

    0 讨论(0)
  • 2020-12-10 18:52

    Picasso does handle the caching in it and downloading also you just need to place it in your target Image view similar to Aquery

    According to The Corner Square Engineering blog picasso handle downloading caching in it self and give its handler to user to use it and place the image in image view

    0 讨论(0)
提交回复
热议问题