diff --git a/retrofit/src/main/java/retrofit/Platform.java b/retrofit/src/main/java/retrofit/Platform.java index 5a394746f1e83d25e287a23c78b0dd0f978828f4..57b2d6abc815d63a015e56b24bf429184a5ee07a 100644 --- a/retrofit/src/main/java/retrofit/Platform.java +++ b/retrofit/src/main/java/retrofit/Platform.java @@ -60,7 +60,7 @@ abstract class Platform { } abstract Converter defaultConverter(); - abstract Client.Provider defaultClient(); + abstract Client defaultClient(); abstract Executor defaultHttpExecutor(); abstract Executor defaultCallbackExecutor(); abstract RestAdapter.Log defaultLog(); @@ -71,18 +71,11 @@ abstract class Platform { return new GsonConverter(new Gson()); } - @Override Client.Provider defaultClient() { - final Client client; + @Override Client defaultClient() { if (hasOkHttpOnClasspath()) { - client = OkClientInstantiator.instantiate(); - } else { - client = new UrlConnectionClient(); + return OkClientInstantiator.instantiate(); } - return new Client.Provider() { - @Override public Client get() { - return client; - } - }; + return new UrlConnectionClient(); } @Override Executor defaultHttpExecutor() { @@ -117,20 +110,14 @@ abstract class Platform { return new GsonConverter(new Gson()); } - @Override Client.Provider defaultClient() { - final Client client; + @Override Client defaultClient() { if (hasOkHttpOnClasspath()) { - client = OkClientInstantiator.instantiate(); - } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) { - client = new AndroidApacheClient(); - } else { - client = new UrlConnectionClient(); + return OkClientInstantiator.instantiate(); } - return new Client.Provider() { - @Override public Client get() { - return client; - } - }; + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) { + return new AndroidApacheClient(); + } + return new UrlConnectionClient(); } @Override Executor defaultHttpExecutor() { @@ -156,13 +143,8 @@ abstract class Platform { } private static class AppEngine extends Base { - @Override Client.Provider defaultClient() { - final UrlFetchClient client = new UrlFetchClient(); - return new Client.Provider() { - @Override public Client get() { - return client; - } - }; + @Override Client defaultClient() { + return new UrlFetchClient(); } } diff --git a/retrofit/src/main/java/retrofit/RestAdapter.java b/retrofit/src/main/java/retrofit/RestAdapter.java index ed2644a9d4c9f2f331158995f6ffbda05c48e46f..8209d45814572c2571f41534329372c4bb1b9145 100644 --- a/retrofit/src/main/java/retrofit/RestAdapter.java +++ b/retrofit/src/main/java/retrofit/RestAdapter.java @@ -153,17 +153,17 @@ public class RestAdapter { final Log log; final ErrorHandler errorHandler; - private final Client.Provider clientProvider; + private final Client client; private final Profiler profiler; private RxSupport rxSupport; volatile LogLevel logLevel; - private RestAdapter(Endpoint server, Client.Provider clientProvider, Executor httpExecutor, + private RestAdapter(Endpoint server, Client client, Executor httpExecutor, Executor callbackExecutor, RequestInterceptor requestInterceptor, Converter converter, Profiler profiler, ErrorHandler errorHandler, Log log, LogLevel logLevel) { this.server = server; - this.clientProvider = clientProvider; + this.client = client; this.httpExecutor = httpExecutor; this.callbackExecutor = callbackExecutor; this.requestInterceptor = requestInterceptor; @@ -318,7 +318,7 @@ public class RestAdapter { } long start = System.nanoTime(); - Response response = clientProvider.get().execute(request); + Response response = client.execute(request); long elapsedTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start); int statusCode = response.getStatus(); @@ -527,22 +527,12 @@ public class RestAdapter { /** * Build a new {@link RestAdapter}. *
- * Calling the following methods is required before calling {@link #build()}: - *
- * If you are using asynchronous execution (i.e., with {@link Callback Callbacks}) the following - * is also required: - *