package net.x4a42.volksempfaenger.misc;

import java.util.Map;

import android.graphics.Bitmap;
import android.util.LruCache;

public class BitmapCache extends LruCache<Long, Bitmap> {

	public BitmapCache(int maxSize) {
		super(maxSize);
	}

	@Override
	protected int sizeOf(Long key, Bitmap value) {
		return value.getByteCount();
	}

	public void trimToSize(int maxSize) {
		Map<Long, Bitmap> snapshot = snapshot();
		while (size() > maxSize) {
			for (Long key : snapshot.keySet()) {
				remove(key);
			}
		}
	}
}

@@ -38,31 +38,8 @@
 c;%0A%0A
-import java.util.Map;%0A%0A
 impo
@@ -352,119 +352,90 @@
 %7B%0A%09%09
-Map%3CLong, Bitmap%3E snapshot = snapshot();%0A%09%09while (size() %3E maxSize) %7B%0A%09%09%09for (Long key : snapshot.keySet()) %7B%0A%09
+for (Long key : snapshot().keySet()) %7B%0A%09%09%09if (size() %3E maxSize) %7B%0A%09%09%09%09break;%0A%09%09%09%7D%0A
 %09%09%09r
@@ -446,21 +446,16 @@
 e(key);%0A
-%09%09%09%7D%0A
 %09%09%7D%0A%09%7D%0A%7D

Fix BitmapCache.trimToSize()