Use project level okhttp client with glide

This commit is contained in:
Shinokuni 2020-09-05 14:05:16 +02:00
parent 6c6653e443
commit d59e38ee9d
2 changed files with 21 additions and 10 deletions

View File

@ -1,10 +0,0 @@
package com.readrops.app.utils;
import androidx.annotation.NonNull;
import com.bumptech.glide.module.AppGlideModule;
@com.bumptech.glide.annotation.GlideModule
public class GlideModule extends AppGlideModule {
}

View File

@ -0,0 +1,21 @@
package com.readrops.app.utils
import android.content.Context
import com.bumptech.glide.Glide
import com.bumptech.glide.Registry
import com.bumptech.glide.annotation.GlideModule
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader
import com.bumptech.glide.load.model.GlideUrl
import com.bumptech.glide.module.AppGlideModule
import com.readrops.api.utils.HttpManager
import java.io.InputStream
@GlideModule
class ReadropsGlideModule : AppGlideModule() {
override fun registerComponents(context: Context, glide: Glide, registry: Registry) {
val factory = OkHttpUrlLoader.Factory(HttpManager.getInstance().okHttpClient)
glide.registry.replace(GlideUrl::class.java, InputStream::class.java, factory)
}
}