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

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

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

origin: bumptech/glide

private long getFreeMemoryCacheBytes() {
 return memoryCache.getMaxSize() - memoryCache.getCurrentSize();
}
origin: bumptech/glide

@VisibleForTesting
PreFillQueue generateAllocationOrder(PreFillType... preFillSizes) {
 final long maxSize =
   memoryCache.getMaxSize() - memoryCache.getCurrentSize() + bitmapPool.getMaxSize();
 int totalWeight = 0;
 for (PreFillType size : preFillSizes) {
  totalWeight += size.getWeight();
 }
 final float bytesPerWeight = maxSize / (float) totalWeight;
 Map<PreFillType, Integer> attributeToCount = new HashMap<>();
 for (PreFillType size : preFillSizes) {
  int bytesForSize = Math.round(bytesPerWeight * size.getWeight());
  int bytesPerBitmap = getSizeInBytes(size);
  int bitmapsForSize = bytesForSize / bytesPerBitmap;
  attributeToCount.put(size, bitmapsForSize);
 }
 return new PreFillQueue(attributeToCount);
}
origin: bumptech/glide

@Before
public void setUp() {
 MockitoAnnotations.initMocks(this);
 when(pool.getMaxSize()).thenReturn(poolSize);
 when(pool.getDirty(anyInt(), anyInt(), any(Bitmap.Config.class)))
   .thenAnswer(new CreateBitmap());
 when(cache.getMaxSize()).thenReturn(cacheSize);
 bitmapPreFiller = new BitmapPreFiller(cache, pool, DecodeFormat.DEFAULT);
}
origin: bumptech/glide

@Test
public void testAddsBitmapsToMemoryCacheIfMemoryCacheHasEnoughSpaceRemaining() {
 Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
 when(cache.getMaxSize()).thenReturn(Long.valueOf(Util.getBitmapByteSize(bitmap)));
 PreFillType size =
   new PreFillType.Builder(bitmap.getWidth(), bitmap.getHeight()).setConfig(bitmap.getConfig())
     .build();
 Map<PreFillType, Integer> allocationOrder = new HashMap<>();
 allocationOrder.put(size, 1);
 getHandler(allocationOrder).run();
 verify(cache).put(any(Key.class), anyResource());
 verify(pool, never()).put(any(Bitmap.class));
 // TODO(b/20335397): This code was relying on Bitmap equality which Robolectric removed
 // assertThat(addedBitmaps).containsExactly(bitmap);
}
origin: bumptech/glide

@Test
public void testAddsBitmapsToBitmapPoolIfMemoryCacheIsFull() {
 Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
 when(cache.getMaxSize()).thenReturn(0L);
 PreFillType size =
   new PreFillType.Builder(bitmap.getWidth(), bitmap.getHeight()).setConfig(bitmap.getConfig())
     .build();
 Map<PreFillType, Integer> allocationOrder = new HashMap<>();
 allocationOrder.put(size, 1);
 getHandler(allocationOrder).run();
 verify(cache, never()).put(any(Key.class), anyResource());
 // TODO(b/20335397): This code was relying on Bitmap equality which Robolectric removed
 // verify(pool).put(eq(bitmap));
 // assertThat(addedBitmaps).containsExactly(bitmap);
}
origin: bumptech/glide

@Test
public void testAddsBitmapsToPoolIfMemoryCacheIsNotFullButCannotFitBitmap() {
 Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
 when(cache.getMaxSize()).thenReturn((long) Util.getBitmapByteSize(bitmap) / 2);
 PreFillType size =
   new PreFillType.Builder(bitmap.getWidth(), bitmap.getHeight()).setConfig(bitmap.getConfig())
     .build();
 Map<PreFillType, Integer> allocationOrder = new HashMap<>();
 allocationOrder.put(size, 1);
 getHandler(allocationOrder).run();
 verify(cache, never()).put(any(Key.class), anyResource());
 // TODO(b/20335397): This code was relying on Bitmap equality which Robolectric removed
 //verify(pool).put(eq(bitmap));
 //assertThat(addedBitmaps).containsExactly(bitmap);
}
origin: bumptech/glide

@Test
public void testAllocationOrderRoundRobinsDifferentSizes() {
 when(pool.getMaxSize()).thenReturn(defaultBitmapSize);
 when(cache.getMaxSize()).thenReturn(defaultBitmapSize);
 PreFillType smallWidth =
   new PreFillType.Builder(DEFAULT_BITMAP_WIDTH / 2, DEFAULT_BITMAP_HEIGHT)
     .setConfig(defaultBitmapConfig).build();
 PreFillType smallHeight =
   new PreFillType.Builder(DEFAULT_BITMAP_WIDTH, DEFAULT_BITMAP_HEIGHT / 2)
     .setConfig(defaultBitmapConfig).build();
 PreFillQueue allocationOrder = bitmapPreFiller.generateAllocationOrder(smallWidth, smallHeight);
 List<PreFillType> attributes = new ArrayList<>();
 while (!allocationOrder.isEmpty()) {
  attributes.add(allocationOrder.remove());
 }
 // Either width, height, width, height or height, width, height, width.
 try {
  assertThat(attributes).containsExactly(smallWidth, smallHeight, smallWidth, smallHeight)
    .inOrder();
 } catch (AssertionError e) {
  assertThat(attributes).containsExactly(smallHeight, smallWidth, smallHeight, smallWidth)
    .inOrder();
 }
}
origin: guolindev/giffun

private int getFreeMemoryCacheBytes() {
  return memoryCache.getMaxSize() - memoryCache.getCurrentSize();
}
origin: palaima/DebugDrawer

private void refresh() {
  final BitmapPool pool = glide.getBitmapPool();
  final String total = getSizeString(pool.getMaxSize());
  final String memCacheCurrent = getSizeString(memoryCache.getCurrentSize());
  final String memCacheMax = getSizeString(memoryCache.getMaxSize());
  poolSizeLabel.setText(total);
  memCacheCurrentLabel.setText(memCacheCurrent);
  memCacheMaxLabel.setText(memCacheMax);
}
origin: guolindev/giffun

PreFillQueue generateAllocationOrder(PreFillType[] preFillSizes) {
  final int maxSize = memoryCache.getMaxSize() - memoryCache.getCurrentSize() + bitmapPool.getMaxSize();
  int totalWeight = 0;
  for (PreFillType size : preFillSizes) {
    totalWeight += size.getWeight();
  }
  final float bytesPerWeight = maxSize / (float) totalWeight;
  Map<PreFillType, Integer> attributeToCount = new HashMap<PreFillType, Integer>();
  for (PreFillType size : preFillSizes) {
    int bytesForSize = Math.round(bytesPerWeight * size.getWeight());
    int bytesPerBitmap = getSizeInBytes(size);
    int bitmapsForSize = bytesForSize / bytesPerBitmap;
    attributeToCount.put(size, bitmapsForSize);
  }
  return new PreFillQueue(attributeToCount);
}
origin: mozilla-tw/Rocket

private int getFreeMemoryCacheBytes() {
 return memoryCache.getMaxSize() - memoryCache.getCurrentSize();
}
origin: mozilla-tw/Rocket

PreFillQueue generateAllocationOrder(PreFillType... preFillSizes) {
 final int maxSize =
   memoryCache.getMaxSize() - memoryCache.getCurrentSize() + bitmapPool.getMaxSize();
 int totalWeight = 0;
 for (PreFillType size : preFillSizes) {
  totalWeight += size.getWeight();
 }
 final float bytesPerWeight = maxSize / (float) totalWeight;
 Map<PreFillType, Integer> attributeToCount = new HashMap<>();
 for (PreFillType size : preFillSizes) {
  int bytesForSize = Math.round(bytesPerWeight * size.getWeight());
  int bytesPerBitmap = getSizeInBytes(size);
  int bitmapsForSize = bytesForSize / bytesPerBitmap;
  attributeToCount.put(size, bitmapsForSize);
 }
 return new PreFillQueue(attributeToCount);
}
com.bumptech.glide.load.engine.cacheMemoryCachegetMaxSize

Javadoc

Returns the current maximum size in bytes of the cache.

Popular methods of MemoryCache

  • 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.
  • 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

  • Reading from database using SQL prepared statement
  • getContentResolver (Context)
  • findViewById (Activity)
  • scheduleAtFixedRate (Timer)
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top 17 PhpStorm 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