fikisipi / SmartCache

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

Provide a sample implementation #7

Closed peter1408 closed 3 years ago

peter1408 commented 6 years ago

I referred to this sample project of yours link

but how am I able to check if the value is loaded from the cache before the network response is rendered..

how to know if the response is the cache value or a network response???

fikisipi commented 6 years ago

There's no way of checking that; it's a huge problem, I agree.

andreyrd commented 6 years ago

Cached responses will have the request URL set to http://localhost/! You can simply check if response.raw().request().url().host() == 'localhost' to see if it's a cached value.

fikisipi commented 3 years ago

@peter1408 @andreyrd I added a function for checking which response is rendered, as well as a function for deleting cache. I added a new demo app as well.

To install the new version change the implementation line in Gradle, as mentioned in the README. The demo app is in the base folder as well.