Exemplo n.º 1
0
 @Override
 public void shutdown() {
   if (!sharedClient) {
     com.squareup.okhttp.Cache cache = client.getCache();
     if (cache != null) {
       try {
         cache.close();
       } catch (IOException ignored) {
       }
     }
   }
 }
Exemplo n.º 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()));
 }
Exemplo n.º 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();
  }