mirror of
https://github.com/revanced/ARSCLib.git
synced 2025-05-07 17:24:26 +02:00
simplify obtaining parent
This commit is contained in:
parent
85926e4e1c
commit
217a491940
@ -54,12 +54,9 @@ public class TypeBlock extends Chunk<TypeHeader>
|
||||
addChild(mEntryArray);
|
||||
}
|
||||
public PackageBlock getPackageBlock(){
|
||||
Block parent=getParent();
|
||||
while (parent!=null){
|
||||
if(parent instanceof SpecTypePair){
|
||||
return ((SpecTypePair)parent).getPackageBlock();
|
||||
}
|
||||
parent=parent.getParent();
|
||||
SpecTypePair specTypePair = getParent(SpecTypePair.class);
|
||||
if(specTypePair!=null){
|
||||
return specTypePair.getPackageBlock();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -261,12 +261,9 @@
|
||||
return null;
|
||||
}
|
||||
public ResXmlIDMap getResXmlIDMap(){
|
||||
Block parent=getParent();
|
||||
while (parent!=null){
|
||||
if(parent instanceof ResXmlDocument){
|
||||
return ((ResXmlDocument)parent).getResXmlIDMap();
|
||||
}
|
||||
parent=parent.getParent();
|
||||
ResXmlDocument resXmlDocument = getParentInstance(ResXmlDocument.class);
|
||||
if(resXmlDocument!=null){
|
||||
return resXmlDocument.getResXmlIDMap();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -56,12 +56,9 @@
|
||||
|
||||
}
|
||||
ResXmlStringPool getXmlStringPool(){
|
||||
Block parent=this;
|
||||
while (parent!=null){
|
||||
if(parent instanceof ResXmlDocument){
|
||||
return ((ResXmlDocument)parent).getStringPool();
|
||||
}
|
||||
parent=parent.getParent();
|
||||
ResXmlDocument resXmlDocument = getParentInstance(ResXmlDocument.class);
|
||||
if(resXmlDocument!=null){
|
||||
return resXmlDocument.getStringPool();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -72,12 +72,9 @@ public class ResXmlID extends IntegerItem {
|
||||
return stringPool.get(getIndex());
|
||||
}
|
||||
private ResXmlStringPool getXmlStringPool(){
|
||||
Block parent=this;
|
||||
while (parent!=null){
|
||||
if(parent instanceof ResXmlDocument){
|
||||
return ((ResXmlDocument)parent).getStringPool();
|
||||
}
|
||||
parent=parent.getParent();
|
||||
ResXmlDocument resXmlDocument = getParentInstance(ResXmlDocument.class);
|
||||
if(resXmlDocument!=null){
|
||||
return resXmlDocument.getStringPool();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -218,23 +218,13 @@ public class StringItem extends BlockItem implements JSONConvert<JSONObject> {
|
||||
return styleItem.getSpanInfoList().size()>0;
|
||||
}
|
||||
public StyleItem getStyle(){
|
||||
StringPool<?> stringPool=getStringPool();
|
||||
StringPool<?> stringPool = getParentInstance(StringPool.class);
|
||||
if(stringPool==null){
|
||||
return null;
|
||||
}
|
||||
int index=getIndex();
|
||||
return stringPool.getStyle(index);
|
||||
}
|
||||
private StringPool<?> getStringPool(){
|
||||
Block parent=getParent();
|
||||
while (parent!=null){
|
||||
if(parent instanceof StringPool){
|
||||
return (StringPool<?>)parent;
|
||||
}
|
||||
parent=parent.getParent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public JSONObject toJson() {
|
||||
if(isNull()){
|
||||
|
@ -263,14 +263,7 @@ public class StyleItem extends IntegerArray implements JSONConvert<JSONObject> {
|
||||
return null;
|
||||
}
|
||||
private StringPool<?> getStringPool(){
|
||||
Block parent=getParent();
|
||||
while (parent!=null){
|
||||
if(parent instanceof StringPool){
|
||||
return (StringPool<?>)parent;
|
||||
}
|
||||
parent=parent.getParent();
|
||||
}
|
||||
return null;
|
||||
return getParentInstance(StringPool.class);
|
||||
}
|
||||
|
||||
public String applyHtml(String str, boolean xml){
|
||||
|
@ -33,13 +33,6 @@ public class SpecStringPool extends StringPool<SpecString> {
|
||||
return new SpecStringArray(offsets, itemCount, itemStart, is_utf8);
|
||||
}
|
||||
public PackageBlock getPackageBlock(){
|
||||
Block parent=getParent();
|
||||
while (parent!=null){
|
||||
if(parent instanceof PackageBlock){
|
||||
return (PackageBlock) parent;
|
||||
}
|
||||
parent=parent.getParent();
|
||||
}
|
||||
return null;
|
||||
return getParent(PackageBlock.class);
|
||||
}
|
||||
}
|
||||
|
@ -140,6 +140,13 @@ package com.reandroid.arsc.pool;
|
||||
group.add(item);
|
||||
}
|
||||
}
|
||||
void updateUniqueIdMap(T item){
|
||||
if(item==null){
|
||||
return;
|
||||
}
|
||||
StringGroup<T> group = getOrCreateGroup(item.getHtml());
|
||||
group.add(item);
|
||||
}
|
||||
public List<T> removeUnusedStrings(){
|
||||
return getStringsArray().removeUnusedStrings();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user