当前位置: 首页>>代码示例>>Java>>正文


Java CacheType类代码示例

本文整理汇总了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;
}
 
开发者ID:Superingxz,项目名称:MoligyMvpArms,代码行数:23,代码来源:RepositoryManager.java

示例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;
}
 
开发者ID:Superingxz,项目名称:MoligyMvpArms,代码行数:23,代码来源:RepositoryManager.java

示例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;
}
 
开发者ID:Superingxz,项目名称:MoligyMvpArms,代码行数:14,代码来源:GlobalConfigModule.java

示例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;
}
 
开发者ID:Zweihui,项目名称:Aurora,代码行数:9,代码来源:BaseLazyLoadFragment.java

示例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;
}
 
开发者ID:Zweihui,项目名称:Aurora,代码行数:9,代码来源:BaseActivity.java

示例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;
}
 
开发者ID:Zweihui,项目名称:Aurora,代码行数:20,代码来源:RepositoryManager.java

示例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;
}
 
开发者ID:Zweihui,项目名称:Aurora,代码行数:20,代码来源:RepositoryManager.java

示例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);
}
 
开发者ID:Superingxz,项目名称:MoligyMvpArms,代码行数:6,代码来源:AppModule.java


注:本文中的com.jess.arms.integration.cache.CacheType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。