Tabnine Logo
MemoryCache.remove
Code IndexAdd Tabnine to your IDE (free)

How to use
remove
method
in
com.bumptech.glide.load.engine.cache.MemoryCache

Best Java code snippets using com.bumptech.glide.load.engine.cache.MemoryCache.remove (Showing top 12 results out of 315)

origin: bumptech/glide

private EngineResource<?> getEngineResourceFromCache(Key key) {
 Resource<?> cached = cache.remove(key);
 final EngineResource<?> result;
 if (cached == null) {
  result = null;
 } else if (cached instanceof EngineResource) {
  // Save an object allocation if we've cached an EngineResource (the typical case).
  result = (EngineResource<?>) cached;
 } else {
  result = new EngineResource<>(cached, true /*isMemoryCacheable*/, true /*isRecyclable*/);
 }
 return result;
}
origin: bumptech/glide

@Test
public void testResourceIsReturnedFromCacheIfPresent() {
 when(harness.cache.remove(eq(harness.cacheKey))).thenReturn(harness.resource);
 harness.doLoad();
 verify(harness.cb).onResourceReady(eq(harness.resource), eq(DataSource.MEMORY_CACHE));
}
origin: bumptech/glide

@Test
public void testCacheIsCheckedIfMemoryCacheable() {
 when(harness.cache.remove(eq(harness.cacheKey))).thenReturn(harness.resource);
 harness.doLoad();
 verify(harness.cb).onResourceReady(eq(harness.resource), eq(DataSource.MEMORY_CACHE));
}
origin: bumptech/glide

@Test
public void testNewLoadIsNotStartedIfResourceIsCached() {
 when(harness.cache.remove(eq(harness.cacheKey))).thenReturn(harness.resource);
 harness.doLoad();
 verify(harness.job, never()).start(any(DecodeJob.class));
}
origin: bumptech/glide

@Test
public void testCacheIsNotCheckedIfNotMemoryCacheable() {
 when(harness.cache.remove(eq(harness.cacheKey))).thenReturn(harness.resource);
 harness.isMemoryCacheable = false;
 harness.doLoad();
 verify(harness.job).start((DecodeJob) any());
}
origin: bumptech/glide

@Test
public void testResourceIsAcquiredIfReturnedFromCache() {
 when(harness.cache.remove(eq(harness.cacheKey))).thenReturn(harness.resource);
 harness.doLoad();
 verify(harness.resource).acquire();
}
origin: bumptech/glide

@Test
public void load_withResourceInActiveResources_doesNotCheckMemoryCache() {
 harness.activeResources.activate(harness.cacheKey, harness.resource);
 harness.doLoad();
 verify(harness.cb).onResourceReady(eq(harness.resource), eq(DataSource.MEMORY_CACHE));
 verify(harness.cache, never()).remove(any(Key.class));
}
origin: bumptech/glide

@Test
public void testNullLoadStatusIsReturnedForCachedResource() {
 when(harness.cache.remove(eq(harness.cacheKey))).thenReturn(harness.resource);
 Engine.LoadStatus loadStatus = harness.doLoad();
 assertNull(loadStatus);
}
origin: bumptech/glide

@Test
public void testResourceIsAddedToActiveResourceIfReturnedFromCache() {
 when(harness.cache.remove(eq(harness.cacheKey))).thenReturn(harness.resource);
 harness.doLoad();
 EngineResource<?> activeResource = harness.activeResources.get(harness.cacheKey);
 assertThat(activeResource).isEqualTo(harness.resource);
}
origin: bumptech/glide

@Test
public void testHandlesNonEngineResourcesFromCacheIfPresent() {
 final Object expected = new Object();
 @SuppressWarnings("rawtypes") Resource fromCache = mockResource();
 when(fromCache.get()).thenReturn(expected);
 when(harness.cache.remove(eq(harness.cacheKey))).thenReturn(fromCache);
 doAnswer(
     new Answer<Void>() {
      @Override
      public Void answer(InvocationOnMock invocationOnMock) {
       Resource<?> resource = (Resource<?>) invocationOnMock.getArguments()[0];
       assertEquals(expected, resource.get());
       return null;
      }
     })
   .when(harness.cb)
   .onResourceReady(anyResource(), isADataSource());
 harness.doLoad();
 verify(harness.cb).onResourceReady(anyResource(), isADataSource());
}
origin: guolindev/giffun

@SuppressWarnings("unchecked")
private EngineResource<?> getEngineResourceFromCache(Key key) {
  Resource<?> cached = cache.remove(key);
  final EngineResource result;
  if (cached == null) {
    result = null;
  } else if (cached instanceof EngineResource) {
    // Save an object allocation if we've cached an EngineResource (the typical case).
    result = (EngineResource) cached;
  } else {
    result = new EngineResource(cached, true /*isCacheable*/);
  }
  return result;
}
origin: mozilla-tw/Rocket

@SuppressWarnings("unchecked")
private EngineResource<?> getEngineResourceFromCache(Key key) {
 Resource<?> cached = cache.remove(key);
 final EngineResource<?> result;
 if (cached == null) {
  result = null;
 } else if (cached instanceof EngineResource) {
  // Save an object allocation if we've cached an EngineResource (the typical case).
  result = (EngineResource<?>) cached;
 } else {
  result = new EngineResource<>(cached, true /*isMemoryCacheable*/);
 }
 return result;
}
com.bumptech.glide.load.engine.cacheMemoryCacheremove

Javadoc

Removes the value for the given key and returns it if present or null otherwise.

Popular methods of MemoryCache

  • getMaxSize
    Returns the current maximum size in bytes of the cache.
  • clearMemory
    Evict all items from the memory cache.
  • getCurrentSize
    Returns the sum of the sizes of all the contents of the cache in bytes.
  • put
    Add bitmap to the cache with the given key.
  • setResourceRemovedListener
    Set the listener to be called when a bitmap is removed from the cache.
  • setSizeMultiplier
    Adjust the maximum size of the cache by multiplying the original size of the cache by the given mult
  • trimMemory
    Trim the memory cache to the appropriate level. Typically called on the callback onTrimMemory.

Popular in Java

  • Parsing JSON documents to java classes using gson
  • onCreateOptionsMenu (Activity)
  • requestLocationUpdates (LocationManager)
  • startActivity (Activity)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • Permission (java.security)
    Legacy security code; do not use.
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • PhpStorm for WordPress
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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