AndBase开发框架  1.5.8r3
 全部  命名空间 文件 函数 变量 枚举值 
静态 Public 成员函数 | 静态 Public 属性 | 静态 Private 属性 | 所有成员列表
com.ab.bitmap.AbImageCache类 参考

静态 Public 成员函数

static Bitmap getBitmapFromCache (String key)
 
static void addBitmapToCache (String key, Bitmap bitmap)
 
static void removeBitmapFromCache (String key)
 
static void removeAllBitmapFromCache ()
 
static String getCacheKey (String url, int width, int height, int type)
 
static Runnable getRunRunnableFromCache (String key)
 
static void addToRunRunnableCache (String key, Runnable runnable)
 
static void removeRunRunnableFromCache (String key)
 
static Runnable getWaitRunnableFromCache (String key)
 
static void addToWaitRunnableCache (String key, Runnable runnable)
 
static void removeWaitRunnableFromCache (String key)
 

静态 Public 属性

static int cacheSize = 8 * 1024 * 1024
 
static final ReentrantLock lock = new ReentrantLock()
 

静态 Private 属性

static final LruCache< String,
Bitmap > 
bitmapCache
 
static final HashMap< String,
Runnable > 
runRunnableCache = new HashMap<String, Runnable>()
 
static final List< HashMap
< String, Runnable > > 
waitRunnableList = new ArrayList<HashMap<String, Runnable>>()
 

详细描述

© 2012 amsoft.cn 名称:AbImageCache.java 描述:图片缓存.

作者
还如一梦中
版本
v1.0
日期
:2013-5-23 上午10:10:53

成员函数说明

static void com.ab.bitmap.AbImageCache.addBitmapToCache ( String  key,
Bitmap  bitmap 
)
inlinestatic

描述:增加一个图片到缓存.

参数
key通过url计算的缓存key
bitmapthe bitmap
static void com.ab.bitmap.AbImageCache.addToRunRunnableCache ( String  key,
Runnable  runnable 
)
inlinestatic

描述:增加一个正在执行线程的记录.

参数
key通过url计算的缓存key
runnablethe runnable
static void com.ab.bitmap.AbImageCache.addToWaitRunnableCache ( String  key,
Runnable  runnable 
)
inlinestatic

描述:增加一个等待线程的记录.

参数
key通过url计算的缓存key
runnablethe runnable
static Bitmap com.ab.bitmap.AbImageCache.getBitmapFromCache ( String  key)
inlinestatic

描述:从缓存中获取这个Bitmap.

参数
keythe key
返回
the bitmap from mem cache
static String com.ab.bitmap.AbImageCache.getCacheKey ( String  url,
int  width,
int  height,
int  type 
)
inlinestatic

根据url计算缓存key,这个key+后缀就是文件名.

参数
url图片地址.
width图片宽度.
height图片高度.
type处理类型.
返回
the cache key
static Runnable com.ab.bitmap.AbImageCache.getRunRunnableFromCache ( String  key)
inlinestatic

描述:从缓存中获取这个正在执行线程.

参数
keythe key
返回
the runnable
static Runnable com.ab.bitmap.AbImageCache.getWaitRunnableFromCache ( String  key)
inlinestatic

描述:从缓存中获取这个正在等待线程.

参数
keythe key
返回
the runnable
static void com.ab.bitmap.AbImageCache.removeAllBitmapFromCache ( )
inlinestatic

描述:清空缓存的Bitmap.

static void com.ab.bitmap.AbImageCache.removeBitmapFromCache ( String  key)
inlinestatic

描述:从缓存删除.

参数
key通过url计算的缓存key
static void com.ab.bitmap.AbImageCache.removeRunRunnableFromCache ( String  key)
inlinestatic

描述:从缓存一个正在执行的线程.

参数
key通过url计算的缓存key
static void com.ab.bitmap.AbImageCache.removeWaitRunnableFromCache ( String  key)
inlinestatic

描述:从缓存删除一个等待线程.

参数
key通过url计算的缓存key

类成员变量说明

final LruCache<String, Bitmap> com.ab.bitmap.AbImageCache.bitmapCache
staticprivate
初始值:
= new LruCache<String, Bitmap>(cacheSize) {
protected int sizeOf(String key, Bitmap bitmap) {
return bitmap.getRowBytes() * bitmap.getHeight();
}
@Override
protected void entryRemoved(boolean evicted, String key,
Bitmap oldValue, Bitmap newValue) {
AbLogUtil.d(AbImageCache.class, "LruCache:移除了"+key);
}
}

为了加快速度,在内存中开启缓存,最新的LruCache.

int com.ab.bitmap.AbImageCache.cacheSize = 8 * 1024 * 1024
static

缓存空间大小8MB.

final ReentrantLock com.ab.bitmap.AbImageCache.lock = new ReentrantLock()
static

锁对象.

final HashMap<String, Runnable> com.ab.bitmap.AbImageCache.runRunnableCache = new HashMap<String, Runnable>()
staticprivate

正在下载中的线程.

final List<HashMap<String, Runnable> > com.ab.bitmap.AbImageCache.waitRunnableList = new ArrayList<HashMap<String, Runnable>>()
staticprivate

等待中的线程.


该类的文档由以下文件生成: