Java Code Examples for com.bumptech.glide.Glide#getPhotoCacheDir()

The following examples show how to use com.bumptech.glide.Glide#getPhotoCacheDir() . 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: ImageWatcherUtils.java    From tysq-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 通过 url 获取 glide 的存储文件
 *
 * @param context 上下文
 * @param url     url
 * @return 存储文件
 */
public static File getGlideCacheFileViaUrl(Context context, String url) {
    File photoCacheDir = Glide.getPhotoCacheDir(context);

    if (photoCacheDir == null) {
        return null;
    }

    String key = EncryptionUtils.sha256Encrypt(url);

    return new File(photoCacheDir, key + GLIDE_CACHE_SUFFIX);
}
 
Example 2
Source File: GlideUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 获取 SDCard 缓存空间
 * @return SDCard 缓存空间 File
 */
public static File getDiskCache() {
    try {
        return Glide.getPhotoCacheDir(sContext);
    } catch (Exception e) {
        LogPrintUtils.eTag(TAG, e, "getDiskCache");
    }
    return null;
}
 
Example 3
Source File: ExplorerActivity.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
@Override
   public void onResume() {
       Log.d(TAG, "onResume");
	super.onResume();
	File cacheDir = Glide.getPhotoCacheDir(ExplorerActivity.this);
	Log.d(TAG, "onResume cacheDir " + cacheDir.getAbsolutePath());
	curContentFrag = (ContentFragment) slideFrag.getFragmentIndex(curContentFragIndex);
	curSelectionFrag = (ContentFragment) slideFrag.getFrag(Frag.TYPE.SELECTION);
	if (slideFrag2 != null) {
		curExplorerFrag = (ContentFragment) slideFrag2.getFragmentIndex(curExplorerFragIndex);
		curSelectionFrag2 = (ContentFragment) slideFrag2.getFrag(Frag.TYPE.SELECTION);
		Log.d(TAG, "onResume curContentFrag2 " + curSelectionFrag2);
	}
}
 
Example 4
Source File: ExplorerActivity.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
public void clearCache(View v) {
    Log.d(TAG, "clearing cache");
    Glide.clear(v);
    //Glide.clear(imageViewNet);
    Glide.get(this).clearMemory();
    File cacheDir = Glide.getPhotoCacheDir(this);
    if (cacheDir.isDirectory()) {
        for (File child : cacheDir.listFiles()) {
            if (!child.delete()) {
                Log.w(TAG, "cannot delete: " + child);
            }
        }
    }
    //reload();
}
 
Example 5
Source File: OkHttpHelper.java    From hipda with GNU General Public License v2.0 5 votes vote down vote up
private OkHttpHelper() {
    mCookiestore = new PersistentCookieStore(HiApplication.getAppContext(), HiUtils.CookieDomain);
    mCookieJar = new CookieJar() {
        @Override
        public void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
            if (cookies != null && cookies.size() > 0) {
                for (Cookie item : cookies) {
                    mCookiestore.add(url, item);
                }
            }
        }

        @Override
        public List<Cookie> loadForRequest(HttpUrl url) {
            return mCookiestore.get(url);
        }
    };
    Cache cache = new Cache(Glide.getPhotoCacheDir(HiApplication.getAppContext(), CACHE_DIR_NAME), 10 * 1024 * 1024);

    OkHttpClient.Builder builder = new OkHttpClient.Builder();
    builder.connectTimeout(OkHttpHelper.NETWORK_TIMEOUT_SECS, TimeUnit.SECONDS)
            .readTimeout(OkHttpHelper.NETWORK_TIMEOUT_SECS, TimeUnit.SECONDS)
            .writeTimeout(OkHttpHelper.NETWORK_TIMEOUT_SECS, TimeUnit.SECONDS)
            .cache(cache)
            .cookieJar(mCookieJar);

    if (HiSettingsHelper.getInstance().isTrustAllCerts()) {
        setupTrustAllCerts(builder);
    }

    if (Logger.isDebug())
        builder.addInterceptor(new LoggingInterceptor());

    mClient = builder.build();
    handler = new Handler(Looper.getMainLooper());
}
 
Example 6
Source File: Utils.java    From hipda with GNU General Public License v2.0 5 votes vote down vote up
public static void clearOkhttpCache() {
    try {
        File cache = Glide.getPhotoCacheDir(HiApplication.getAppContext(), OkHttpHelper.CACHE_DIR_NAME);
        if (cache != null && cache.isDirectory()) {
            deleteDir(cache);
        }
    } catch (Exception ignored) {
    }
}
 
Example 7
Source File: DataCleanManager.java    From LLApp with Apache License 2.0 2 votes vote down vote up
/**
 * 获取glide的图片缓存路径
 * @param context
 * @return
 */
public static File getGlideDir(Context context){
    File glideCache = Glide.getPhotoCacheDir(context);
    return glideCache;
}