Customize Glide Network Timeouts on Android
build.gradle
implementation 'com.squareup.okhttp3:okhttp:3.12.0' implementation "com.github.bumptech.glide:okhttp3-integration:4.9.0" annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
create a new GlideModule
@GlideModule public class CustomTimeOutOkHttpGlideModule extends LibraryGlideModule { @Override public void registerComponents(Context context, Glide glide, Registry registry) { OkHttpClient.Builder builder = new OkHttpClient.Builder(); // customize connection timeouts here // ... OkHttpClient okHttpClient = builder.build(); registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(okHttpClient)); } }
References
https://futurestud.io/tutorials/glide-4-customize-network-timeouts
https://futurestud.io/tutorials/glide-module-example-accepting-self-signed-https-certificates
https://bumptech.github.io/glide/int/okhttp3.html