Reputation: 1416
The question is how to combine all these 3 libraries in one project?
Upvotes: 6
Views: 7085
Reputation: 11406
For OkHttpClient 3.0 and Retrofit 2.0 it is:
OkHttpClient client = new OkHttpClient.Builder()
.cache(cache) // optional for adding cache
.networkInterceptors().add(loggingInterceptor) // optional for adding an interceptor
.build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://api.yourdomain.com/v1/")
.addConverterFactory(GsonConverterFactory.create())
.client(client)
.build();
Picasso picasso = Picasso.Builder(context)
.downloader(new OkHttp3Downloader(client))
.build();
Prioritization has been moved down the stack model to the http client, and there is an issue being studied: https://github.com/square/okhttp/issues/1361
Upvotes: 8
Reputation: 7937
In a nutshell:
OkHttpClient okHttpClient = new OkHttpClient();
RestAdapter restAdapter = new RestAdapter.Builder().setClient(new OkClient(okHttpClient)).build();
OkHttpDownloader downloader = new OkHttpDownloader(okHttpClient);
Picasso picasso = new Picasso.Builder(this).downloader(downloader).build();
I do not think it's possible to have priorities with the current version of Retrofit.
Upvotes: 20