AssetManager: special handling for style and array types

These are complex and can't be loaded into a TypedArray
This commit is contained in:
Julian Winkler
2024-02-09 16:04:40 +01:00
parent 164383121c
commit f3292a76f2

View File

@@ -804,7 +804,7 @@ public final class AssetManager {
ValueItem valueItem = parser.getResXmlAttributeAt(xmlCache.get(resId));
value.type = valueItem.getType();
value.data = valueItem.getData();
value.resourceId = resId;
value.resourceId = 0;
value.assetCookie = -1;
if (value.type != TypedValue.TYPE_ATTRIBUTE)
found = true;
@@ -820,6 +820,14 @@ public final class AssetManager {
found = true;
}
}
if (value.type == TypedValue.TYPE_REFERENCE && value.data != 0) {
String typeName = getResourceTypeName(value.data);
if ("style".equals(typeName) || "array".equals(typeName)) {
// style and array are complex types, which can't be stored in a TypedArray
value.resourceId = value.data;
break;
}
}
if ((value.type == TypedValue.TYPE_REFERENCE || value.type == TypedValue.TYPE_ATTRIBUTE) && value.data != resId) {
resId = value.data;
} else {