Created
August 4, 2014 16:44
-
-
Save xrigau/efe694ec0a9e976b4c26 to your computer and use it in GitHub Desktop.
Simple Image cache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ImageCache implements Map<String, Bitmap> { | |
private final Map<String, Bitmap> cache = new HashMap<String, Bitmap>(); | |
private final Context context; | |
public ImageCache(Context context) { | |
this.context = context; | |
} | |
@Override | |
public void clear() { | |
for (Bitmap bitmap : values()) { | |
bitmap.recycle(); | |
} | |
cache.clear(); | |
} | |
@Override | |
public boolean containsKey(Object o) { | |
return cache.containsKey(o); | |
} | |
@Override | |
public boolean containsValue(Object o) { | |
return cache.containsValue(o); | |
} | |
@Override | |
public Set<Entry<String, Bitmap>> entrySet() { | |
return cache.entrySet(); | |
} | |
@Override | |
public boolean equals(Object o) { | |
return cache.equals(o); | |
} | |
@Override | |
public Bitmap get(Object o) { | |
return cache.get(o); | |
} | |
@Override | |
public int hashCode() { | |
return cache.hashCode(); | |
} | |
@Override | |
public boolean isEmpty() { | |
return cache.isEmpty(); | |
} | |
@Override | |
public Set<String> keySet() { | |
return cache.keySet(); | |
} | |
@Override | |
public Bitmap put(String s, Bitmap bitmap) { | |
return cache.put(s, bitmap); | |
} | |
@Override | |
public void putAll(Map<? extends String, ? extends Bitmap> map) { | |
cache.putAll(map); | |
} | |
@Override | |
public Bitmap remove(Object o) { | |
return cache.remove(o); | |
} | |
@Override | |
public int size() { | |
return cache.size(); | |
} | |
@Override | |
public Collection<Bitmap> values() { | |
return cache.values(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment