我正在使用 ViewPager 构建画廊。每次下载照片时,我都会立即将其缓存在mMemoryCache
其中
mMemoryCache = new LruCache<Integer, Bitmap>(cacheSize) {
@Override
protected int sizeOf(Integer key, Bitmap bitmap) {
// The cache size will be measured in bytes rather than number
// of items.
return (bitmap.getRowBytes() * bitmap.getHeight());
}
};
如您所见sizeOf()
,如果使用了字节,则返回数字,这是有道理的。我的问题是我的 ViewPager 的适配器需要知道我有多少页,这将是我的缓存中的对象数。
关于我该怎么做的任何想法?谢谢!