本文整理匯總了Java中android.support.v4.util.LruCache.get方法的典型用法代碼示例。如果您正苦於以下問題:Java LruCache.get方法的具體用法?Java LruCache.get怎麽用?Java LruCache.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.util.LruCache
的用法示例。
在下文中一共展示了LruCache.get方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: query
import android.support.v4.util.LruCache; //導入方法依賴的package包/類
public static CollectionDAO query(String collectionName, String documentID) {
CollectionDAO dao = null;
LruCache<String, CollectionDAO> cache = mCache.get(collectionName);
if (cache != null) {
dao = cache.get(documentID);
if (dao != null) {
return dao;
}
}
Cursor cursor = DBManager.getInstance().query(TABLE_NAME, null, COLUMN_COLLECTION_NAME + "=? AND " + COLUMN_DOCUMENT_ID + "=?", new String[]{collectionName, documentID});
if (cursor != null) {
if (cursor.getCount() > 0) {
cursor.moveToFirst();
do {
dao = new CollectionDAO(cursor);
} while (cursor.moveToNext());
}
cursor.close();
}
return dao;
}
示例2: getImageLoader
import android.support.v4.util.LruCache; //導入方法依賴的package包/類
@NonNull
public static ImageLoader getImageLoader(@NonNull Context context) {
MaxWidthImageLoader imageLoader = sMaxWidthImageLoader;
// Double-check locking to initialize.
if (imageLoader == null) {
synchronized (Networking.class) {
imageLoader = sMaxWidthImageLoader;
if (imageLoader == null) {
RequestQueue queue = getRequestQueue(context);
int cacheSize = DeviceUtils.memoryCacheSizeBytes(context);
final LruCache<String, Bitmap> imageCache = new LruCache<String, Bitmap>(cacheSize) {
@Override
protected int sizeOf(String key, Bitmap value) {
if (value != null) {
return value.getRowBytes() * value.getHeight();
}
return super.sizeOf(key, value);
}
};
imageLoader = new MaxWidthImageLoader(queue, context, new MaxWidthImageLoader.ImageCache() {
@Override
public Bitmap getBitmap(final String key) {
return imageCache.get(key);
}
@Override
public void putBitmap(final String key, final Bitmap bitmap) {
imageCache.put(key, bitmap);
}
});
sMaxWidthImageLoader = imageLoader;
}
}
}
return imageLoader;
}
示例3: getBitmapFromMemory
import android.support.v4.util.LruCache; //導入方法依賴的package包/類
protected Bitmap getBitmapFromMemory(String key) {
LruCache<String, Bitmap> lruCache = getLruCache();
return lruCache.get(key);
}