Search code examples
androidretrofitpicassookhttp

OkHttp + Picasso + Retrofit


The question is how to combine all these 3 libraries in one project?

  • Make one OkHttpClient to be a background layer for both Picasso and Retrofit.
  • How to make Priority changes like in Volley lib. (for pagination)?

Solution

  • 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.