Class SizeConfigStrategy


  • @RequiresApi(19)
    public class SizeConfigStrategy
    extends java.lang.Object
    Keys Bitmaps using both Bitmap.getAllocationByteCount() and the Bitmap.Config returned from Bitmap.getConfig().

    Using both the config and the byte size allows us to safely re-use a greater variety of Bitmaps, which increases the hit rate of the pool and therefore the performance of applications. This class works around #301 by only allowing re-use of Bitmaps with a matching number of bytes per pixel.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      android.graphics.Bitmap get​(int width, int height, android.graphics.Bitmap.Config config)  
      int getSize​(android.graphics.Bitmap bitmap)  
      java.lang.String logBitmap​(int width, int height, android.graphics.Bitmap.Config config)  
      java.lang.String logBitmap​(android.graphics.Bitmap bitmap)  
      void put​(android.graphics.Bitmap bitmap)  
      android.graphics.Bitmap removeLast()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • SizeConfigStrategy

        public SizeConfigStrategy()
    • Method Detail

      • put

        public void put​(android.graphics.Bitmap bitmap)
      • get

        @Nullable
        public android.graphics.Bitmap get​(int width,
                                           int height,
                                           android.graphics.Bitmap.Config config)
      • removeLast

        @Nullable
        public android.graphics.Bitmap removeLast()
      • logBitmap

        public java.lang.String logBitmap​(android.graphics.Bitmap bitmap)
      • logBitmap

        public java.lang.String logBitmap​(int width,
                                          int height,
                                          android.graphics.Bitmap.Config config)
      • getSize

        public int getSize​(android.graphics.Bitmap bitmap)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object