com.bumptech.glide.signature.EmptySignature Java Examples
The following examples show how to use
com.bumptech.glide.signature.EmptySignature.
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: ImageLoader.java From imsdk-android with MIT License | 6 votes |
/** * 获取是否有某张原图的缓存 * 缓存模式必须是:DiskCacheStrategy.SOURCE 才能获取到缓存文件 */ public static File getGlideCacheFile(Context context, String url) { try { url = QtalkStringUtils.findRealUrl(url); OriginalKey originalKey = new OriginalKey(url, EmptySignature.obtain()); SafeKeyGenerator safeKeyGenerator = new SafeKeyGenerator(); String safeKey = safeKeyGenerator.getSafeKey(originalKey); File file = new File(context.getCacheDir(), DiskCache.Factory.DEFAULT_DISK_CACHE_DIR); DiskLruCache diskLruCache = DiskLruCache.open(file, 1, 1, DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE); DiskLruCache.Value value = diskLruCache.get(safeKey); if (value != null) { return value.getFile(0); } } catch (Exception e) { e.printStackTrace(); } return null; }
Example #2
Source File: GlideLoader.java From ImageLoader with Apache License 2.0 | 6 votes |
/** * 无法同步判断 * 参见:https://github.com/bumptech/glide/issues/639 * * 4.0以上可用: * val file: File? = try { Glide.with(view.context).downloadOnly().load(url).apply(RequestOptions().onlyRetrieveFromCache(true)).submit().get() } catch (e: Exception) { e.printStackTrace() null } *https://github.com/bumptech/glide/issues/2972 * * @param url * @return */ @Override public boolean isCached(String url) { OriginalKey originalKey = new OriginalKey(url, EmptySignature.obtain()); SafeKeyGenerator safeKeyGenerator = new SafeKeyGenerator(); String safeKey = safeKeyGenerator.getSafeKey(originalKey); try { DiskLruCache diskLruCache = DiskLruCache.open(new File(GlobalConfig.context.getCacheDir(), DiskCache.Factory.DEFAULT_DISK_CACHE_DIR), 1, 1, DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE); DiskLruCache.Value value = diskLruCache.get(safeKey); if (value != null && value.getFile(0).exists() && value.getFile(0).length() > 30) { return true; } } catch (Exception e) { e.printStackTrace(); } return false; }
Example #3
Source File: Glide4Loader.java From ImageLoader with Apache License 2.0 | 6 votes |
/** * 无法同步判断 * 参见:https://github.com/bumptech/glide/issues/639 * * 4.0以上可用: * val file: File? = try { Glide.with(view.context).downloadOnly().load(url).apply(RequestOptions().onlyRetrieveFromCache(true)).submit().get() } catch (e: Exception) { e.printStackTrace() null } *https://github.com/bumptech/glide/issues/2972 * * @param url * @return */ @Override public boolean isCached(String url) { OriginalKey originalKey = new OriginalKey(url, EmptySignature.obtain()); SafeKeyGenerator safeKeyGenerator = new SafeKeyGenerator(); String safeKey = safeKeyGenerator.getSafeKey(originalKey); try { DiskLruCache diskLruCache = DiskLruCache.open(new File(GlobalConfig.context.getCacheDir(), DiskCache.Factory.DEFAULT_DISK_CACHE_DIR), 1, 1, DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE); DiskLruCache.Value value = diskLruCache.get(safeKey); if (value != null && value.getFile(0).exists() && value.getFile(0).length() > 30) { return true; } } catch (Exception e) { e.printStackTrace(); } return false; }
Example #4
Source File: GlideLoader.java From ImageLoader with Apache License 2.0 | 5 votes |
public File getCacheFile(String url) { OriginalKey originalKey = new OriginalKey(url, EmptySignature.obtain()); SafeKeyGenerator safeKeyGenerator = new SafeKeyGenerator(); String safeKey = safeKeyGenerator.getSafeKey(originalKey); try { DiskLruCache diskLruCache = DiskLruCache.open(new File(GlobalConfig.context.getCacheDir(), DiskCache.Factory.DEFAULT_DISK_CACHE_DIR), 1, 1, DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE); DiskLruCache.Value value = diskLruCache.get(safeKey); if (value != null) { return value.getFile(0); } } catch (IOException e) { e.printStackTrace(); } return null; }
Example #5
Source File: Glide4Loader.java From ImageLoader with Apache License 2.0 | 5 votes |
public File getCacheFile(String url) { OriginalKey originalKey = new OriginalKey(url, EmptySignature.obtain()); SafeKeyGenerator safeKeyGenerator = new SafeKeyGenerator(); String safeKey = safeKeyGenerator.getSafeKey(originalKey); try { DiskLruCache diskLruCache = DiskLruCache.open(new File(GlobalConfig.context.getCacheDir(), DiskCache.Factory.DEFAULT_DISK_CACHE_DIR), 1, 1, DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE); DiskLruCache.Value value = diskLruCache.get(safeKey); if (value != null) { return value.getFile(0); } } catch (IOException e) { e.printStackTrace(); } return null; }