congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
MemoryCache.setResourceRemovedListener
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: bumptech/glide

@Test
public void testEngineAddedAsListenerToMemoryCache() {
 harness.getEngine();
 verify(harness.cache).setResourceRemovedListener(eq(harness.getEngine()));
}
origin: bumptech/glide

cache.setResourceRemovedListener(this);
origin: bumptech/glide

@Test
public void testPreventEviction() {
 final MemoryCache cache = new LruResourceCache(100);
 final Resource<?> first = getResource(30);
 final Key firstKey = new MockKey();
 cache.put(firstKey, first);
 Resource<?> second = getResource(30);
 Key secondKey = new MockKey();
 cache.put(secondKey, second);
 Resource<?> third = getResource(30);
 Key thirdKey = new MockKey();
 cache.put(thirdKey, third);
 cache.setResourceRemovedListener(new ResourceRemovedListener() {
  @Override
  public void onResourceRemoved(@NonNull Resource<?> removed) {
   if (removed == first) {
    cache.put(firstKey, first);
   }
  }
 });
 // trims from 100 to 50, having 30+30+30 items, it should trim to 1 item
 cache.trimMemory(ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN);
 // and that 1 item must be first, because it's forced to return to cache in the listener
 @SuppressWarnings("unchecked")
 LruCache<Key, Resource<?>> lruCache = (LruCache<Key, Resource<?>>) cache;
 assertTrue(lruCache.contains(firstKey));
 assertFalse(lruCache.contains(secondKey));
 assertFalse(lruCache.contains(thirdKey));
}
origin: guolindev/giffun

Engine(MemoryCache cache, DiskCache.Factory diskCacheFactory, ExecutorService diskCacheService,
    ExecutorService sourceService, Map<Key, EngineJob> jobs, EngineKeyFactory keyFactory,
    Map<Key, WeakReference<EngineResource<?>>> activeResources, EngineJobFactory engineJobFactory,
    ResourceRecycler resourceRecycler) {
  this.cache = cache;
  this.diskCacheProvider = new LazyDiskCacheProvider(diskCacheFactory);
  if (activeResources == null) {
    activeResources = new HashMap<Key, WeakReference<EngineResource<?>>>();
  }
  this.activeResources = activeResources;
  if (keyFactory == null) {
    keyFactory = new EngineKeyFactory();
  }
  this.keyFactory = keyFactory;
  if (jobs == null) {
    jobs = new HashMap<Key, EngineJob>();
  }
  this.jobs = jobs;
  if (engineJobFactory == null) {
    engineJobFactory = new EngineJobFactory(diskCacheService, sourceService, this);
  }
  this.engineJobFactory = engineJobFactory;
  if (resourceRecycler == null) {
    resourceRecycler = new ResourceRecycler();
  }
  this.resourceRecycler = resourceRecycler;
  cache.setResourceRemovedListener(this);
}
origin: mozilla-tw/Rocket

cache.setResourceRemovedListener(this);
com.bumptech.glide.load.engine.cacheMemoryCachesetResourceRemovedListener

Javadoc

Set the listener to be called when a bitmap is removed from the cache.

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.
  • remove
    Removes the value for the given key and returns it if present or null otherwise.
  • 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

  • Finding current android device location
  • addToBackStack (FragmentTransaction)
  • getResourceAsStream (ClassLoader)
  • onCreateOptionsMenu (Activity)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top 15 Vim Plugins
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