Retrofit: read from cache on connection timeout

时间:2016-10-15 17:08:21

标签: android http caching retrofit okhttp

Is there a way to read from cache if a connection timeout occurs?

All the cache is working, but it only works if there's no internet.

I already know how to check the timeout exception:

@Override
public void onFailure(Call call, Throwable t) {
    if(t instanceof SocketTimeoutException){
        // I want to load from cache here.
    }
}

0 个答案:

没有答案