Search in sources :

Example 1 with Actions

use of com.android.manifmerger.Actions in project android by JetBrains.

the class ManifestUtils method getRecords.

@NotNull
static List<? extends Actions.Record> getRecords(@NotNull MergedManifest manifest, @NotNull Node item) {
    Actions actions = manifest.getActions();
    if (actions != null) {
        if (item instanceof Element) {
            Element element = (Element) item;
            XmlNode.NodeKey key = getNodeKey(manifest, element);
            return actions.getNodeRecords(key);
        } else if (item instanceof Attr) {
            Attr attribute = (Attr) item;
            Element element = attribute.getOwnerElement();
            XmlNode.NodeKey key = getNodeKey(manifest, element);
            XmlNode.NodeName name = XmlNode.fromXmlName(attribute.getName());
            List<? extends Actions.Record> attributeRecords = actions.getAttributeRecords(key, name);
            if (!attributeRecords.isEmpty()) {
                return attributeRecords;
            }
            return actions.getNodeRecords(key);
        }
    }
    return Collections.emptyList();
}
Also used : XmlNode(com.android.manifmerger.XmlNode) Actions(com.android.manifmerger.Actions) ArrayList(java.util.ArrayList) List(java.util.List) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with Actions

use of com.android.manifmerger.Actions in project android by JetBrains.

the class MergedManifest method getNodeKey.

@Nullable
public XmlNode.NodeKey getNodeKey(String name) {
    sync();
    if (myNodeKeys == null) {
        HashMap<String, XmlNode.NodeKey> nodeKeys = new HashMap<>();
        Actions actions = getActions();
        if (actions != null) {
            Set<XmlNode.NodeKey> keys = actions.getNodeKeys();
            for (XmlNode.NodeKey key : keys) {
                nodeKeys.put(key.toString(), key);
            }
        }
        myNodeKeys = nodeKeys;
    }
    return myNodeKeys.get(name);
}
Also used : XmlNode(com.android.manifmerger.XmlNode) Actions(com.android.manifmerger.Actions) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Actions (com.android.manifmerger.Actions)2 XmlNode (com.android.manifmerger.XmlNode)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1