首页 > 系统服务 > 详细

BitmapCache

时间:2014-11-24 19:07:32      阅读:374      评论:0      收藏:0      [点我收藏+]
package com.zcs.fast.forward.utils;

import android.graphics.Bitmap;
import android.support.v4.util.LruCache;

import com.android.volley.toolbox.ImageLoader.ImageCache;

public class BitmapCache implements ImageCache {
	private static LruCache<String, Bitmap> mCache;

	public BitmapCache() {
		if (mCache == null) {
			LogUtil.i(VolleyUtil.TAG, "***Init The BitmapCache");
			int maxSize = 10 * 1024 * 1024;
			mCache = new LruCache<String, Bitmap>(maxSize) {
				@Override
				protected int sizeOf(String key, Bitmap value) {
					return value.getRowBytes() * value.getHeight();
				}
			};
		}
	}

	@Override
	public Bitmap getBitmap(String url) {
		return mCache.get(url);
	}

	@Override
	public void putBitmap(String url, Bitmap bitmap) {
		mCache.put(url, bitmap);
		LogUtil.i(VolleyUtil.TAG, "put:BitmapCache size:" + mCache.size());
	}

}

  

BitmapCache

原文:http://www.cnblogs.com/ZengCS/p/4119283.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!