Tabnine Logo
DiskCache.get
Code IndexAdd Tabnine to your IDE (free)

How to use
get
method
in
com.bumptech.glide.load.engine.cache.DiskCache

Best Java code snippets using com.bumptech.glide.load.engine.cache.DiskCache.get (Showing top 16 results out of 315)

origin: bumptech/glide

@Test
public void get_afterDeleteDirectoryOutsideGlideAndClose_doesNotThrow() {
 DiskCache cache = DiskLruCacheWrapper.create(cacheDir, 1024 * 1024);
 cache.get(mock(Key.class));
 deleteRecursively(cacheDir);
 cache.clear();
 cache.get(mock(Key.class));
}
origin: bumptech/glide

 @Test
 public void get_afterDeleteDirectoryOutsideGlideAndClose_doesNotThrow() {
  assumeTrue("A file handle is likely open, so cannot delete dir", !Util.isWindows());
  DiskCache cache = DiskLruCacheWrapper.create(dir, 1024 * 1024);
  cache.get(mock(Key.class));
  deleteRecursive(dir);
  cache.clear();

  cache.get(mock(Key.class));
 }
}
origin: bumptech/glide

@Test
public void testDoesNotCommitIfWriterReturnsFalse() {
 cache.put(key, new DiskCache.Writer() {
  @Override
  public boolean write(@NonNull File file) {
   return false;
  }
 });
 assertNull(cache.get(key));
}
origin: bumptech/glide

@Test
public void clearDiskCache_afterOpeningDiskCache_andDeleteDirectoryOutsideGlide_doesNotThrow() {
 DiskCache cache = DiskLruCacheWrapper.create(cacheDir, 1024 * 1024);
 cache.get(mock(Key.class));
 deleteRecursively(cacheDir);
 cache.clear();
}
origin: bumptech/glide

@Test
public void testDoesNotCommitIfWriterWritesButReturnsFalse() {
 cache.put(key, new DiskCache.Writer() {
  @Override
  public boolean write(@NonNull File file) {
   try {
    Util.writeFile(file, data);
   } catch (IOException e) {
    fail(e.toString());
   }
   return false;
  }
 });
 assertNull(cache.get(key));
}
origin: bumptech/glide

cacheFile = helper.getDiskCache().get(originalKey);
if (cacheFile != null) {
 this.sourceKey = sourceId;
origin: bumptech/glide

@Test
public void clearDiskCache_afterOpeningDiskCache_andDeleteDirectoryOutsideGlide_doesNotThrow() {
 assumeTrue("A file handle is likely open, so cannot delete dir", !Util.isWindows());
 DiskCache cache = DiskLruCacheWrapper.create(dir, 1024 * 1024);
 cache.get(mock(Key.class));
 deleteRecursive(dir);
 cache.clear();
}
origin: bumptech/glide

    resourceClass,
    helper.getOptions());
cacheFile = helper.getDiskCache().get(currentKey);
if (cacheFile != null) {
 sourceKey = sourceId;
origin: bumptech/glide

@Test
public void testCanInsertAndGet() throws IOException {
 cache.put(key, new DiskCache.Writer() {
  @Override
  public boolean write(@NonNull File file) {
   try {
    Util.writeFile(file, data);
   } catch (IOException e) {
    fail(e.toString());
   }
   return true;
  }
 });
 byte[] received = Util.readFile(cache.get(key), data.length);
 assertArrayEquals(data, received);
}
origin: bumptech/glide

@Test
public void loadFromCache_afterDiskCacheDeleted_doesNotFail() {
 final DiskCache cache = DiskLruCacheWrapper.create(cacheDir, 1024 * 1024);
 cache.get(mock(Key.class));
 deleteRecursively(cacheDir);
 Glide.init(
   context,
   new GlideBuilder()
     .setDiskCache(new Factory() {
      @Override
      public DiskCache build() {
       return cache;
      }
     }));
 Drawable drawable =
   concurrency.get(Glide.with(context)
     .load(raw.canonical)
     .submit());
 assertThat(drawable).isNotNull();
}
origin: bumptech/glide

@Test
public void testEditIsAbortedIfWriterThrows() throws IOException {
 try {
  cache.put(key, new DiskCache.Writer() {
   @Override
   public boolean write(@NonNull File file) {
    throw new RuntimeException("test");
   }
  });
 } catch (RuntimeException e) {
  // Expected.
 }
 cache.put(key, new DiskCache.Writer() {
  @Override
  public boolean write(@NonNull File file) {
   try {
    Util.writeFile(file, data);
   } catch (IOException e) {
    fail(e.toString());
   }
   return true;
  }
 });
 byte[] received = Util.readFile(cache.get(key), data.length);
 assertArrayEquals(data, received);
}
origin: bumptech/glide

@Test
public void loadFromCache_afterDiskCacheDeletedAndCleared_doesNotFail() {
 final DiskCache cache = DiskLruCacheWrapper.create(cacheDir, 1024 * 1024);
 cache.get(mock(Key.class));
 deleteRecursively(cacheDir);
 cache.clear();
 Glide.init(
   context,
   new GlideBuilder()
     .setDiskCache(new Factory() {
      @Override
      public DiskCache build() {
       return cache;
      }
     }));
 Drawable drawable =
   concurrency.get(
     Glide.with(context)
       .load(ResourceIds.raw.canonical)
       .submit());
 assertThat(drawable).isNotNull();
}
origin: guolindev/giffun

  public <Z> Resource<Z> load(Key key, ResourceDecoder<File, Z> decoder, int width, int height) {
    File fromCache = diskCache.get(key);
    if (fromCache == null) {
      return null;
    }

    Resource<Z> result = null;
    try {
      result = decoder.decode(fromCache, width, height);
    } catch (IOException e) {
      if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Exception decoding image from cache", e);
      }
    }
    if (result == null) {
      if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Failed to decode image from cache or not present in cache");
      }
      diskCache.delete(key);
    }
    return result;
  }
}
origin: guolindev/giffun

private Resource<T> loadFromCache(Key key) throws IOException {
  File cacheFile = diskCacheProvider.getDiskCache().get(key);
  if (cacheFile == null) {
    return null;
  }
  Resource<T> result = null;
  try {
    result = loadProvider.getCacheDecoder().decode(cacheFile, width, height);
  } finally {
    if (result == null) {
      diskCacheProvider.getDiskCache().delete(key);
    }
  }
  return result;
}
origin: mozilla-tw/Rocket

@Override
public boolean startNext() {
 while (modelLoaders == null || !hasNextModelLoader()) {
  sourceIdIndex++;
  if (sourceIdIndex >= cacheKeys.size()) {
   return false;
  }
  Key sourceId = cacheKeys.get(sourceIdIndex);
  Key originalKey = new DataCacheKey(sourceId, helper.getSignature());
  cacheFile = helper.getDiskCache().get(originalKey);
  if (cacheFile != null) {
   this.sourceKey = sourceId;
   modelLoaders = helper.getModelLoaders(cacheFile);
   modelLoaderIndex = 0;
  }
 }
 loadData = null;
 boolean started = false;
 while (!started && hasNextModelLoader()) {
  ModelLoader<File, ?> modelLoader = modelLoaders.get(modelLoaderIndex++);
  loadData =
    modelLoader.buildLoadData(cacheFile, helper.getWidth(), helper.getHeight(),
      helper.getOptions());
  if (loadData != null && helper.hasLoadPath(loadData.fetcher.getDataClass())) {
   started = true;
   loadData.fetcher.loadData(helper.getPriority(), this);
  }
 }
 return started;
}
origin: mozilla-tw/Rocket

cacheFile = helper.getDiskCache().get(currentKey);
if (cacheFile != null) {
 this.sourceKey = sourceId;
com.bumptech.glide.load.engine.cacheDiskCacheget

Javadoc

Get the cache for the value at the given key.

Note - This is potentially dangerous, someone may write a new value to the file at any point in time and we won't know about it.

Popular methods of DiskCache

  • clear
    Clear the cache.
  • put
    Write to a key in the cache. Writer is used so that the cache implementation can perform actions aft
  • delete
    Remove the key and value from the cache.

Popular in Java

  • Reactive rest calls using spring rest template
  • compareTo (BigDecimal)
  • getSharedPreferences (Context)
  • getContentResolver (Context)
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • JButton (javax.swing)
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now