如何在毕加索检索缓存的图片? [英] How to retrieve images from cache memory in picasso?

查看:152
本文介绍了如何在毕加索检索缓存的图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的毕加索库加载图像。在默认情况下毕加索,它采用内部缓存加载images.But按我的应用程序的配置,我必须使用外部高速缓存存储器(高速缓存磁盘上)。 所以我用这个$ C $下高速缓存的磁盘

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 cache memory(Cache on Disk). so i used this code for Cache on Disk

              File httpCacheDir = new File(getApplicationContext().getExternalCacheDir(),"http");
                long httpCacheSize = 10 * 1024 * 1024; // 10 MiB
               HttpResponseCache.install(httpCacheDir, httpCacheSize);}

毕加索是灵活的。所以,现在它缓存图像外置SD卡。

Picasso is flexible. So now it caches images in external Sd card..

缓存存储在SD卡/安卓/数据/包名称/缓存/ HTTP  缓存存储在0.1,0。格式 所以我只是把包裹打开并变成.1到.JPG。它提供了精确的图像我需要什么。 但如何做编程?但毕加索本身缓存我的记忆在我的应用程序加载图像到imageview.but我必须将它们保存到SD卡直接作为图像/位图设置为墙纸在离线模式?

The caches is stored in sdcard/android/data/packagename/cache/http The caches are stored in ".1" ,".0". formats so i just opened them and changes into ".1" to ".jpg".it gives exact images what i need. But how to do in programatically? but picasso itself caches my memory in to my app for loading image into imageview.but i have to save them into sdcard directly as images/set bitmap as wallpaper in offline mode?

推荐答案

您可以建立时提供自己的缓存实现你的毕加索实例。这样,您就可以提供您可以打电话直接从内存中缓存中检索位图额外的方法。使用 Picasso.Builder 来提供自己的实现它。当您使用与()您使用的是静态单内部实例,多数民众赞成设置与大多数的默认值(大多数应用程序需要的缺省值反正。)

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.

如果你是指对磁盘缓存,那么没有毕加索不支持的时刻。这是由设计,因为磁盘层缓存由HTTP层完成,是没有区别了。

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.

您可以但是,更改磁盘缓存的路径。如果您使用的是OkHttpDownloader然后提供当你建立你下载一个不同的文件。同样,对于UrlConnectionDownloader,你可以扩展它,并覆盖负载()方法。

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.

这篇关于如何在毕加索检索缓存的图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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