Java Code Examples for io.victoralbertos.jolyglot.GsonSpeaker

The following examples show how to use io.victoralbertos.jolyglot.GsonSpeaker. These examples are extracted from open source projects. 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 Project: MVPArms   Source File: ClientModule.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 提供 {@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));
}
 
Example 2
Source Project: v9porn   Source File: ApplicationModule.java    License: MIT License 5 votes vote down vote up
@Singleton
@Provides
static CacheProviders providesCacheProviders(@ApplicationContext Context context) {
    File cacheDir = AppCacheUtils.getRxCacheDir(context);
    return new RxCache.Builder()
            .persistence(cacheDir, new GsonSpeaker())
            .using(CacheProviders.class);
}
 
Example 3
Source Project: AcgClub   Source File: ClientModule.java    License: MIT License 5 votes vote down vote up
/**
 * 提供RXCache客户端
 *
 * @param cacheDirectory RxCache缓存路径
 */
@Singleton
@Provides
RxCache provideRxCache(@Named("RxCacheDirectory") File cacheDirectory, Gson gson) {
  return new RxCache
      .Builder()
      .persistence(cacheDirectory, new GsonSpeaker(gson));
}
 
Example 4
Source Project: v9porn   Source File: ApplicationModule.java    License: MIT License 5 votes vote down vote up
@Singleton
@Provides
static CacheProviders providesCacheProviders(@ApplicationContext Context context) {
    File cacheDir = AppCacheUtils.getRxCacheDir(context);
    return new RxCache.Builder()
            .persistence(cacheDir, new GsonSpeaker())
            .using(CacheProviders.class);
}
 
Example 5
Source Project: POCenter   Source File: Repertories.java    License: MIT License 5 votes vote down vote up
public Repertories(File cacheDir) {
    // create apis
    cacheApi = new RxCache.Builder()
            .useExpiredDataIfLoaderNotAvailable(true)
            .persistence(cacheDir, new GsonSpeaker())
            .using(CacheApi.class);

    remoteApi = new Retrofit.Builder()
            .baseUrl(URL_BASE)
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .addConverterFactory(GsonConverterFactory.create())
            .client(UnsafeOkHttpUtils.getClient())
            .build()
            .create(RemoteApi.class);

    // add types
    Context context = BaseApplication.getContext();
    types.add(context.getString(R.string.type_other));
    types.add(context.getString(R.string.type_web));
    types.add(context.getString(R.string.type_we_chat));
    types.add(context.getString(R.string.type_html5));
    types.add(context.getString(R.string.type_app));
    types.add(context.getString(R.string.type_intelligent_hardware));
    types.add(context.getString(R.string.type_desktop_app));
    types.add(context.getString(R.string.type_big_data));
    types.add(context.getString(R.string.type_system));
    types.add(context.getString(R.string.type_sdk_api));
    types.add(context.getString(R.string.type_art));
}
 
Example 6
Source Project: Aurora   Source File: ClientModule.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 提供 {@link RxCache}
 *
 * @param cacheDirectory RxCache缓存路径
 * @return
 */
@Singleton
@Provides
RxCache provideRxCache(Application application, @Nullable RxCacheConfiguration configuration, @Named("RxCacheDirectory") File cacheDirectory) {
    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());
}
 
Example 7
Source Project: MVVMArms   Source File: ClientModule.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 提供 {@link RxCache}
 *
 * @param cacheDirectory RxCache 缓存路径
 * @return RxCache
 */
@Singleton
@Provides
RxCache provideRxCache(@Nullable RxCacheConfiguration configuration, @Named("RxCacheDirectory") File cacheDirectory) {
    RxCache.Builder builder = new RxCache.Builder();
    RxCache rxCache = null;
    if (configuration != null) {
        rxCache = configuration.configRxCache(mApplication, builder);
    }
    if (rxCache != null) {
        return rxCache;
    }
    return builder.persistence(cacheDirectory, new GsonSpeaker());
}
 
Example 8
Source Project: RxGpsService   Source File: BaseApp.java    License: Apache License 2.0 4 votes vote down vote up
private void initReactiveCache() {
    reactiveCache = new ReactiveCache.Builder()
            .using(getFilesDir(), new GsonSpeaker());
}