Code example for SoftReference

Methods: get

0
    } 
 
    private Drawable getCachedDrawable(String key) {
        if (mIconCache.containsKey(key)) {
            if (DEBUG) log("getCachedDrawable('" + key + "') - cached drawable found");
            return mIconCache.get(key).get();
        } 
        return null; 
    } 
 
    private void setCachedDrawable(String key, Drawable d) {
        mIconCache.put(key, new SoftReference<Drawable>(d));
        if (DEBUG) log("setCachedDrawable('" + key + "') - storing to cache");
    } 
 
    public Drawable getWifiIcon(String key) {
        Drawable cd = getCachedDrawable(key);
        if (cd != null) return cd;
 
        if (mWifiIconIds.containsKey(key)) {
            Drawable d = mResources.getDrawable(mWifiIconIds.get(key)).mutate();