Code example for WeakReference

Methods: get

0
        final String name = parser.getName();
        try { 
            Class<? extends Drawable> clazz = CLASS_MAP.get(name);
            if (clazz != null) {
                drawable = clazz.newInstance();
            } else if (name.indexOf('.') > 0) {
                drawable = (Drawable) Class.forName(name).newInstance();
            } 
        } catch (Exception e) {
            throw new XmlPullParserException("Error while inflating drawable resource", parser, e);
        } 
        if (drawable == null) {
            return Drawable.createFromXmlInner(r, parser, attrs);
        } 
        drawable.inflate(r, parser, attrs);
        return drawable;
    } 
 
    private static Drawable getCachedDrawable(long key, Resources res) {
        WeakReference<Drawable.ConstantState> wr = sDrawableCache.get(key);
        if (wr != null) {