use of com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool in project glide by bumptech.
the class GlideBuilder method createGlide.
Glide createGlide(Context context) {
if (sourceExecutor == null) {
sourceExecutor = GlideExecutor.newSourceExecutor();
}
if (diskCacheExecutor == null) {
diskCacheExecutor = GlideExecutor.newDiskCacheExecutor();
}
if (memorySizeCalculator == null) {
memorySizeCalculator = new MemorySizeCalculator.Builder(context).build();
}
if (connectivityMonitorFactory == null) {
connectivityMonitorFactory = new DefaultConnectivityMonitorFactory();
}
if (bitmapPool == null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
int size = memorySizeCalculator.getBitmapPoolSize();
bitmapPool = new LruBitmapPool(size);
} else {
bitmapPool = new BitmapPoolAdapter();
}
}
if (arrayPool == null) {
arrayPool = new LruArrayPool(memorySizeCalculator.getArrayPoolSizeInBytes());
}
if (memoryCache == null) {
memoryCache = new LruResourceCache(memorySizeCalculator.getMemoryCacheSize());
}
if (diskCacheFactory == null) {
diskCacheFactory = new InternalCacheDiskCacheFactory(context);
}
if (engine == null) {
engine = new Engine(memoryCache, diskCacheFactory, diskCacheExecutor, sourceExecutor, GlideExecutor.newUnlimitedSourceExecutor());
}
return new Glide(context, engine, memoryCache, bitmapPool, arrayPool, connectivityMonitorFactory, logLevel, defaultRequestOptions.lock());
}
use of com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool in project glide by bumptech.
the class GlideContextTest method setUp.
@Before
public void setUp() {
Application app = RuntimeEnvironment.application;
transitionOptions = new HashMap<>();
context = new GlideContext(app, new LruArrayPool(), new Registry(), new ImageViewTargetFactory(), new RequestOptions(), transitionOptions, mock(Engine.class), Log.DEBUG);
}
use of com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool in project glide by bumptech.
the class ByteBufferGifDecoderTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
gifHeader = Mockito.spy(new GifHeader());
when(parser.parseHeader()).thenReturn(gifHeader);
when(parserPool.obtain(isA(ByteBuffer.class))).thenReturn(parser);
when(decoderFactory.build(isA(GifDecoder.BitmapProvider.class), eq(gifHeader), isA(ByteBuffer.class), anyInt())).thenReturn(gifDecoder);
List<ImageHeaderParser> parsers = new ArrayList<>();
parsers.add(new DefaultImageHeaderParser());
options = new Options();
decoder = new ByteBufferGifDecoder(RuntimeEnvironment.application, parsers, bitmapPool, new LruArrayPool(ARRAY_POOL_SIZE_BYTES), parserPool, decoderFactory);
}
use of com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool in project glide by bumptech.
the class DownsamplerEmulatorTest method buildDownsampler.
private static Downsampler buildDownsampler() {
List<ImageHeaderParser> parsers = Collections.<ImageHeaderParser>singletonList(new DefaultImageHeaderParser());
DisplayMetrics displayMetrics = new DisplayMetrics();
// XHDPI.
displayMetrics.densityDpi = 320;
BitmapPool bitmapPool = new BitmapPoolAdapter();
ArrayPool arrayPool = new LruArrayPool();
return new Downsampler(parsers, displayMetrics, bitmapPool, arrayPool);
}
use of com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool in project glide by bumptech.
the class ResourceCacheKeyTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
arrayPool = new LruArrayPool();
doAnswer(new Util.WriteDigest("transformation1")).when(transformation1).updateDiskCacheKey(any(MessageDigest.class));
doAnswer(new Util.WriteDigest("transformation1")).when(transformation2).updateDiskCacheKey(any(MessageDigest.class));
}
Aggregations