com.koushikdutta.urlimageviewhelper.SoftReferenceHashTable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of urlimageviewhelper Show documentation
Show all versions of urlimageviewhelper Show documentation
Android library that sets an ImageView's contents from a url. Manages image downloading, caching, and makes your coffee too.
The newest version!
package com.koushikdutta.urlimageviewhelper;
import java.lang.ref.SoftReference;
import java.util.Hashtable;
public class SoftReferenceHashTable {
Hashtable> mTable = new Hashtable>();
public V put(K key, V value) {
SoftReference old = mTable.put(key, new SoftReference(value));
if (old == null)
return null;
return old.get();
}
public V get(K key) {
SoftReference val = mTable.get(key);
if (val == null)
return null;
V ret = val.get();
if (ret == null)
mTable.remove(key);
return ret;
}
public V remove(K k) {
SoftReference v = mTable.remove(k);
if (v == null)
return null;
return v.get();
}
}