Ignore some XML tags
This commit is contained in:
+7
-1
@@ -33,6 +33,8 @@ public object AndroidConst {
|
||||
val ID_USAGE_PREFIX = "@id/"
|
||||
|
||||
val CLEAR_FUNCTION_NAME = "clearFindViewByIdCache"
|
||||
|
||||
val IGNORED_XML_WIDGET_TYPES = setOf("requestFocus", "merge", "tag", "check")
|
||||
}
|
||||
|
||||
public fun nameToIdDeclaration(name: String): String = AndroidConst.ID_DECLARATION_PREFIX + name
|
||||
@@ -49,7 +51,11 @@ public fun isResourceIdUsage(str: String?): Boolean = str?.startsWith(AndroidCon
|
||||
|
||||
public fun isResourceDeclarationOrUsage(id: String?): Boolean = isResourceIdDeclaration(id) || isResourceIdUsage(id)
|
||||
|
||||
public fun isWidgetTypeIgnored(xmlType: String): Boolean {
|
||||
return (xmlType.isEmpty() || xmlType in AndroidConst.IGNORED_XML_WIDGET_TYPES)
|
||||
}
|
||||
|
||||
public fun getRealWidgetType(xmlType: String): String = when (xmlType) {
|
||||
"fragment", "include", "merge" -> "View"
|
||||
"fragment", "include" -> "View"
|
||||
else -> xmlType
|
||||
}
|
||||
+1
@@ -31,6 +31,7 @@ class AndroidXmlHandler(private val elementCallback: (String, String) -> Unit) :
|
||||
}
|
||||
|
||||
override fun startElement(uri: String, localName: String, qName: String, attributes: Attributes) {
|
||||
if (isWidgetTypeIgnored(localName)) return
|
||||
val attributesMap = attributes.toMap()
|
||||
val idAttribute = attributesMap[AndroidConst.ID_ATTRIBUTE_NO_NAMESPACE]
|
||||
val widgetType = getRealWidgetType(attributesMap[AndroidConst.CLASS_ATTRIBUTE_NO_NAMESPACE] ?: localName)
|
||||
|
||||
Reference in New Issue
Block a user