com.bumptech.glide.GlideBuilder Java Examples

The following examples show how to use com.bumptech.glide.GlideBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GlideModelConfig.java    From ImageLoader with Apache License 2.0 6 votes vote down vote up
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ) {
        builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
    }else {
        builder.setDecodeFormat(DecodeFormat.PREFER_RGB_565);
    }//解决rgb565部分手机上出现绿色问题
    //比较耗时,所以反向设置
   /* builder.setDiskCache(new DiskLruCacheFactory(new File(context.getCacheDir(), GlobalConfig.cacheFolderName).getAbsolutePath(),
            GlobalConfig.cacheMaxSize*1024*1024));*/
    Log.i("glide","applyOptions---");

   /* builder.setResizeService(new FifoPriorityThreadPoolExecutor(4))
            .setDiskCacheService(new FifoPriorityThreadPoolExecutor(4));*/

}
 
Example #2
Source File: XGlideModule.java    From XKnife-Android with Apache License 2.0 6 votes vote down vote up
@Override
public void applyOptions(Context context, GlideBuilder builder) {

    //设置图片解码格式
    builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);

    //设置内存缓存大小
    int maxMemory = (int) Runtime.getRuntime().maxMemory();//获取系统分配给应用的总内存大小
    int memoryCacheSize = maxMemory / 8;//设置图片内存缓存占用八分之一
    builder.setMemoryCache(new LruResourceCache(memoryCacheSize));
    builder.setBitmapPool(new LruBitmapPool(memoryCacheSize));

    // 存放路径和缓存控件大小
    int diskCacheSize = 1024 * 1024 * 30;
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, diskCacheName, diskCacheSize));  // data/data/xx/cache/
    builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, diskCacheName, diskCacheSize));  //存放在外置文件浏览器
}
 
Example #3
Source File: AptoideGlideModule.java    From aptoide-client with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    builder.setDiskCache(new DiskCache.Factory() {
        @Override
        public DiskCache build() {
            File pathIcons = new File(Configuration.PATH_CACHE_ICONS);
            pathIcons.mkdirs();
            return DiskLruCacheWrapper.get(pathIcons, DEFAULT_DISK_CACHE_SIZE);
        }
    });

    final MemorySizeCalculator calculator = new MemorySizeCalculator(context);
    final int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
    builder.setMemoryCache(new LruResourceCache(defaultMemoryCacheSize / 2));
    final int defaultBitmapPoolSize = calculator.getBitmapPoolSize();
    builder.setBitmapPool(new LruBitmapPool(defaultBitmapPoolSize / 2));
}
 
Example #4
Source File: GlideModifications.java    From aptoide-client-v8 with GNU General Public License v3.0 6 votes vote down vote up
@Override public void applyOptions(Context context, GlideBuilder builder) {

    builder.setDefaultRequestOptions(RequestOptions.formatOf(DecodeFormat.PREFER_RGB_565));
    // disk cache config
    //builder.setDiskCache(new ExternalCacheDiskCacheFactory(context));
    // using defaults

    MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context).build();

    // size for memory cache
    int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
    builder.setMemoryCache(new LruResourceCache(defaultMemoryCacheSize));

    // size for bitmap pool
    int defaultBitmapPoolSize = calculator.getBitmapPoolSize();
    builder.setBitmapPool(new LruBitmapPool(defaultBitmapPoolSize));
  }
 
Example #5
Source File: MyGlideModule.java    From hipda with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder gb) {
    String cacheSizeStr = HiSettingsHelper.getInstance().getStringValue(HiSettingsHelper.PERF_CACHE_SIZE_IN_MB, DEFAULT_CACHE_SIZE + "");
    int cacheSize = DEFAULT_CACHE_SIZE;
    if (TextUtils.isDigitsOnly(cacheSizeStr)) {
        cacheSize = Integer.parseInt(cacheSizeStr);
        if (cacheSize < MIN_CACHE_SIZE) {
            cacheSize = DEFAULT_CACHE_SIZE;
        }
    }
    gb.setDiskCache(new ExternalPreferredCacheDiskCacheFactory(context, cacheSize * 1024 * 1024));
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
        gb.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_RGB_565));

    GlideHelper.initDefaultFiles();
}
 
Example #6
Source File: GlideReset.java    From glide-support with The Unlicense 6 votes vote down vote up
/** Mimics Glide.get with a specific set of modules */
public void replace(Iterable<Class<? extends GlideModule>> moduleClasses) {
	Glide originalGlide = null;
	if (Glide.isSetup()) {
		originalGlide = Glide.get(applicationContext);
		tearDown();
	}
	Log.d(TAG, "Setting up new Glide...");
	GlideBuilder builder = new GlideBuilder(applicationContext);
	List<GlideModule> modules = createModules(moduleClasses);
	Log.v(TAG, "using modules: " + modules);
	applyOptions(modules, builder);
	Glide.setup(builder);
	Glide newGlide = Glide.get(applicationContext);
	registerComponents(modules, newGlide);
	Log.i(TAG, "Glide has been replaced, original=" + originalGlide + ", new=" + newGlide);
}
 
Example #7
Source File: FCGlideModules.java    From FamilyChat with Apache License 2.0 6 votes vote down vote up
@Override
public void applyOptions(Context context, GlideBuilder builder)
{
    //修改内存容量和位图缓存池大小
    MemorySizeCalculator calculator = new MemorySizeCalculator(context);
    int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
    int defaultBitmapPoolSize = calculator.getBitmapPoolSize();
    int customMemoryCacheSize = (int) (MEMORY_CACHE_COUNT * defaultMemoryCacheSize);
    int customBitmapPoolSize = (int) (MEMORY_CACHE_COUNT * defaultBitmapPoolSize);
    builder.setMemoryCache(new LruResourceCache(customMemoryCacheSize));
    builder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize));
    //设置磁盘缓存
    String diskCachePath = FCCache.getInstance().getImageCachePath();
    int cacheSize = 0;
    long availableSize = SdUtils.getAvailableExternalMemorySize();
    if (availableSize < MAX_DISK_CACHE_SIZE)
        cacheSize = (int) availableSize;
    else
        cacheSize = MAX_DISK_CACHE_SIZE;
    builder.setDiskCache(new DiskLruCacheFactory(diskCachePath, cacheSize));
}
 
Example #8
Source File: GlideUtils.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
public static void init(final Context context) {
        OkHttpClient okHttpClient = new OkHttpClient();
        okHttpClient.setReadTimeout(30, TimeUnit.SECONDS);
        okHttpClient.setConnectTimeout(30, TimeUnit.SECONDS);
//        okHttpClient.setProtocols(Arrays.asList(Protocol.HTTP_1_1));

        GlideBuilder glideBuilder = new GlideBuilder(context)
                .setDiskCache(new DiskCache.Factory() {
                    @Override
                    public DiskCache build() {
                        // Careful: the external cache directory doesn't enforce permissions
                        File cacheLocation = new File(context.getExternalCacheDir(), AppConfig.CACHE_IMAGE_DIR);
                        cacheLocation.mkdirs();
                        return DiskLruCacheWrapper.get(cacheLocation, 100 * 1024 * 1024);
                    }
                });
        if (!Glide.isSetup()) {
            Glide.setup(glideBuilder);
        }

        Glide.get(context).register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(okHttpClient));
    }
 
Example #9
Source File: CustomGlideModule.java    From leafpicrevived with GNU General Public License v3.0 6 votes vote down vote up
@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)
    );*/
}
 
Example #10
Source File: DefaultGlideModule.java    From star-zone-android with Apache License 2.0 6 votes vote down vote up
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    //磁盘缓存
    builder.setDiskCache(new DiskLruCacheFactory(context.getCacheDir().getAbsolutePath(), 50 * 1024 * 1024));
    KLog.d("Glide", "glide cache file path  >>>  " + context.getCacheDir().getAbsolutePath());
    //内存缓存
    MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context).build();
    int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
    int defaultBitmapPoolSize = calculator.getBitmapPoolSize();
    //设置比默认大小大1.5倍的缓存和图片池大小
    int customMemoryCacheSize = (int) (1.5 * defaultMemoryCacheSize);
    int customBitmapPoolSize = defaultBitmapPoolSize;

    builder.setMemoryCache(new LruResourceCache(customMemoryCacheSize));
    builder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize));


    KLog.d("Glide", "bitmapPoolSize >>>>>   " +
            formatFileSize(context, customBitmapPoolSize) +
            " / memorySize>>>>>>>>   " +
            formatFileSize(context, customMemoryCacheSize));

    builder.setLogLevel(Log.ERROR);
}
 
Example #11
Source File: ApplicationGlideModule.java    From TDTChannels-APP with MIT License 5 votes vote down vote up
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
    MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context)
            .setMemoryCacheScreens(2)
            .build();
    builder.setMemoryCache(new LruResourceCache(calculator.getMemoryCacheSize()));
}
 
Example #12
Source File: GlideConfiguration.java    From MVVMArms with Apache License 2.0 5 votes vote down vote up
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    super.applyOptions(context, builder);
    builder.setDiskCache(new DiskCache.Factory() {
        @Nullable
        @Override
        public DiskCache build() {
            // Careful: the external cache directory doesn't enforce permissions
            return DiskLruCacheWrapper.get(DataHelper.makeDirs(
                    new File(RepositoryUtils.INSTANCE.obtainRepositoryComponent(context).cacheFile(), "Glide")),
                    IMAGE_DISK_CACHE_MAX_SIZE);
        }
    });

    MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context).build();
    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));

    //将配置 Glide 的机会转交给 GlideImageLoaderStrategy,如你觉得框架提供的 GlideImageLoaderStrategy
    //并不能满足自己的需求,想自定义 BaseImageLoaderStrategy,那请你最好实现 GlideAppliesOptions
    //因为只有成为 GlideAppliesOptions 的实现类,这里才能调用 applyGlideOptions(),让你具有配置 Glide 的权利

    BaseImageLoaderStrategy imageLoaderStrategy = ArmsUtils.INSTANCE.obtainArmsComponent(context).imageLoader().getStrategy();
    if (imageLoaderStrategy instanceof GlideAppliesOptions) {
        ((GlideAppliesOptions) imageLoaderStrategy).applyGlideOptions(context, builder);
    }
}
 
Example #13
Source File: GlideConfiguration.java    From android-proguards with Apache License 2.0 5 votes vote down vote up
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    // Prefer higher quality images unless we're on a low RAM device
    ActivityManager activityManager =
            (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    builder.setDecodeFormat(activityManager.isLowRamDevice() ?
                    DecodeFormat.PREFER_RGB_565 : DecodeFormat.PREFER_ARGB_8888);
}
 
Example #14
Source File: VideoListGlideModule.java    From VideoListPlayer with MIT License 5 votes vote down vote up
@Override
public void applyOptions(final Context context, GlideBuilder builder) {
    ViewTarget.setTagId(R.id.glide_loader);
    builder.setDiskCache(new DiskLruCacheFactory(new DiskLruCacheFactory.CacheDirectoryGetter
            () {
        @Override
        public File getCacheDirectory() {
            return context.getExternalCacheDir();
        }
    }, DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE));
}
 
Example #15
Source File: QtalkGlideModule.java    From imsdk-android with MIT License 5 votes vote down vote up
@Override
    public void applyOptions(Context context, GlideBuilder builder) {
        final String dir = "/files/glide";
        int diskCacheSize = 1024 * 1024 * 1024;//最多可以缓存多少字节的数据
//        builder.setDiskCache(new ExternalCacheDiskCacheFactory(context, dir, diskCacheSize));
        builder.setDiskCache(new DiskLruCacheFactory(new DiskLruCacheFactory.CacheDirectoryGetter() {
            @Override
            public File getCacheDirectory() {
                return new File(MyDiskCache.getDirectory().getAbsolutePath() + "/files/glide");
            }
        }, diskCacheSize));
    }
 
Example #16
Source File: AbstractGlideModule.java    From Common with Apache License 2.0 5 votes vote down vote up
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_RGB_565))
            .setDiskCache(new ExternalCacheDiskCacheFactory(context, getCachePath(), 1024 * 1024 * 1024))
            .setMemoryCache(new LruResourceCache(3 * 1024 * 1024))
            .setBitmapPool(new LruBitmapPool(3 * 1024 * 1024));
}
 
Example #17
Source File: OkHttpProgressGlideModule.java    From imsdk-android with MIT License 5 votes vote down vote up
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
    File cacheDir = new File(context.getCacheDir(), DiskCache.Factory.DEFAULT_DISK_CACHE_DIR);
    cache = DiskLruCacheWrapper.get(cacheDir, DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE);
    builder.setDiskCache(new DiskCache.Factory() {
        @Override
        public DiskCache build() {
            return cache;
        }
    });
}
 
Example #18
Source File: GlideConfigModule.java    From ImageLoadPK with Apache License 2.0 5 votes vote down vote up
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    // 指定位置在packageName/cache/glide_cache,大小为MAX_CACHE_DISK_SIZE的磁盘缓存
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, "glide_cache", ConfigConstants.MAX_CACHE_DISK_SIZE));
    //指定内存缓存大小
    builder.setMemoryCache(new LruResourceCache(ConfigConstants.MAX_CACHE_MEMORY_SIZE));
    //全部的内存缓存用来作为图片缓存
    builder.setBitmapPool(new LruBitmapPool(ConfigConstants.MAX_CACHE_MEMORY_SIZE));
    builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);//和Picasso配置一样
}
 
Example #19
Source File: CustomCachingGlideModule.java    From android-tutorials-glide with MIT License 5 votes vote down vote up
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);

    // memory cache
    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));

    // disk cache
    // set size & external vs. internal
    int cacheSize100MegaBytes = 104857600;

    builder.setDiskCache(
            new InternalCacheDiskCacheFactory(context, cacheSize100MegaBytes));

    builder.setDiskCache(
            new ExternalCacheDiskCacheFactory(context, cacheSize100MegaBytes));

    // set custom location
    String downloadDirectoryPath = Environment.getDownloadCacheDirectory().getPath();

    builder.setDiskCache(
            new DiskLruCacheFactory(downloadDirectoryPath, cacheSize100MegaBytes));

    // In case you want to specify a cache folder ("glide"):
    //builder.setDiskCache(
    //        new DiskLruCacheFactory( downloadDirectoryPath, "glidecache", cacheSize100MegaBytes ) );

}
 
Example #20
Source File: GlideSetup.java    From MoeGallery with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    //builder.setMemoryCache(new LruResourceCache(64 * 1024 * 1024));
    //builder.setBitmapPool(new LruBitmapPool(32 * 1024 * 1024));
    builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, 2147483647));
    builder.setResizeService(new FifoPriorityThreadPoolExecutor(2));
}
 
Example #21
Source File: GlobalApplication.java    From narrate-android with Apache License 2.0 5 votes vote down vote up
private void setupGlide() {
    MemorySizeCalculator calculator = new MemorySizeCalculator(this);
    int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
    int defaultBitmapPoolSize = calculator.getBitmapPoolSize();

    // disable the disk cache because all of our images are already cached on the sd card
    Glide.setup(new GlideBuilder(this)
                    .setDiskCache(new DiskCacheAdapter())
                    .setBitmapPool(new LruBitmapPool(defaultBitmapPoolSize))
                    .setMemoryCache(new LruResourceCache(defaultMemoryCacheSize))
    );
}
 
Example #22
Source File: GlideConfig.java    From MVVM-JueJin with MIT License 5 votes vote down vote up
@Override
    public void applyOptions(Context context, GlideBuilder builder) {
        builder
                // 下面三项都是默认的, 不必设置
//                .setMemoryCache(new LruResourceCache(MEMORY_CACHE_SIZE))
//                .setBitmapPool(new LruBitmapPool(MEMORY_CACHE_SIZE))
                // 默认 rgb565
                .setDecodeFormat(DecodeFormat.PREFER_ARGB_8888)
                .setDiskCache(new InternalCacheDiskCacheFactory(context, DISK_CACHE_SIZE));
    }
 
Example #23
Source File: MyAppGlideModule.java    From nativescript-image-cache-it with Apache License 2.0 5 votes vote down vote up
@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
    int diskCacheSizeBytes = 1024 * 1024 * 1000; // 1GB
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, diskCacheSizeBytes));
    /*MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context)
            .setMemoryCacheScreens(4)
            .build();
    builder.setMemoryCache(new LruResourceCache(calculator.getMemoryCacheSize()));
    MemorySizeCalculator bpCalculator = new MemorySizeCalculator.Builder(context)
            .setBitmapPoolScreens(3)
            .build();
    builder.setBitmapPool(new LruBitmapPool(bpCalculator.getBitmapPoolSize()));
    */
}
 
Example #24
Source File: CustomGlideModule.java    From RetrofitClient with MIT License 5 votes vote down vote up
@Override
    public void applyOptions(Context context, GlideBuilder builder) {

//        MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context)
//                .setMemoryCacheScreens(2)
//                .build();
//        builder.setMemoryCache(new LruResourceCache(calculator.getMemoryCacheSize()));

//        builder.setDiskCache(new ExternalCacheDiskCacheFactory(context));
        int diskCacheSizeBytes = 1024 * 1024 * 100; // 100 MB
        builder.setDiskCache(new InternalCacheDiskCacheFactory(context, diskCacheSizeBytes));
//        builder.setDiskCache(new InternalCacheDiskCacheFactory(context, "cacheFolderName", diskCacheSizeBytes));
    }
 
Example #25
Source File: AbstractGlideModule.java    From DMusic with Apache License 2.0 5 votes vote down vote up
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_RGB_565))
            .setDiskCache(new ExternalCacheDiskCacheFactory(context, getCachePath(), 1024 * 1024 * 1024))
            .setMemoryCache(new LruResourceCache(3 * 1024 * 1024))
            .setBitmapPool(new LruBitmapPool(3 * 1024 * 1024));
}
 
Example #26
Source File: GlideConfiguration.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    AppComponent appComponent = ArmsUtils.obtainAppComponentFromContext(context);
    builder.setDiskCache(new DiskCache.Factory() {
        @Override
        public DiskCache build() {
            // Careful: the external cache directory doesn't enforce permissions
            return DiskLruCacheWrapper.get(DataHelper.makeDirs(new File(appComponent.cacheFile(), "Glide")), IMAGE_DISK_CACHE_MAX_SIZE);
        }
    });

    MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context).build();
    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));

    //将配置 Glide 的机会转交给 GlideImageLoaderStrategy,如你觉得框架提供的 GlideImageLoaderStrategy
    //并不能满足自己的需求,想自定义 BaseImageLoaderStrategy,那请你最好实现 GlideAppliesOptions
    //因为只有成为 GlideAppliesOptions 的实现类,这里才能调用 applyGlideOptions(),让你具有配置 Glide 的权利
    BaseImageLoaderStrategy loadImgStrategy = appComponent.imageLoader().getLoadImgStrategy();
    if (loadImgStrategy instanceof GlideAppliesOptions) {
        ((GlideAppliesOptions) loadImgStrategy).applyGlideOptions(context, builder);
    }
}
 
Example #27
Source File: MyGlideModule.java    From ZoomPreviewPicture with Apache License 2.0 5 votes vote down vote up
@Override
public void applyOptions(final Context context, GlideBuilder builder) {
    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));
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, cacheSize100MegaBytes));
    ViewTarget.setTagId(R.id.glide_tag_id);
}
 
Example #28
Source File: MyAppGlideModel.java    From OpenHub with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    super.applyOptions(context, builder);
    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, AppConfig.IMAGE_MAX_CACHE_SIZE));
    RequestOptions requestOptions = RequestOptions.placeholderOf(R.mipmap.logo);
    builder.setDefaultRequestOptions(requestOptions);
}
 
Example #29
Source File: OkHttpGlideModule.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
@Override
  public void applyOptions(Context context, GlideBuilder builder) {

//    int deskacheize = 1024 * 1024 * 30;
    int maxMemory = (int)Runtime.getRuntime().maxMemory();
    int memoryCheSize = maxMemory / 8;
//    builder.setDiskCache(new InternalCacheDiskCacheFactory(context, "glide", deskacheize));
    builder.setDiskCache(new DiskLruCacheFactory(FileUtil.getCacheDir(),"glide", DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE));
    builder.setMemoryCache(new LruResourceCache(memoryCheSize));
    builder.setBitmapPool(new LruBitmapPool(memoryCheSize));
    builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
  }
 
Example #30
Source File: QuickModule.java    From glide-support with The Unlicense 4 votes vote down vote up
@Override public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
//		builder.setDiskCache(new ExternalCacheDiskCacheFactory(context));
	}