当前位置: 首页>>代码示例>>Java>>正文


Java LruCache.put方法代码示例

本文整理汇总了Java中android.support.v4.util.LruCache.put方法的典型用法代码示例。如果您正苦于以下问题:Java LruCache.put方法的具体用法?Java LruCache.put怎么用?Java LruCache.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.util.LruCache的用法示例。


在下文中一共展示了LruCache.put方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: insertIntoCache

import android.support.v4.util.LruCache; //导入方法依赖的package包/类
private void insertIntoCache() {
    synchronized (mCache) {
        LruCache<String, CollectionDAO> cache = mCache.get(collectionName);
        if (cache == null) {
            cache = new LruCache<>(50);
            mCache.put(collectionName, cache);
        }
        cache.put(documentID, this);
    }
}
 
开发者ID:lukamarin,项目名称:Rocket.Chat-android,代码行数:11,代码来源:CollectionDAO.java

示例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;
}
 
开发者ID:JSafaiyeh,项目名称:Fabric-Example-App-Android,代码行数:38,代码来源:Networking.java

示例3: testWeakDeletion

import android.support.v4.util.LruCache; //导入方法依赖的package包/类
@Test
public void testWeakDeletion() {
    final LruCache<String, String> cache = new WeakLruCache<>(1);

    // create Strings this way to prevent usage of intern table
    String val1 = new String(VALUE1);
    String val2 = new String(VALUE2);

    // populate the cache
    cache.put(KEY1, val1);
    assertEquals(1, cache.size());
    cache.put(KEY2, val2);
    assertEquals(1, cache.size());

    // controlled gc to make sure errors don't hide behind unscheduled GC's
    forceGc();

    // make sure both are still accessible
    assertEquals(VALUE1, cache.get(KEY1));
    assertEquals(VALUE2, cache.get(KEY2));

    // wipe local copy and force GC
    val1 = null;
    val2 = null;
    forceGc();

    // val1 should be missing now
    assertNull(cache.get(KEY1));
    assertNotEquals(VALUE1, cache.get(KEY1));
    assertEquals(VALUE2, cache.get(KEY2));
}
 
开发者ID:CruGlobal,项目名称:android-gto-support,代码行数:32,代码来源:WeakLruCacheTest.java

示例4: doSaveOrUpdate

import android.support.v4.util.LruCache; //导入方法依赖的package包/类
private <T extends AbstractStorage> void doSaveOrUpdate(T t)
{
    Class tClass = t.getClass();
    LruCache<Serializable, T> cache = getFastLRUCache(tClass);
    cache.put(t.getId(), t);
}
 
开发者ID:ZhuoKeTeam,项目名称:AndroidJsoup,代码行数:7,代码来源:StorageService.java

示例5: saveBitmapToMemory

import android.support.v4.util.LruCache; //导入方法依赖的package包/类
/**
 * put bitmap into LruCache
 *
 * @param bitmap
 */
protected void saveBitmapToMemory(Bitmap bitmap) {
    Log.d("LruImage", "saveBitmapToMemory");
    LruCache<String, Bitmap> lruCache = getLruCache();
    lruCache.put(getKey(), bitmap);
}
 
开发者ID:douo,项目名称:lru-image,代码行数:11,代码来源:LruImage.java


注:本文中的android.support.v4.util.LruCache.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。