com.bumptech.glide.load.engine.bitmap_recycle
Class BitmapPoolAdapter

java.lang.Object
  extended by com.bumptech.glide.load.engine.bitmap_recycle.BitmapPoolAdapter
All Implemented Interfaces:
BitmapPool

public class BitmapPoolAdapter
extends Object
implements BitmapPool

An BitmapPool implementation that rejects all Bitmaps added to it and always returns null from get.


Constructor Summary
BitmapPoolAdapter()
           
 
Method Summary
 void clearMemory()
          Removes all Bitmaps from the pool.
 Bitmap get(int width, int height, Bitmap.Config config)
          Returns a Bitmap of exactly the given width, height, and configuration, or null if no such Bitmap could be obtained from the pool.
 boolean put(Bitmap bitmap)
          Adds the given Bitmap and returns true if the Bitmap was eligible to be added and false otherwise.
 void setSizeMultiplier(float sizeMultiplier)
          Multiplies the initial size of the pool by the given multipler to dynamically and synchronously allow users to adjust the size of the pool.
 void trimMemory(int level)
          Reduces the size of the cache by evicting items based on the given level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitmapPoolAdapter

public BitmapPoolAdapter()
Method Detail

setSizeMultiplier

public void setSizeMultiplier(float sizeMultiplier)
Description copied from interface: BitmapPool
Multiplies the initial size of the pool by the given multipler to dynamically and synchronously allow users to adjust the size of the pool.

If the current total size of the pool is larger than the max size after the given multiplier is applied, Bitmaps should be evicted until the pool is smaller than the new max size.

Specified by:
setSizeMultiplier in interface BitmapPool
Parameters:
sizeMultiplier - The size multiplier to apply between 0 and 1.

put

public boolean put(Bitmap bitmap)
Description copied from interface: BitmapPool
Adds the given Bitmap and returns true if the Bitmap was eligible to be added and false otherwise.

Note - If the Bitmap is rejected (this method returns false) then it is the caller's responsibility to call Bitmap.recycle().

Note - This method will return true if the given Bitmap is synchronously evicted after being accepted. The only time this method will return false is if the Bitmap is not eligible to be added to the pool (either it is not mutable or it is larger than the max pool size).

Specified by:
put in interface BitmapPool
Parameters:
bitmap - The Bitmap to attempt to add.
See Also:
Bitmap.isMutable(), Bitmap.recycle()

get

public Bitmap get(int width,
                  int height,
                  Bitmap.Config config)
Description copied from interface: BitmapPool
Returns a Bitmap of exactly the given width, height, and configuration, or null if no such Bitmap could be obtained from the pool.

Specified by:
get in interface BitmapPool
Parameters:
width - The width of the desired Bitmap.
height - The height of the desired Bitmap.
config - The Bitmap.Config of the desired Bitmap.

clearMemory

public void clearMemory()
Description copied from interface: BitmapPool
Removes all Bitmaps from the pool.

Specified by:
clearMemory in interface BitmapPool

trimMemory

public void trimMemory(int level)
Description copied from interface: BitmapPool
Reduces the size of the cache by evicting items based on the given level.

Specified by:
trimMemory in interface BitmapPool
Parameters:
level - The level from ComponentCallbacks2 to use to determine how many Bitmaps to evict.
See Also:
ComponentCallbacks2