Search in sources :

Example 1 with LruResourceCache

use of com.bumptech.glide.load.engine.cache.LruResourceCache 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());
}
Also used : LruArrayPool(com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool) DefaultConnectivityMonitorFactory(com.bumptech.glide.manager.DefaultConnectivityMonitorFactory) LruBitmapPool(com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool) LruResourceCache(com.bumptech.glide.load.engine.cache.LruResourceCache) BitmapPoolAdapter(com.bumptech.glide.load.engine.bitmap_recycle.BitmapPoolAdapter) InternalCacheDiskCacheFactory(com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory) Engine(com.bumptech.glide.load.engine.Engine)

Example 2 with LruResourceCache

use of com.bumptech.glide.load.engine.cache.LruResourceCache 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));
}
Also used : MemorySizeCalculator(com.bumptech.glide.load.engine.cache.MemorySizeCalculator) LruBitmapPool(com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool) LruResourceCache(com.bumptech.glide.load.engine.cache.LruResourceCache) InternalCacheDiskCacheFactory(com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory)

Example 3 with LruResourceCache

use of com.bumptech.glide.load.engine.cache.LruResourceCache in project fresco by facebook.

the class SampleGlideModule method applyOptions.

@Override
public void applyOptions(final Context context, GlideBuilder builder) {
    builder.setDiskCache(new DiskCache.Factory() {

        @Override
        public DiskCache build() {
            return DiskLruCacheWrapper.get(Glide.getPhotoCacheDir(context), ConfigConstants.MAX_DISK_CACHE_SIZE);
        }
    });
    builder.setMemoryCache(new LruResourceCache(ConfigConstants.MAX_MEMORY_CACHE_SIZE));
}
Also used : LruResourceCache(com.bumptech.glide.load.engine.cache.LruResourceCache) DiskCache(com.bumptech.glide.load.engine.cache.DiskCache)

Example 4 with LruResourceCache

use of com.bumptech.glide.load.engine.cache.LruResourceCache 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));
}
Also used : MemorySizeCalculator(com.bumptech.glide.load.engine.cache.MemorySizeCalculator) LruBitmapPool(com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool) LruResourceCache(com.bumptech.glide.load.engine.cache.LruResourceCache) DiskCache(com.bumptech.glide.load.engine.cache.DiskCache) File(java.io.File)

Aggregations

LruResourceCache (com.bumptech.glide.load.engine.cache.LruResourceCache)4 LruBitmapPool (com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool)3 DiskCache (com.bumptech.glide.load.engine.cache.DiskCache)2 InternalCacheDiskCacheFactory (com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory)2 MemorySizeCalculator (com.bumptech.glide.load.engine.cache.MemorySizeCalculator)2 Engine (com.bumptech.glide.load.engine.Engine)1 BitmapPoolAdapter (com.bumptech.glide.load.engine.bitmap_recycle.BitmapPoolAdapter)1 LruArrayPool (com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool)1 DefaultConnectivityMonitorFactory (com.bumptech.glide.manager.DefaultConnectivityMonitorFactory)1 File (java.io.File)1