未验证 提交 f642e11a 编写于 作者: B bagipro 提交者: GitHub

fix(res): fixes ns value (PR #1029)

* Fixes ns value
* fix formatting
Co-authored-by: Nbagipro <bugi@MacBook-Pro.local>
Co-authored-by: NSkylot <skylot@gmail.com>
上级 fdc87fe2
......@@ -313,17 +313,23 @@ public class BinaryXMLParser extends CommonBinaryParser {
}
private String generateNameForNS(String attrUrl) {
for (int i = 1;; i++) {
String attrName = "ns" + i;
if (!nsMap.containsValue(attrName) && !nsMapGenerated.contains(attrName)) {
nsMapGenerated.add(attrName);
// do not add generated value to nsMap
// because attrUrl might be used in a neighbor element, but never defined
writer.add("xmlns:").add(attrName)
.add("=\"").add(attrUrl).add("\" ");
return attrName;
String attrName;
if (ANDROID_NS_URL.equals(attrUrl)) {
attrName = ANDROID_NS_VALUE;
nsMap.put(ANDROID_NS_URL, attrName);
} else {
for (int i = 1;; i++) {
attrName = "ns" + i;
if (!nsMapGenerated.contains(attrName) && !nsMap.containsValue(attrName)) {
nsMapGenerated.add(attrName);
// do not add generated value to nsMap
// because attrUrl might be used in a neighbor element, but never defined
break;
}
}
}
writer.add("xmlns:").add(attrName).add("=\"").add(attrUrl).add("\" ");
return attrName;
}
private String getAttributeName(int id) {
......
......@@ -9,6 +9,7 @@ public class ParserConstants {
}
protected static final String ANDROID_NS_URL = "http://schemas.android.com/apk/res/android";
protected static final String ANDROID_NS_VALUE = "android";
/**
* Chunk types
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册