public class

BitmapCounter

extends Object
java.lang.Object
   ↳ com.facebook.imagepipeline.memory.BitmapCounter

Class Overview

Counts bitmaps - keeps track of both, count and total size in bytes.

Summary

Public Constructors
BitmapCounter(int maxCount, int maxSize)
Public Methods
List<CloseableReference<Bitmap>> associateBitmapsWithBitmapCounter(List<Bitmap> bitmaps)
Associates bitmaps with the bitmap counter.
synchronized void decrease(Bitmap bitmap)
Excludes given bitmap from the count.
synchronized int getCount()
ResourceReleaser<Bitmap> getReleaser()
synchronized long getSize()
synchronized boolean increase(Bitmap bitmap)
Includes given bitmap in the bitmap count.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public BitmapCounter (int maxCount, int maxSize)

Public Methods

public List<CloseableReference<Bitmap>> associateBitmapsWithBitmapCounter (List<Bitmap> bitmaps)

Associates bitmaps with the bitmap counter.

If this method throws TooManyBitmapsException, the code will have called recycle() on the bitmaps.

Parameters
bitmaps the bitmaps to associate
Returns
  • the references to the bitmaps that are now tied to the bitmap pool
Throws
TooManyBitmapsException if the pool is full

public synchronized void decrease (Bitmap bitmap)

Excludes given bitmap from the count.

Parameters
bitmap to be excluded from the count

public synchronized int getCount ()

Returns
  • number of counted bitmaps

public ResourceReleaser<Bitmap> getReleaser ()

public synchronized long getSize ()

Returns
  • total size in bytes of counted bitmaps

public synchronized boolean increase (Bitmap bitmap)

Includes given bitmap in the bitmap count. The bitmap is included only if doing so does not violate configured limit

Parameters
bitmap to include in the count
Returns
  • true if and only if bitmap is successfully included in the count