本文整理汇总了Java中com.jess.arms.integration.cache.CacheType类的典型用法代码示例。如果您正苦于以下问题:Java CacheType类的具体用法?Java CacheType怎么用?Java CacheType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CacheType类属于com.jess.arms.integration.cache包,在下文中一共展示了CacheType类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: obtainRetrofitService
import com.jess.arms.integration.cache.CacheType; //导入依赖的package包/类
/**
* 根据传入的 Class 获取对应的 Retrofit service
*
* @param service
* @param <T>
* @return
*/
@Override
public <T> T obtainRetrofitService(Class<T> service) {
if (mRetrofitServiceCache == null)
mRetrofitServiceCache = mCachefactory.build(CacheType.RETROFIT_SERVICE_CACHE);
Preconditions.checkNotNull(mRetrofitServiceCache,"Cannot return null from a Cache.Factory#build(int) method");
T retrofitService;
synchronized (mRetrofitServiceCache) {
retrofitService = (T) mRetrofitServiceCache.get(service.getName());
if (retrofitService == null) {
retrofitService = mRetrofit.get().create(service);
mRetrofitServiceCache.put(service.getName(), retrofitService);
}
}
return retrofitService;
}
示例2: obtainCacheService
import com.jess.arms.integration.cache.CacheType; //导入依赖的package包/类
/**
* 根据传入的 Class 获取对应的 RxCache service
*
* @param cache
* @param <T>
* @return
*/
@Override
public <T> T obtainCacheService(Class<T> cache) {
if (mCacheServiceCache == null)
mCacheServiceCache = mCachefactory.build(CacheType.CACHE_SERVICE_CACHE);
Preconditions.checkNotNull(mCacheServiceCache,"Cannot return null from a Cache.Factory#build(int) method");
T cacheService;
synchronized (mCacheServiceCache) {
cacheService = (T) mCacheServiceCache.get(cache.getName());
if (cacheService == null) {
cacheService = mRxCache.get().using(cache);
mCacheServiceCache.put(cache.getName(), cacheService);
}
}
return cacheService;
}
示例3: provideCacheFactory
import com.jess.arms.integration.cache.CacheType; //导入依赖的package包/类
@Singleton
@Provides
Cache.Factory provideCacheFactory(Application application) {
return mCacheFactory == null ? new Cache.Factory() {
@NonNull
@Override
public Cache build(CacheType type) {
//若想自定义 LruCache 的 size, 或者不想使用 LruCache , 想使用自己自定义的策略
//并使用 GlobalConfigModule.Builder#cacheFactory() 扩展
return new LruCache(type.calculateCacheSize(application));
}
} : mCacheFactory;
}
示例4: provideCache
import com.jess.arms.integration.cache.CacheType; //导入依赖的package包/类
@NonNull
@Override
public synchronized Cache<String, Object> provideCache() {
if (mCache == null) {
mCache = ArmsUtils.obtainAppComponentFromContext(getActivity()).cacheFactory().build(CacheType.FRAGMENT_CACHE);
}
return mCache;
}
示例5: provideCache
import com.jess.arms.integration.cache.CacheType; //导入依赖的package包/类
@NonNull
@Override
public synchronized Cache<String, Object> provideCache() {
if (mCache == null) {
mCache = ArmsUtils.obtainAppComponentFromContext(this).cacheFactory().build(CacheType.ACTIVITY_CACHE);
}
return mCache;
}
示例6: obtainRetrofitService
import com.jess.arms.integration.cache.CacheType; //导入依赖的package包/类
/**
* 根据传入的 Class 获取对应的 Retrofit service
*
* @param service
* @param <T>
* @return
*/
@Override
public synchronized <T> T obtainRetrofitService(Class<T> service) {
if (mRetrofitServiceCache == null)
mRetrofitServiceCache = mCachefactory.build(CacheType.RETROFIT_SERVICE_CACHE);
Preconditions.checkNotNull(mRetrofitServiceCache, "Cannot return null from a Cache.Factory#build(int) method");
T retrofitService = (T) mRetrofitServiceCache.get(service.getCanonicalName());
if (retrofitService == null) {
retrofitService = mRetrofit.get().create(service);
mRetrofitServiceCache.put(service.getCanonicalName(), retrofitService);
}
return retrofitService;
}
示例7: obtainCacheService
import com.jess.arms.integration.cache.CacheType; //导入依赖的package包/类
/**
* 根据传入的 Class 获取对应的 RxCache service
*
* @param cache
* @param <T>
* @return
*/
@Override
public synchronized <T> T obtainCacheService(Class<T> cache) {
if (mCacheServiceCache == null)
mCacheServiceCache = mCachefactory.build(CacheType.CACHE_SERVICE_CACHE);
Preconditions.checkNotNull(mCacheServiceCache, "Cannot return null from a Cache.Factory#build(int) method");
T cacheService = (T) mCacheServiceCache.get(cache.getCanonicalName());
if (cacheService == null) {
cacheService = mRxCache.get().using(cache);
mCacheServiceCache.put(cache.getCanonicalName(), cacheService);
}
return cacheService;
}
示例8: provideExtras
import com.jess.arms.integration.cache.CacheType; //导入依赖的package包/类
@Singleton
@Provides
public Cache<String, Object> provideExtras(Cache.Factory cacheFactory) {
return cacheFactory.build(CacheType.EXTRAS);
}