/**
* Returns the value to which this map maps the specified <code>key</code>. If this map does not contain a value for this key, then return <code>null</code>.
* @param key The key whose associated value, if any, is to be returned.
*/
public Object get(Object key){
processQueue();
SoftReference ref=(SoftReference)hash.get(key);
if (ref != null) return ref.get();
return null;
}

/**
* Returns the value to which this map maps the specified <code>key</code>. If this map does not contain a value for this key, then return <code>null</code>.
* @param key The key whose associated value, if any, is to be returned.
*/
public Object get(Object key){
processQueue();
SoftReference ref=(SoftReference)hash.get(key);
if (ref != null) return ref.get();
return null;
}

Example 5

From project platform_external_javassist, under directory /src/main/javassist/scopedpool/.

/**
* Returns the value to which this map maps the specified <code>key</code>. If this map does not contain a value for this key, then return <code>null</code>.
* @param key The key whose associated value, if any, is to be returned.
*/
public Object get(Object key){
processQueue();
SoftReference ref=(SoftReference)hash.get(key);
if (ref != null) return ref.get();
return null;
}

/**
* Retrieves a drawable from the book covers cache, identified by the specified id. If the drawable does not exist in the cache, it is loaded and added to the cache. If the drawable cannot be added to the cache, the specified default drwaable is returned.
* @param id The id of the drawable to retrieve
* @param defaultCover The default drawable returned if no drawable can be found thatmatches the id
* @return The drawable identified by id or defaultCover
*/
public static FastBitmapDrawable getCachedCover(String id,FastBitmapDrawable defaultCover){
FastBitmapDrawable drawable=null;
SoftReference<FastBitmapDrawable> reference=sArtCache.get(id);
if (reference != null) {
drawable=reference.get();
}
if (drawable == null) {
final Bitmap bitmap=loadCover(id);
if (bitmap != null) {
drawable=new FastBitmapDrawable(bitmap);
}
else {
drawable=NULL_DRAWABLE;
}
sArtCache.put(id,new SoftReference<FastBitmapDrawable>(drawable));
}
return drawable == NULL_DRAWABLE ? defaultCover : drawable;
}

Example 25

From project android_7, under directory /src/org/immopoly/android/helper/.

/**
* Retrieves a drawable from the cache, identified by the specified id. If the drawable does not exist in the cache, it is loaded and added to the cache. If the drawable cannot be added to the cache, the specified default drwaable is returned.
* @param id The id of the drawable to retrieve
* @param defaultIcon The default drawable returned if no drawable can be found that matches the id
* @return The drawable identified by id or defaultIcon
*/
public static FastBitmapDrawable getCachedIcon(File cacheDirectory,String id,FastBitmapDrawable defaultIcon){
FastBitmapDrawable drawable=null;
SoftReference<FastBitmapDrawable> reference=sArtCache.get(id);
if (reference != null) {
drawable=reference.get();
}
if (drawable == null) {
final Bitmap bitmap=loadIcon(cacheDirectory,id);
if (bitmap != null) {
drawable=new FastBitmapDrawable(bitmap);
}
else {
drawable=NULL_DRAWABLE;
}
sArtCache.put(id,new SoftReference<FastBitmapDrawable>(drawable));
}
return drawable == NULL_DRAWABLE ? defaultIcon : drawable;
}

Example 86

From project MIT-Mobile-for-Android, under directory /src/edu/mit/mitmobile2/maps/.