use of com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool in project LeafPic by HoraApps.
the class CustomGlideModule method applyOptions.
@Override
public void applyOptions(Context context, GlideBuilder builder) {
// Apply options to the builder here.
builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
MemorySizeCalculator calculator = new MemorySizeCalculator(context);
int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
int defaultBitmapPoolSize = calculator.getBitmapPoolSize();
int customMemoryCacheSize = (int) (1.2 * defaultMemoryCacheSize);
int customBitmapPoolSize = (int) (1.2 * defaultBitmapPoolSize);
builder.setMemoryCache(new LruResourceCache(customMemoryCacheSize));
builder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize));
int cacheSize100MegaBytes = 104857600;
builder.setDiskCache(new InternalCacheDiskCacheFactory(context, cacheSize100MegaBytes));
}
use of com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool in project glide by bumptech.
the class BitmapPreFillRunnerTest method allocate_whenBitmapPoolIsAtCapacity_doesNotLogWithRecycledBitmap.
@Test
public void allocate_whenBitmapPoolIsAtCapacity_doesNotLogWithRecycledBitmap() {
ShadowLog.setLoggable(BitmapPreFillRunner.TAG, Log.VERBOSE);
int dimensions = 10;
Bitmap.Config config = Bitmap.Config.ARGB_8888;
int bitmapByteSize = Util.getBitmapByteSize(dimensions, dimensions, config);
PreFillType preFillType = new PreFillType.Builder(dimensions).setConfig(config).build();
Map<PreFillType, Integer> allocationOrder = new HashMap<>();
allocationOrder.put(preFillType, 1);
PreFillQueue queue = new PreFillQueue(allocationOrder);
BitmapPreFillRunner runner = new BitmapPreFillRunner(new LruBitmapPool(bitmapByteSize - 1), new MemoryCacheAdapter(), queue);
runner.allocate();
}
use of com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool in project MVPArms by JessYanCoding.
the class GlideConfiguration method applyOptions.
@Override
public void applyOptions(Context context, GlideBuilder builder) {
builder.setDiskCache(new DiskCache.Factory() {
@Override
public DiskCache build() {
// Careful: the external cache directory doesn't enforce permissions
File cacheDirectory = new File(DataHelper.getCacheFile(UiUtils.getContext()), "Glide");
return DiskLruCacheWrapper.get(DataHelper.makeDirs(cacheDirectory), IMAGE_DISK_CACHE_MAX_SIZE);
}
});
MemorySizeCalculator calculator = new MemorySizeCalculator(context);
int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
int defaultBitmapPoolSize = calculator.getBitmapPoolSize();
int customMemoryCacheSize = (int) (1.2 * defaultMemoryCacheSize);
int customBitmapPoolSize = (int) (1.2 * defaultBitmapPoolSize);
builder.setMemoryCache(new LruResourceCache(customMemoryCacheSize));
builder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize));
}
use of com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool in project glide by bumptech.
the class LoadBitmapTest method loadFromRequestBuilder_asBitmap_withBitmap_doesNotLoadFromDiskCache.
@Test
public void loadFromRequestBuilder_asBitmap_withBitmap_doesNotLoadFromDiskCache() {
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), ResourceIds.raw.canonical);
Glide.init(context, new GlideBuilder().setMemoryCache(new LruResourceCache(Util.getBitmapByteSize(bitmap) * 10)).setBitmapPool(new LruBitmapPool(Util.getBitmapByteSize(bitmap) * 10)));
Target<Bitmap> target = concurrency.wait(GlideApp.with(context).asBitmap().load(bitmap).centerCrop().submit(100, 100));
Glide.with(context).clear(target);
assertThat(bitmap.isRecycled()).isFalse();
concurrency.runOnMainThread(new Runnable() {
@Override
public void run() {
Glide.get(context).clearMemory();
}
});
concurrency.wait(GlideApp.with(context).asBitmap().load(bitmap).centerCrop().listener(bitmapListener).submit(100, 100));
verify(bitmapListener).onResourceReady(anyBitmap(), any(), anyBitmapTarget(), eq(DataSource.LOCAL), anyBoolean());
}
use of com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool in project glide by bumptech.
the class LoadBitmapTest method loadFromRequestBuilder_asBitmap_withBitmapAndStrategyBeforeLoad_notFromCache.
@Test
public void loadFromRequestBuilder_asBitmap_withBitmapAndStrategyBeforeLoad_notFromCache() {
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), ResourceIds.raw.canonical);
Glide.init(context, new GlideBuilder().setMemoryCache(new LruResourceCache(Util.getBitmapByteSize(bitmap) * 10)).setBitmapPool(new LruBitmapPool(Util.getBitmapByteSize(bitmap) * 10)));
Target<Bitmap> target = concurrency.wait(GlideApp.with(context).asBitmap().diskCacheStrategy(DiskCacheStrategy.ALL).load(bitmap).centerCrop().submit(100, 100));
Glide.with(context).clear(target);
assertThat(bitmap.isRecycled()).isFalse();
concurrency.runOnMainThread(new Runnable() {
@Override
public void run() {
Glide.get(context).clearMemory();
}
});
concurrency.wait(GlideApp.with(context).asBitmap().load(bitmap).centerCrop().listener(bitmapListener).submit(100, 100));
verify(bitmapListener).onResourceReady(anyBitmap(), any(), anyBitmapTarget(), eq(DataSource.LOCAL), anyBoolean());
}
Aggregations