3

I wonder if it's possible to make Glide use the same OkHttpClient which I register and create in Application class?

Since we have a fairly complex OkHttpClient which is consumed by our service layer, we would like to use this instead of having Glide use it's own.

Is it possible to registering this as custom module instead?

OkHttp version: 2.5.0
Glide version: 3.6.1
halfer
  • 19,824
  • 17
  • 99
  • 186
Henric
  • 782
  • 1
  • 9
  • 23
  • Possible duplicate of [How to set OkHttpClient for glide](http://stackoverflow.com/questions/37208043/how-to-set-okhttpclient-for-glide) – Hristo Stoyanov Jan 18 '17 at 08:45

1 Answers1

0

To achieve setting the proper OkHttpClient I chose to use Picasso (2.5.2) instead. Similar libraries, so for our usage we chose Picasso instead.

Simply because we use an older version of OkHttp, and not able to update to OkHttp 3+ just yet.

In CustomApplication class called in onCreate()

private void setupPicasso()
{
    final Picasso picasso = new Picasso.Builder(getApplicationContext())
            .downloader(new OkHttpDownloader(getPrimaryHttpClient()))
            .build();
    Picasso.setSingletonInstance(picasso);
}

Gradle import:

compile 'com.squareup.picasso:picasso:2.5.2'

So now the proper client is being used, and images is working as expected.

I hope this helps anyone at least.

Henric
  • 782
  • 1
  • 9
  • 23