Java Code Examples for com.lzy.okgo.cache.CacheMode#NO_CACHE
The following examples show how to use
com.lzy.okgo.cache.CacheMode#NO_CACHE .
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: OkGo.java From okhttp-OkGo with Apache License 2.0 | 6 votes |
private OkGo() { mDelivery = new Handler(Looper.getMainLooper()); mRetryCount = 3; mCacheTime = CacheEntity.CACHE_NEVER_EXPIRE; mCacheMode = CacheMode.NO_CACHE; OkHttpClient.Builder builder = new OkHttpClient.Builder(); HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor("OkGo"); loggingInterceptor.setPrintLevel(HttpLoggingInterceptor.Level.BODY); loggingInterceptor.setColorLevel(Level.INFO); builder.addInterceptor(loggingInterceptor); builder.readTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS); builder.writeTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS); builder.connectTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS); HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(); builder.sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager); builder.hostnameVerifier(HttpsUtils.UnSafeHostnameVerifier); okHttpClient = builder.build(); }
Example 2
Source File: OkGo.java From BaseProject with Apache License 2.0 | 6 votes |
private OkGo() { mDelivery = new Handler(Looper.getMainLooper()); mRetryCount = 3; mCacheTime = CacheEntity.CACHE_NEVER_EXPIRE; mCacheMode = CacheMode.NO_CACHE; OkHttpClient.Builder builder = new OkHttpClient.Builder(); HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor("OkGo"); loggingInterceptor.setPrintLevel(HttpLoggingInterceptor.Level.BODY); loggingInterceptor.setColorLevel(Level.CONFIG); builder.addInterceptor(loggingInterceptor); builder.readTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS); builder.writeTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS); builder.connectTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS); HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(); builder.sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager); builder.hostnameVerifier(HttpsUtils.UnSafeHostnameVerifier); okHttpClient = builder.build(); }
Example 3
Source File: BaseCachePolicy.java From BaseProject with Apache License 2.0 | 6 votes |
/** * 请求成功后根据缓存模式,更新缓存数据 * * @param headers 响应头 * @param data 响应数据 */ private void saveCache(Headers headers, T data) { if (data == null) { return; } if (request.getCacheMode() == CacheMode.NO_CACHE) return; //不需要缓存,直接返回 if (data instanceof Bitmap) return; //Bitmap没有实现Serializable,不能缓存 CacheEntity<T> cache = HeaderParser.createCacheEntity(headers, data, request.getCacheMode(), request.getCacheKey()); if (cache == null) { //服务器不需要缓存,移除本地缓存 CacheManager.getInstance().remove(request.getCacheKey()); } else { //缓存命中,更新缓存 CacheManager.getInstance().replace(request.getCacheKey(), cache); } }
Example 4
Source File: BaseCachePolicy.java From okhttp-OkGo with Apache License 2.0 | 5 votes |
/** * 请求成功后根据缓存模式,更新缓存数据 * * @param headers 响应头 * @param data 响应数据 */ private void saveCache(Headers headers, T data) { if (request.getCacheMode() == CacheMode.NO_CACHE) return; //不需要缓存,直接返回 if (data instanceof Bitmap) return; //Bitmap没有实现Serializable,不能缓存 CacheEntity<T> cache = HeaderParser.createCacheEntity(headers, data, request.getCacheMode(), request.getCacheKey()); if (cache == null) { //服务器不需要缓存,移除本地缓存 CacheManager.getInstance().remove(request.getCacheKey()); } else { //缓存命中,更新缓存 CacheManager.getInstance().replace(request.getCacheKey(), cache); } }