fikisipi / SmartCache

A library for preloaded Retrofit responses.
Apache License 2.0
78 stars 16 forks source link

Any way to force refresh? #10

Open gregdev opened 5 years ago

gregdev commented 5 years ago

Is there any way to force a particular URL to be fetched from the web again and update the cache with the result, or to purge a URL from the cache?

My app includes pull down to refresh - when this is used I'd like to invalidate the cache, fetch data from the server, and update the cache with the new data.

marutichintan commented 5 years ago

public void onResponse(Call<List<Brand>> call, Response<List<Brand>> response) { if(!response.raw().request().url().host().equalsIgnoreCase("localhost")) { //from Cache }else{ //from server } }

fikisipi commented 3 years ago

Hey, I added a way to check if cache is used: SmartCache.isResponseFromNetwork() that you can use in your callback. Cache can be cleared as well, you can check the new demo app I added.

To install the new version change the implementation line in Gradle, as mentioned in the README. The username/owner of the repo is changed as well.