I need to add headers to Glide requests. I've found that GlideModule could be used for this purpuse.
I'm using OkHttpClient integration to use intercepters and add headers.
But I need to pass parameters to registerComponents method of AppGlideModule.
How could it be done?
My glide version is 4.13.2
My module looks like this:
class MyAppGlideModule : AppGlideModule() {
override fun registerComponents(context: Context, glide: Glide, registry: Registry) {
super.registerComponents(context, glide, registry)
val client = OkHttpClient
.Builder()
.apply {
val loggingInterceptor = HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
}
addInterceptor(loggingInterceptor)
}
.addInterceptor(Interceptor { chain ->
val newRequest = chain
.request()
.newBilder()
.header("X-header-18", <I NEED PARAM HERE>)
.build()
chain.proceed(newRequest)
})
.build()
registry.replace(GlideUrl::class.java, InputStream::class.java, OkHttpUrlLoader.Factory(client))
}
}