Code example for Bitmap

Methods: getHeightgetRowBytes

0
 * cache.<br /> 
 * <br /> 
 * <b>NOTE:</b> This cache uses strong and weak references for stored Bitmaps. Strong references - for limited count of 
 * Bitmaps (depends on cache size), weak references - for all other cached Bitmaps. 
 * 
 * @author Sergey Tarasevich (nostra13[at]gmail[dot]com) 
 * @since 1.0.0 
 */ 
public class LargestLimitedMemoryCache extends LimitedMemoryCache<String, Bitmap> {
	/** 
	 * Contains strong references to stored objects (keys) and sizes of the objects. If hard cache 
	 * size will exceed limit then object with the largest size is deleted (but it continue exist at 
	 * {@link #softMap} and can be collected by GC at any time) 
	 */ 
	private final Map<Bitmap, Integer> valueSizes = Collections.synchronizedMap(new HashMap<Bitmap, Integer>());
 
	public LargestLimitedMemoryCache(int sizeLimit) {
		super(sizeLimit);
	} 
 
	@Override 
	public boolean put(String key, Bitmap value) {
		if (super.put(key, value)) {
			valueSizes.put(value, getSize(value));
			return true; 
		} else { 
			return false; 
		} 
	} 
 
	@Override 
	public void remove(String key) {
		Bitmap value = super.get(key);
		if (value != null) {
			valueSizes.remove(value);
		}