I am using glide to load images from URL. While I am fetching the images I am showing a loader in the image view. Some of the images being fetched are larger and therefore
If you would like to use OkHttp
, please import glide:okhttp-integration
according to this, and then implement your own OkHttpGlideModule
:
@GlideModule
public class CustomGlideModule extends OkHttpGlideModule {
@Override
public void applyOptions(Context context, GlideBuilder builder) {
// stub
}
@Override
public void registerComponents(Context context, Glide glide) {
final OkHttpClient.Builder builder = new OkHttpClient.Builder();
// set your timeout here
builder.readTimeout(30, TimeUnit.SECONDS);
builder.writeTimeout(30, TimeUnit.SECONDS);
builder.connectTimeout(30, TimeUnit.SECONDS);
glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(builder.build()));
}
}