FileDocCategorySizeDatePackage
LayoutPullParser.javaAPI DocAndroid 5.1 API3624Thu Mar 12 22:22:44 GMT 2015com.android.layoutlib.bridge.intensive.setup

LayoutPullParser

public class LayoutPullParser extends KXmlParser implements com.android.ide.common.rendering.api.ILayoutPullParser

Fields Summary
Constructors Summary
public LayoutPullParser(String layoutPath)

param
layoutPath Must start with '/' and be relative to test resources.

        assert layoutPath.startsWith("/");
        try {
            init(getClass().getResourceAsStream(layoutPath));
        } catch (XmlPullParserException e) {
            throw new IOError(e);
        }
    
public LayoutPullParser(File layoutFile)

param
layoutFile Path of the layout xml file on disk.

        try {
            init(new FileInputStream(layoutFile));
        } catch (XmlPullParserException e) {
            throw new IOError(e);
        } catch (FileNotFoundException e) {
            throw new IOError(e);
        }
    
Methods Summary
public com.android.ide.common.rendering.api.ILayoutPullParsergetParser(java.lang.String layoutName)

        // Studio returns null.
        return null;
    
public java.lang.ObjectgetViewCookie()

        // TODO: Implement this properly.
        String name = super.getName();
        if (name == null) {
            return null;
        }

        // Store tools attributes if this looks like a layout we'll need adapter view
        // bindings for in the LayoutlibCallback.
        if (LIST_VIEW.equals(name) || EXPANDABLE_LIST_VIEW.equals(name) || GRID_VIEW.equals(name) || SPINNER.equals(name)) {
            Map<String, String> map = null;
            int count = getAttributeCount();
            for (int i = 0; i < count; i++) {
                String namespace = getAttributeNamespace(i);
                if (namespace != null && namespace.equals(TOOLS_URI)) {
                    String attribute = getAttributeName(i);
                    if (attribute.equals(ATTR_IGNORE)) {
                        continue;
                    }
                    if (map == null) {
                        map = new HashMap<String, String>(4);
                    }
                    map.put(attribute, getAttributeValue(i));
                }
            }

            return map;
        }

        return null;
    
private voidinit(java.io.InputStream stream)

        setFeature(FEATURE_PROCESS_NAMESPACES, true);
        setInput(stream, null);