FileDocCategorySizeDatePackage
BridgeXmlPullAttributes.javaAPI DocAndroid 1.5 API3979Wed May 06 22:42:02 BST 2009com.android.layoutlib.bridge

BridgeXmlPullAttributes

public class BridgeXmlPullAttributes extends android.util.XmlPullAttributes
A correct implementation of the {@link AttributeSet} interface on top of a XmlPullParser

Fields Summary
private final BridgeContext
mContext
private final boolean
mPlatformFile
Constructors Summary
public BridgeXmlPullAttributes(XmlPullParser parser, BridgeContext context, boolean platformFile)

        super(parser);
        mContext = context;
        mPlatformFile = platformFile;
    
Methods Summary
public intgetAttributeNameResource(int index)

        // get the attribute name.
        String name = getAttributeName(index);
        
        // get the attribute namespace
        String ns = mParser.getAttributeNamespace(index);
        
        if (BridgeConstants.NS_RESOURCES.equals(ns)) {
            Integer v = Bridge.getResourceValue(BridgeConstants.RES_ATTR, name);
            if (v != null) {
                return v.intValue();
            }
            
            return 0;
        }
        
        // this is not an attribute in the android namespace, we query the customviewloader, if
        // the namespaces match.
        if (mContext.getProjectCallback().getNamespace().equals(ns)) {
            Integer v = mContext.getProjectCallback().getResourceValue(BridgeConstants.RES_ATTR,
                    name);
            if (v != null) {
                return v.intValue();
            }
        }

        return 0;
    
public intgetAttributeResourceValue(int index, int defaultValue)

        String value = getAttributeValue(index);
        
        return resolveResourceValue(value, defaultValue);
    
public intgetAttributeResourceValue(java.lang.String namespace, java.lang.String attribute, int defaultValue)

        String value = getAttributeValue(namespace, attribute);
        
        return resolveResourceValue(value, defaultValue);
    
private intresolveResourceValue(java.lang.String value, int defaultValue)

        // now look for this particular value
        IResourceValue resource = mContext.resolveResValue(mContext.findResValue(value));
        
        if (resource != null) {
            Integer id = null;
            if (mPlatformFile || resource.isFramework()) {
                id = Bridge.getResourceValue(resource.getType(), resource.getName());
            } else {
                id = mContext.getProjectCallback().getResourceValue(
                        resource.getType(), resource.getName());
            }

            if (id != null) {
                return id;
            }
        }
        
        return defaultValue;