Cat*_*san 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();
Run Code Online (Sandbox Code Playgroud)
我不认为有可能优先使用当前版本的Retrofit.
对于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();
Run Code Online (Sandbox Code Playgroud)
优先级已经从堆栈模型向下移动到http客户端,并且正在研究一个问题:https://github.com/square/okhttp/issues/1361