1、Android-Universal-Image-Loader
可以高度配置的网络图片缓存库,非常灵活,用户量最多
缓存过期实现:
File cacheDir = StorageUtils.getCacheDirectory(context); // or any other folder
MemoryCacheAware<String, Bitmap> memoryCacheCore
= new LruMemoryCache(4 * 1024 * 1024); // or any other implementation
MemoryCacheAware<String, Bitmap> memoryCache
= new LimitedAgeMemoryCache<String, Bitmap>(memoryCacheCore, 15 * 60);
DiscCacheAware discCache = new LimitedAgeDiscCache(cacheDir, 15 * 60);
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
.memoryCache(memoryCache)
.discCache(discCache)
...
.build();
If you use "limited age" memory cache or disc cache then bitmap or image file will be deleted from cache after timeout (actually they will be deleted during search in cache). Logic is following:
- Search bitmap in memory cache
- needed bitmap is there
- bitmap was added to cache more than specified time ago
- delete it from memory cache, go to step 2
- bitmap was added to cache recently
- get the bitmap, display it. End.
- no needed bitmap in cache, go to step 2
- Search image file in disc cache
- needed image is there
- image was added to cache more than specified time ago
- delete it from disc cache, go to step 3
- image was added to cache recently
- decode image to bitmap, display it. End.
- no needed image in cache, go to step 3
- Download image
Don't forget enable caching (in display options, DisplayImageOptions
).
针对同一图片地址,图片会变的情况,平滑替换过期图片的实现:
方法1:重写LimitedAgeDiscCache、LimitedAgeMemoryCache的get方法
方法2:增加判断缓存是否过期的接口,如果过期则通过下载回调监听的方式更新UI。
2、androidQuery
链式调用,有自定义图片载入效果
3、Picasso
功能单一,没有缓存过期,同androidQuery一样链式调用,载入本地文件速度慢(没有生成thumbnails)。这有一篇老外的对比:http://stackoverflow.com/questions/19995007/local-image-caching-solution-for-android-square-picasso-vs-universal-image-load
4、android-smart-image-view
古董了,功能老掉牙了,不要用了
分享到:
相关推荐
实现Android中WebView图片的缓存,并且实现如何替换WebView中默认图片以及如何实现图片的点击。
一个和图片缓存有关的小项目,就可以当作学习资料来是使用,在学习一下android图pain缓存的原理
安卓源码包android图片缓存&展示Android 异步加载图片等24个合集: ‘360全景查看demo.rar afinal框架实现图片的简单异步缓存加载.rar andengine中直接加载多张小图片合成一张大图片生成动画精灵.rar android gif...
Android应用源码之Android 图片缓存、加载器.zip
Universal ImageLoader是最早开源的 Android 图片缓存库, 强大的缓存机制。功能特点:支持多线程加载图片(同步或者异步加载)具有很高的定制性每一张图片都有很多备用资源(原始图片、内存缓存、Bitmap等 )图片能...
Android中非常好图片缓存ImageCache,是国外的大牛写的,比较完整系统,但是本人认为也有几个缺点,比如获取磁盘缓存目录的方法,不过,总体非常还是很好的,基本满足各种场景,希望对你有所帮助!
Android 图片缓存 利用软硬引用,进行三级缓存。
利用现有的开源的图片缓存框架实现的图片缓存下载,测试程序在TestLoadImage中
用于图片缓存的很好的demo,值得大家研究学习,有什么想法的可以给留言讨论
一个Android图像加载和缓存库专注于流畅体验
Android开发中实现图片缓存机制,可以直接导入eclipse后到处jar使用。
android 图片缓存处理,希望可以帮到大家
NULL 博文链接:https://zhelong111.iteye.com/blog/2228870
Android图片缓存算法的代码例子。用于演示几种图片缓存框架的原理与使用,包括自定义的ImageCache、Picasso、ImageLoader等等。
Android Universal Image Loader master 图片缓存 ,这个很好用,源码和事例都有
Android使用LruCache缓存图片,
在android中,获取网络图片进行缓存是必须的,但是如果你的缓存策略不够好的话就会内存溢出,今天我总结一下我自己的看法,并做了demo。用到了线程池来控制线程,根据你手机的cpu的个数来确定你线程池中线程数的大小...
用于android 图片的缓存,策略:cache中检索,有则display,无则下载之,存入cache,display,真的拿不到图片则显示设定的默认图(主题建议为找不到图片),功能尚在完善中,暂不开放源代码。我的博客:...
Android技术积累 图片缓存管理 ,适用于android特性
通过网络获取图片,并缓存到本地,适合初学者,代码里面标有注释,listView = (ListView) findViewById(R.id.listview); listView.setAdapter(new CacheAdapter(this));