@Override public void shutdown() { if (!sharedClient) { com.squareup.okhttp.Cache cache = client.getCache(); if (cache != null) { try { cache.close(); } catch (IOException ignored) { } } } }
private void refreshOkHttpCacheStats() { Cache cache = client.getCache(); // Shares the cache with apiClient, so no need to check both. int writeTotal = cache.getWriteSuccessCount() + cache.getWriteAbortCount(); int percentage = (int) ((1f * cache.getWriteAbortCount() / writeTotal) * 100); okHttpCacheWriteErrorView.setText( cache.getWriteAbortCount() + " / " + writeTotal + " (" + percentage + "%)"); okHttpCacheRequestCountView.setText(String.valueOf(cache.getRequestCount())); okHttpCacheNetworkCountView.setText(String.valueOf(cache.getNetworkCount())); okHttpCacheHitCountView.setText(String.valueOf(cache.getHitCount())); }
private void setupOkHttpCacheSection() { Cache cache = client.getCache(); // Shares the cache with apiClient, so no need to check both. okHttpCacheMaxSizeView.setText(getSizeString(cache.getMaxSize())); refreshOkHttpCacheStats(); }