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