Java Code Examples for com.bumptech.glide.Glide#setup()
The following examples show how to use
com.bumptech.glide.Glide#setup() .
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: GlideReset.java From glide-support with The Unlicense | 6 votes |
/** 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 2
Source File: GlideUtils.java From BigApp_Discuz_Android with Apache License 2.0 | 6 votes |
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 3
Source File: GlobalApplication.java From narrate-android with Apache License 2.0 | 5 votes |
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)) ); }