问题是如何将所有这些 3 库合并到一个项目中?
答案 0 :(得分:20)
简而言之:
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();
我认为可以优先使用当前版本的Retrofit。
答案 1 :(得分:7)
对于OkHttpClient 3.0和Retrofit 2.0,它是:
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();
优先级已经从堆栈模型向下移动到http客户端,并且正在研究一个问题:https://github.com/square/okhttp/issues/1361