OkHttp + Picasso + Retrofit

问题是如何将所有这3个库合并到一个项目中?

  • 使一个OkHttpClient成为Picasso和Retrofit的背景图层。
  • 如何在Volley lib中进行优先级更改。 (分页)?

简而言之:

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。

对于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