Add mechanism to register image caches and flush them all on GUI size change

This should avoid the issue of having lots of unused entries in caches if the
GUI size is changed multiple times.
This commit is contained in:
draxdyn 2016-06-01 19:32:49 +02:00
parent 415c8cce7e
commit 1999dfe5c0
2 changed files with 36 additions and 0 deletions

View file

@ -0,0 +1,34 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.client.util;
import java.util.Map;
import java.util.Vector;
/**
*
* @author user
*/
public class ImageCaches {
private static Vector<Map> IMAGE_CACHES;
static {
IMAGE_CACHES = new Vector<Map>();
}
public static Map register(Map map)
{
IMAGE_CACHES.add(map);
return map;
}
public static void flush()
{
for (Map map : IMAGE_CACHES) {
map.clear();
}
}
}