Java Code Examples for retrofit2.adapter.rxjava.RxJavaCallAdapterFactory#create()

The following examples show how to use retrofit2.adapter.rxjava.RxJavaCallAdapterFactory#create() . 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: OkApiModule.java    From Forage with Mozilla Public License 2.0 4 votes vote down vote up
@NonNull
@Provides
@Singleton
public static RxJavaCallAdapterFactory providesRxAdapter() {
    return RxJavaCallAdapterFactory.create();
}
 
Example 2
Source File: ApiServiceModule.java    From MVP-Dagger2-Rxjava-Retrofit with Apache License 2.0 4 votes vote down vote up
@Provides
@Singleton
protected RxJavaCallAdapterFactory provideRxJavaCallAdapterFactory() {
    return RxJavaCallAdapterFactory.create();
}
 
Example 3
Source File: RestModule.java    From octoandroid with GNU General Public License v3.0 4 votes vote down vote up
@Provides
@Singleton
RxJavaCallAdapterFactory provideRxJavaCallAdapterFactory() {
    return RxJavaCallAdapterFactory.create();
}
 
Example 4
Source File: ApiModule.java    From fyber_mobile_offers with MIT License 4 votes vote down vote up
@Provides
@Singleton
public CallAdapter.Factory provideRxJavaCallAdapterFactory() {
    return RxJavaCallAdapterFactory.create();
}
 
Example 5
Source File: ApplicationModule.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@Singleton @Provides @Named("rx") CallAdapter.Factory providesCallAdapterFactory() {
  return RxJavaCallAdapterFactory.create();
}
 
Example 6
Source File: RestClient.java    From autorest-clientruntime-for-java with MIT License 4 votes vote down vote up
/**
 * Build a RestClient with all the current configurations.
 *
 * @return a {@link RestClient}.
 */
public RestClient build() {
    UserAgentInterceptor userAgentInterceptor = new UserAgentInterceptor();
    if (userAgent != null) {
        userAgentInterceptor.withUserAgent(userAgent);
    }
    if (baseUrl == null) {
        throw new IllegalArgumentException("Please set base URL.");
    }
    if (!baseUrl.endsWith("/")) {
        baseUrl += "/";
    }
    if (responseBuilderFactory == null) {
        throw new IllegalArgumentException("Please set response builder factory.");
    }
    if (serializerAdapter == null) {
        throw new IllegalArgumentException("Please set serializer adapter.");
    }

    if (this.credentials != null) {
        int interceptorCount = httpClientBuilder.interceptors().size();
        this.credentials.applyCredentialsFilter(httpClientBuilder);
        // store the interceptor
        if (httpClientBuilder.interceptors().size() > interceptorCount) {
            credentialsInterceptor = httpClientBuilder.interceptors().get(interceptorCount);
        }
    }

    RetryHandler retryHandler;
    if (retryStrategy == null) {
        retryHandler = new RetryHandler();
    } else {
        retryHandler = new RetryHandler(retryStrategy);
    }

    if (connectionPool != null) {
        httpClientBuilder = httpClientBuilder.connectionPool(connectionPool);
    }
    if (dispatcher != null) {
        httpClientBuilder = httpClientBuilder.dispatcher(dispatcher);
    }

    if (this.tlsVersions != null || this.cipherSuites != null) {
        ConnectionSpec.Builder connectionSpecBuilder = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS);
        if (this.tlsVersions != null && this.tlsVersions.length > 0) {
            connectionSpecBuilder.tlsVersions(this.tlsVersions);
        }
        if (this.cipherSuites != null && this.cipherSuites.length > 0) {
            connectionSpecBuilder.cipherSuites(this.cipherSuites);
        }
        this.httpClientBuilder.connectionSpecs(Arrays.asList(connectionSpecBuilder.build(), ConnectionSpec.CLEARTEXT));
    }

    OkHttpClient httpClient = httpClientBuilder
            .addInterceptor(userAgentInterceptor)
            .addInterceptor(customHeadersInterceptor)
            .addInterceptor(retryHandler)
            .addNetworkInterceptor(loggingInterceptor)
            .build();

    RxJavaCallAdapterFactory callAdapterFactory;
    if (useHttpClientThreadPool) {
        callAdapterFactory = RxJavaCallAdapterFactory.createAsync();
    } else {
        callAdapterFactory = RxJavaCallAdapterFactory.create();
    }

    return new RestClient(httpClient,
            retrofitBuilder
                    .baseUrl(baseUrl)
                    .client(httpClient)
                    .addConverterFactory(serializerAdapter.converterFactory())
                    .addCallAdapterFactory(callAdapterFactory)
                    .build(),
            this);
}
 
Example 7
Source File: NetworkModule.java    From android with Apache License 2.0 4 votes vote down vote up
@Provides @Singleton CallAdapter.Factory provideCallAdapterFactory() {
  return RxJavaCallAdapterFactory.create();
}