問題は、これら3 つのライブラリをすべて 1 つのプロジェクトに結合する方法です。
- 1 つの OkHttpClient を Picasso と Retrofit の両方の背景レイヤーにします。
- Volley lib のように優先順位を変更する方法。(ページネーション用)?
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