I'm writing an Android app and I need to have an offline mode there, that means that I need to download all images from the back-end and in case I have no Internet connection I will be able to show them to the user. I read the official documentation for the caching Glide 4.3.1 and tried to use this code to download:
GlideApp.with(context)
.downloadOnly()
.load(url)
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.submit();
To load image I use:
GlideApp
.with(context)
.load(url)
.error(R.drawable.image_placeholder)
.into(imageView);`
It looks like it works because the space that my app takes increase. But when I try to run my app in offline mode most of the images are skipped and in logs I see the next:
Load failed for myhostname/myfilename.jpg with size [395x485]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, REMOTE
Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
Cause (1 of 1): class java.net.UnknownHostException: Unable to resolve host "cava.cool": No address associated with hostname
Has someone faced with a similar problem?
P.S. When I have network connection it works perfect.