Java Code Examples for retrofit.client.Client#Provider

The following examples show how to use retrofit.client.Client#Provider . 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: Platform.java    From android-discourse with Apache License 2.0 6 votes vote down vote up
@Override
Client.Provider defaultClient() {
    final Client client;
    if (hasOkHttpOnClasspath()) {
        client = OkClientInstantiator.instantiate();
    } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) {
        client = new AndroidApacheClient();
    } else {
        client = new UrlConnectionClient();
    }
    return new Client.Provider() {
        @Override
        public Client get() {
            return client;
        }
    };
}
 
Example 2
Source File: RestAdapter.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
private RestAdapter(Server server, Client.Provider clientProvider, Executor httpExecutor, Executor callbackExecutor, RequestInterceptor requestInterceptor, Converter converter, Profiler profiler, ErrorHandler errorHandler, Log log, LogLevel logLevel) {
    this.server = server;
    this.clientProvider = clientProvider;
    this.httpExecutor = httpExecutor;
    this.callbackExecutor = callbackExecutor;
    this.requestInterceptor = requestInterceptor;
    this.converter = converter;
    this.profiler = profiler;
    this.errorHandler = errorHandler;
    this.log = log;
    this.logLevel = logLevel;
}
 
Example 3
Source File: RestAdapter.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
/**
 * The HTTP client used for requests.
 */
public Builder setClient(Client.Provider clientProvider) {
    if (clientProvider == null) {
        throw new NullPointerException("Client provider may not be null.");
    }
    this.clientProvider = clientProvider;
    return this;
}
 
Example 4
Source File: Platform.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
@Override
Client.Provider defaultClient() {
    final Client client;
    if (hasOkHttpOnClasspath()) {
        client = OkClientInstantiator.instantiate();
    } else {
        client = new UrlConnectionClient();
    }
    return new Client.Provider() {
        @Override
        public Client get() {
            return client;
        }
    };
}
 
Example 5
Source File: RetrofitApacheClientBuilder.java    From hello-pinnedcerts with MIT License 5 votes vote down vote up
public Client.Provider build() {

        return new Client.Provider() {

            public Client get() {
                return new ApacheClient(httpClientBuilder.build());
            }
        };
    }
 
Example 6
Source File: Platform.java    From android-discourse with Apache License 2.0 votes vote down vote up
abstract Client.Provider defaultClient();