예제 #1
0
 @Override
 public void shutdown() {
   if (!sharedClient) {
     com.squareup.okhttp.Cache cache = client.getCache();
     if (cache != null) {
       try {
         cache.close();
       } catch (IOException ignored) {
       }
     }
   }
 }
예제 #2
0
 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()));
 }
예제 #3
0
  private void setupOkHttpCacheSection() {
    Cache cache = client.getCache(); // Shares the cache with apiClient, so no need to check both.
    okHttpCacheMaxSizeView.setText(getSizeString(cache.getMaxSize()));

    refreshOkHttpCacheStats();
  }