Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
internal fun Attr.belongsToItem() = ownerElement.nodeName == "item"
internal fun Element.belongsToStyle() = parentNode.nodeName == "style"
internal fun Element.belongsToThemeOrThemeOverlay() = belongsToStyle()
&& parentNode.attributes.getNamedItem("name").nodeValue.startsWith("Theme")
* Looks for VALUE in a <style> resource
* e.g. <item name="attrName">VALUE</item>
* else returns null
internal fun Element.findValueOfItemWithName(attrName: String): String? {
if (nodeName != "style") throw IllegalArgumentException("Expected <style> element but found: $nodeName")
return getChildren(this)
.firstOrNull { element -> element.nodeName == "item" && element.getAttribute("name") == attrName }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment