Search in sources :

Example 1 with InternalCacheDiskCacheFactory

use of com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory 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 InternalCacheDiskCacheFactory

use of com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory in project open-event-orga-app by fossasia.

the class GlideAPI method applyOptions.

// TODO: Modify the options here according to the need
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    // 10mb
    int diskCacheSizeBytes = 1024 * 1024 * 10;
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, diskCacheSizeBytes));
}
Also used : InternalCacheDiskCacheFactory(com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory)

Example 3 with InternalCacheDiskCacheFactory

use of com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory in project AntennaPod by AntennaPod.

the class ApGlideModule method applyOptions.

@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
    builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_ARGB_8888));
    @SuppressLint("UsableSpace") long spaceAvailable = context.getCacheDir().getUsableSpace();
    long imageCacheSize = (spaceAvailable > 2 * GIGABYTES) ? (250 * MEGABYTES) : (50 * MEGABYTES);
    Log.d(TAG, "Free space on cache dir: " + spaceAvailable + ", using image cache size: " + imageCacheSize);
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, imageCacheSize));
}
Also used : RequestOptions(com.bumptech.glide.request.RequestOptions) SuppressLint(android.annotation.SuppressLint) InternalCacheDiskCacheFactory(com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory)

Example 4 with InternalCacheDiskCacheFactory

use of com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory 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 5 with InternalCacheDiskCacheFactory

use of com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory in project smartmodule by carozhu.

the class SmartGlideModule method applyOptions.

@Override
public void applyOptions(Context context, GlideBuilder builder) {
    // TODO: 16/6/24 Apply options to the builder here.
    // 设置别的get/set tag id,以免占用View默认的
    ViewTarget.setTagId(R.id.glide_tag_id);
    // 设置图片质量为高质量
    builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
    // 100M
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, DEFAULT_SAVE_IMAGE_PATH, 100 * 1024 * 1024));
}
Also used : InternalCacheDiskCacheFactory(com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory)

Aggregations

InternalCacheDiskCacheFactory (com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory)5 LruBitmapPool (com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool)2 LruResourceCache (com.bumptech.glide.load.engine.cache.LruResourceCache)2 SuppressLint (android.annotation.SuppressLint)1 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 MemorySizeCalculator (com.bumptech.glide.load.engine.cache.MemorySizeCalculator)1 DefaultConnectivityMonitorFactory (com.bumptech.glide.manager.DefaultConnectivityMonitorFactory)1 RequestOptions (com.bumptech.glide.request.RequestOptions)1