I have a home screen and there is a wallpaper that displayed in the background as default.
When launch the app I check with an URL to retrieve the latest wallpaper. I want to just show the latest wallpaper if is cached without showing the default first. I do the check in listener's onResourceReady but it seems to hit the URL if there is no cached image, which causes a white background shown for a short period of time before image is retrieved from the internet. Is there any way to quickly check if the image cached in disk so I can determine if to show the default first? Thanks.
I am using 4.0
onlyRetrieveFromCache(true) + a listener()/custom target?
@TWiStErRob
Yes it works !! The only thing is that I have to instantiate an RequestOptions. Thought I can just call .apply(RequestOptions.onlyRetrieveFromCache()).
Thank you anyway.
You can cache that option in a static constant (you can freeze it as well I think to prevent modification).
Also look at http://bumptech.github.io/glide/doc/generatedapi.html
4.0.0-RC1 can't work with .apply(RequestOptions.onlyRetrieveFromCache())
RequestOptions have no static method onlyRetrieveFromCache.
how can I do with v4?
@musicode Use it like here: https://bumptech.github.io/glide/doc/options.html
Note that if you do this, you'll get "Load failed" log messages at WARN priority. I don't believe there's a way to disable those, short of setting the Glide log level to ERROR or above, as per http://bumptech.github.io/glide/doc/configuration.html#log-level.
Incidentally, for people who are having trouble finding it, you want .apply(new RequestOptions().onlyRetrieveFromCache(true)).
In case of cache miss, would the error listener/target be invoked synchronously?
onlyRetrieveFromCache(true)+ alistener()/custom target?
can you please give example how to attach custom target
is there any synchronous method to check if image exists in cache please help
Most helpful comment
onlyRetrieveFromCache(true)+ alistener()/custom target?