对于Android本地图像缓存解决方案:广场毕加索VS通用图像装载机 [英] Local image caching solution for Android: Square Picasso vs Universal Image Loader

查看:133
本文介绍了对于Android本地图像缓存解决方案:广场毕加索VS通用图像装载机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要异步图像加载和缓存中的Andr​​oid。任何人都知道这两个库?我打算用毕加索,但我发现通用图像装载机是在Github上更受欢迎。优点和缺点的摘要将是巨大的。

I need async image loading and caching in Android. Anyone knows about these two libraries? I was going to use Picasso, but I found Universal Image Loader is more popular on Github. A summary of pros and cons would be great.

(我的所有图像都在本地磁盘,所以我不需要联网,我不认为排球是一个合适的)

(All my images are on disk locally, so I don't need networking, I don't think Volley is a fit)

推荐答案

Koushik杜塔的比较,主要是为速度基准。他的文章只有感动很基本的东西,而不是特定的本地图片。我想与大家分享我的经验与毕加索和UIL后,我问的问题。无论毕加索和UIL可以加载本地图片。我第一次尝试毕加索和很高兴,但后来我决定改用UIL更多的自定义选项。

Koushik Dutta's comparison is mostly for speed benchmark. His post only touched very basic things, and is not specific for local images. I'd like to share my experiences with Picasso and UIL after I asked the question. Both Picasso and UIL can load local images. I first tried Picasso and was happy, but later I decided to switch to UIL for more customization options.

毕加索:

  • 毕加索流畅的界面是很好的。但随着与跳来跳去,进入,负荷你居然不知道什么是幕后。它混淆了什么回来了。

  • Picasso's fluent interface is nice. But jumping around with "with", "into", "load" you actually don't know what's behind the scene. It's confusing what's returned.

毕加索允许您指定确切的目标大小。当你有内存pressure或性能问题,这是非常有用,你可以交易掉一些对速度的图像质量。

Picasso allows you to specify exact target size. It's useful when you have memory pressure or performance issues, you can trade off some image quality for speed.

图像缓存,在主要的大小,当你与不同大小显示图像是非常有用的。

Images are cached with size in its key, it's useful when you display images with different sizes.

您可以自定义的内存缓存大小。但它的盘缓存只有HTTP请求。对于本地的图像,如果你关心的加载速度,这是很好的有一个缩略图磁盘高速缓存,这样你就不用看了一些MBS,用于对图像每次。毕加索不具有此机制调整大小和保存缩​​略图在磁盘上。

You can customize the memory cache size. But its disc cache is only for http requests. For local images, if you care about loading speed, it's good to have a thumbnail disk cache so you don't have to read several MBs for an image every time. Picasso does not have this mechanism resizing and saving thumbnails on disk.

毕加索不公开访问其缓存实例。 (你可以得到一个抓住它,当你第一次配置毕加索,并保持它周围...)。

Picasso does not expose the access to its cache instance. (You can get a hold of it when you first configure Picasso and keep it around...).

有时候你想异步读取图像转换成由听众返回的位图。令人惊讶的毕加索不具有。 取()剂量不传回任何东西。 获得()是同步读取,和load()的是异步画一个图。

Sometimes you want to asynchronously read image into a bitmap returned by a listener. Surprisingly Picasso doesn't have that. "fetch()" dose not pass back anything. "get()" is for synchronously read, and "load()" is for asynchronously draw a view.

毕加索只有在主页上几个简单的例子,你就必须通读的javadoc无序的高级用法。

Picasso only has a few simple examples on the homepage, and you'll have to read through the unordered javadoc for advanced usages.

UIL:

  • UIL使用制造商进行定制。几乎一切都可以配置。

  • UIL uses builders for customization. Almost everything can be configured.

UIL不允许您指定要装载到一个视图中的大小。它使用基于视图的大小一些规则。它的灵活性不如毕加索。我没有办法来加载一个较低分辨率的图像,以减少内存占用。 (编辑:这种行为可以很容易地通过在源$ C ​​$ C添加IMAGESIZE参数修改并绕过视图大小检查)

UIL does not allow you to specify the size you want to load into a view. It uses some rules based on the size of the view. It's not as flexible as Picasso. I have no way to load a lower resolution image to reduce memory footprint. ( this behavior can be easily modified by adding an ImageSize argument in in the source code and bypass the view size checking)

UIL提供可定制的盘缓存,你可以用它来缓存缩略图指定的大小。但它并不是完美的。下面是<一href="http://stackoverflow.com/questions/21961505/android-universal-image-loader-by-pass-disc-memory-cache-check-when-loading-an">details. (编辑:如果你关心速度,想多层次的缩略图缓存,像我的情况下,可以修改源$ C ​​$ C,让磁盘缓存使用memoryKey,并使其也大小敏感)

UIL provides customizable disc cache, you can use this to cache the thumbnails with specified size. But it's not perfect. Here are the details. ( if you care about speed and want multiple levels of thumbnail caching, like my case, you can modify the source code, let the disk cache use "memoryKey", and make it also size sensitive)

由不同尺寸的存储器默认缓存图像UIL,并且它可以在配置被关闭。

UIL by default caches images of different sizes in memory, and it can be turned off in configuration.

UIL公开,您可以访问的支持的内存和磁盘高速缓存。

UIL exposes the backing memory and disk cache you can access.

UIL提供了灵活的方式,你可以得到一个位图或加载到视图。

UIL provides flexible ways you can get a bitmap or load to a view.

UIL是文档更好。 UIL给出了Github上页的详细用法,并有一个链接教程。

UIL is better in documentation. UIL gives the detailed usages on the Github page, and there's a linked tutorial.

我建议开始与毕加索,如果你需要更多的控制和定制,去UIL。

I suggest starting with Picasso, if you need more control and customization, go for UIL.

这篇关于对于Android本地图像缓存解决方案:广场毕加索VS通用图像装载机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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