Search in sources :

Example 1 with GsonSpeaker

use of io.victoralbertos.jolyglot.GsonSpeaker in project MVPArms by JessYanCoding.

the class ClientModule method provideRxCache.

/**
 * 提供 {@link RxCache}
 *
 * @param application    {@link Application}
 * @param configuration  {@link RxCacheConfiguration}
 * @param cacheDirectory RxCache 缓存路径
 * @param gson           {@link Gson}
 * @return {@link RxCache}
 */
@Singleton
@Provides
static RxCache provideRxCache(Application application, @Nullable RxCacheConfiguration configuration, @Named("RxCacheDirectory") File cacheDirectory, Gson gson) {
    RxCache.Builder builder = new RxCache.Builder();
    RxCache rxCache = null;
    if (configuration != null) {
        rxCache = configuration.configRxCache(application, builder);
    }
    if (rxCache != null) {
        return rxCache;
    }
    return builder.persistence(cacheDirectory, new GsonSpeaker(gson));
}
Also used : GsonSpeaker(io.victoralbertos.jolyglot.GsonSpeaker) RxCache(io.rx_cache2.internal.RxCache) Singleton(javax.inject.Singleton) Provides(dagger.Provides)

Aggregations

Provides (dagger.Provides)1 RxCache (io.rx_cache2.internal.RxCache)1 GsonSpeaker (io.victoralbertos.jolyglot.GsonSpeaker)1 Singleton (javax.inject.Singleton)1