All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.koushikdutta.urlimageviewhelper.SoftReferenceHashTable Maven / Gradle / Ivy

Go to download

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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy