mirror of
https://github.com/revanced/ARSCLib.git
synced 2025-04-30 22:34:24 +02:00
remove redundant class AttrIDProvider
This commit is contained in:
parent
c519b9f581
commit
86b68b4646
@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2022 github.com/REAndroid
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.reandroid.xml.parser;
|
|
||||||
|
|
||||||
public interface AttrIDProvider {
|
|
||||||
int getAttributeNameResourceId(int position);
|
|
||||||
int getAttributeValueResourceId(int position);
|
|
||||||
}
|
|
@ -169,26 +169,10 @@ public class XMLDocumentParser {
|
|||||||
String attrValue=mParser.getAttributeValue(i);
|
String attrValue=mParser.getAttributeValue(i);
|
||||||
String prefix=mParser.getAttributePrefix(i);
|
String prefix=mParser.getAttributePrefix(i);
|
||||||
if(!XMLUtil.isEmpty(prefix)){
|
if(!XMLUtil.isEmpty(prefix)){
|
||||||
prefix=validateNameSpace(prefix, i);
|
|
||||||
attrName=appendPrefix(prefix, attrName);
|
attrName=appendPrefix(prefix, attrName);
|
||||||
checkNamespace(prefix, i);
|
checkNamespace(prefix, i);
|
||||||
}
|
}
|
||||||
XMLAttribute attr=mCurrentElement.setAttribute(attrName, attrValue);
|
mCurrentElement.setAttribute(attrName, attrValue);
|
||||||
addIds(attr, i);
|
|
||||||
}
|
|
||||||
private void addIds(XMLAttribute attr, int i){
|
|
||||||
if(attr==null){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
XmlPullParser parser=mParser;
|
|
||||||
if(!(parser instanceof AttrIDProvider)){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
AttrIDProvider idProvider=(AttrIDProvider)parser;
|
|
||||||
int nameId=idProvider.getAttributeNameResourceId(i);
|
|
||||||
int valueId=idProvider.getAttributeValueResourceId(i);
|
|
||||||
attr.setNameId(nameId);
|
|
||||||
attr.setValueId(valueId);
|
|
||||||
}
|
}
|
||||||
private String appendPrefix(String prefix, String attrName){
|
private String appendPrefix(String prefix, String attrName){
|
||||||
if(!prefix.endsWith(":")){
|
if(!prefix.endsWith(":")){
|
||||||
@ -211,42 +195,6 @@ public class XMLDocumentParser {
|
|||||||
}
|
}
|
||||||
checkNamespace(prefix, nsUri);
|
checkNamespace(prefix, nsUri);
|
||||||
}
|
}
|
||||||
private String validateNameSpace(String prefix, int i){
|
|
||||||
XmlPullParser parser=mParser;
|
|
||||||
if(!(parser instanceof AttrIDProvider)){
|
|
||||||
return prefix;
|
|
||||||
}
|
|
||||||
AttrIDProvider idProvider=(AttrIDProvider)parser;
|
|
||||||
int resId=idProvider.getAttributeNameResourceId(i);
|
|
||||||
if(!isResourceId(resId)){
|
|
||||||
return prefix;
|
|
||||||
}
|
|
||||||
boolean isAndroid;
|
|
||||||
if(!isAndroid(resId)){
|
|
||||||
if(!"android".equals(prefix)){
|
|
||||||
return prefix;
|
|
||||||
}
|
|
||||||
isAndroid=false;
|
|
||||||
}else {
|
|
||||||
if("android".equals(prefix)){
|
|
||||||
return prefix;
|
|
||||||
}
|
|
||||||
isAndroid=true;
|
|
||||||
}
|
|
||||||
NameSpaceItem ns;
|
|
||||||
if(isAndroid){
|
|
||||||
ns=NameSpaceItem.getAndroid();
|
|
||||||
}else {
|
|
||||||
ns=NameSpaceItem.getApp();
|
|
||||||
}
|
|
||||||
String prefixNew=ns.getPrefix();
|
|
||||||
NameSpaceItem nsItem=mCurrentElement.getNameSpaceItemForPrefix(prefixNew);
|
|
||||||
if(nsItem==null){
|
|
||||||
mCurrentElement.addNameSpace(ns);
|
|
||||||
mNameSpaceCreated=true;
|
|
||||||
}
|
|
||||||
return prefixNew;
|
|
||||||
}
|
|
||||||
private void checkNamespace(String prefix, String nsUri){
|
private void checkNamespace(String prefix, String nsUri){
|
||||||
NameSpaceItem nsItem=mCurrentElement.getNameSpaceItemForPrefix(prefix);
|
NameSpaceItem nsItem=mCurrentElement.getNameSpaceItemForPrefix(prefix);
|
||||||
if(nsItem!=null){
|
if(nsItem!=null){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user