Search in sources :

Example 1 with Factory

use of com.bumptech.glide.load.engine.cache.DiskCache.Factory in project glide by bumptech.

the class ExternallyClearedDiskCacheTest method loadFromCache_afterDiskCacheDeleted_doesNotFail.

@Test
public void loadFromCache_afterDiskCacheDeleted_doesNotFail() {
    final DiskCache cache = DiskLruCacheWrapper.create(cacheDir, 1024 * 1024);
    cache.get(mock(Key.class));
    deleteRecursively(cacheDir);
    Glide.init(context, new GlideBuilder().setDiskCache(new Factory() {

        @Override
        public DiskCache build() {
            return cache;
        }
    }));
    Drawable drawable = concurrency.get(Glide.with(context).load(raw.canonical).submit());
    assertThat(drawable).isNotNull();
}
Also used : Drawable(android.graphics.drawable.Drawable) Factory(com.bumptech.glide.load.engine.cache.DiskCache.Factory) DiskCache(com.bumptech.glide.load.engine.cache.DiskCache) Key(com.bumptech.glide.load.Key) Test(org.junit.Test)

Example 2 with Factory

use of com.bumptech.glide.load.engine.cache.DiskCache.Factory in project glide by bumptech.

the class ExternallyClearedDiskCacheTest method loadFromCache_afterDiskCacheDeletedAndCleared_doesNotFail.

@Test
public void loadFromCache_afterDiskCacheDeletedAndCleared_doesNotFail() {
    final DiskCache cache = DiskLruCacheWrapper.create(cacheDir, 1024 * 1024);
    cache.get(mock(Key.class));
    deleteRecursively(cacheDir);
    cache.clear();
    Glide.init(context, new GlideBuilder().setDiskCache(new Factory() {

        @Override
        public DiskCache build() {
            return cache;
        }
    }));
    Drawable drawable = concurrency.get(Glide.with(context).load(ResourceIds.raw.canonical).submit());
    assertThat(drawable).isNotNull();
}
Also used : Drawable(android.graphics.drawable.Drawable) Factory(com.bumptech.glide.load.engine.cache.DiskCache.Factory) DiskCache(com.bumptech.glide.load.engine.cache.DiskCache) Key(com.bumptech.glide.load.Key) Test(org.junit.Test)

Aggregations

Drawable (android.graphics.drawable.Drawable)2 Key (com.bumptech.glide.load.Key)2 DiskCache (com.bumptech.glide.load.engine.cache.DiskCache)2 Factory (com.bumptech.glide.load.engine.cache.DiskCache.Factory)2 Test (org.junit.Test)2