mirror of
https://github.com/revanced/ARSCLib.git
synced 2025-05-01 22:54:26 +02:00
auto initialise entries
This commit is contained in:
parent
793f3dd3a9
commit
17a9e18fd2
@ -19,6 +19,8 @@ import com.reandroid.arsc.item.IntegerItem;
|
|||||||
import com.reandroid.arsc.pool.SpecStringPool;
|
import com.reandroid.arsc.pool.SpecStringPool;
|
||||||
import com.reandroid.arsc.pool.TableStringPool;
|
import com.reandroid.arsc.pool.TableStringPool;
|
||||||
import com.reandroid.arsc.value.Entry;
|
import com.reandroid.arsc.value.Entry;
|
||||||
|
import com.reandroid.arsc.value.ResValue;
|
||||||
|
import com.reandroid.arsc.value.ValueType;
|
||||||
import com.reandroid.json.JSONConvert;
|
import com.reandroid.json.JSONConvert;
|
||||||
import com.reandroid.json.JSONArray;
|
import com.reandroid.json.JSONArray;
|
||||||
import com.reandroid.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
@ -75,12 +77,22 @@ public class EntryArray extends OffsetBlockArray<Entry> implements JSONConvert<J
|
|||||||
}
|
}
|
||||||
clearChildes();
|
clearChildes();
|
||||||
}
|
}
|
||||||
public boolean hasComplexEntry(){
|
public Boolean hasComplexEntry(){
|
||||||
Entry first = iterator(true).next();
|
Iterator<Entry> itr = iterator(true);
|
||||||
if(first==null){
|
while (itr.hasNext()){
|
||||||
|
Entry entry = itr.next();
|
||||||
|
if(entry.isComplex()){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ResValue resValue = entry.getResValue();
|
||||||
|
ValueType valueType = resValue.getValueType();
|
||||||
|
if(valueType == null || valueType == ValueType.REFERENCE
|
||||||
|
|| valueType == ValueType.NULL){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return first.isComplex();
|
return null;
|
||||||
}
|
}
|
||||||
public boolean isEmpty(){
|
public boolean isEmpty(){
|
||||||
return !iterator(true).hasNext();
|
return !iterator(true).hasNext();
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
package com.reandroid.arsc.array;
|
package com.reandroid.arsc.array;
|
||||||
|
|
||||||
import com.reandroid.arsc.chunk.ChunkType;
|
import com.reandroid.arsc.chunk.ChunkType;
|
||||||
import com.reandroid.arsc.base.Block;
|
|
||||||
import com.reandroid.arsc.base.BlockArray;
|
import com.reandroid.arsc.base.BlockArray;
|
||||||
import com.reandroid.arsc.chunk.SpecBlock;
|
import com.reandroid.arsc.chunk.SpecBlock;
|
||||||
import com.reandroid.arsc.chunk.TypeBlock;
|
import com.reandroid.arsc.chunk.TypeBlock;
|
||||||
@ -32,17 +31,29 @@ import com.reandroid.json.JSONArray;
|
|||||||
import com.reandroid.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.AbstractList;
|
import java.util.*;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class TypeBlockArray extends BlockArray<TypeBlock>
|
public class TypeBlockArray extends BlockArray<TypeBlock>
|
||||||
implements JSONConvert<JSONArray>, Comparator<TypeBlock> {
|
implements JSONConvert<JSONArray>, Comparator<TypeBlock> {
|
||||||
private byte mTypeId;
|
private byte mTypeId;
|
||||||
|
private Boolean mHasComplexEntry;
|
||||||
|
|
||||||
public TypeBlockArray(){
|
public TypeBlockArray(){
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean hasComplexEntry(){
|
||||||
|
if(mHasComplexEntry != null){
|
||||||
|
return mHasComplexEntry;
|
||||||
|
}
|
||||||
|
for(TypeBlock typeBlock : listItems(true)){
|
||||||
|
Boolean hasComplex = typeBlock.getEntryArray().hasComplexEntry();
|
||||||
|
if(hasComplex != null){
|
||||||
|
mHasComplexEntry = hasComplex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mHasComplexEntry;
|
||||||
|
}
|
||||||
public void destroy(){
|
public void destroy(){
|
||||||
for(TypeBlock typeBlock:listItems()){
|
for(TypeBlock typeBlock:listItems()){
|
||||||
if(typeBlock!=null){
|
if(typeBlock!=null){
|
||||||
|
@ -18,12 +18,8 @@ package com.reandroid.arsc.chunk;
|
|||||||
import com.reandroid.arsc.array.EntryArray;
|
import com.reandroid.arsc.array.EntryArray;
|
||||||
import com.reandroid.arsc.array.OffsetArray;
|
import com.reandroid.arsc.array.OffsetArray;
|
||||||
import com.reandroid.arsc.array.SparseOffsetsArray;
|
import com.reandroid.arsc.array.SparseOffsetsArray;
|
||||||
import com.reandroid.arsc.base.Block;
|
|
||||||
import com.reandroid.arsc.container.SpecTypePair;
|
import com.reandroid.arsc.container.SpecTypePair;
|
||||||
import com.reandroid.arsc.group.EntryGroup;
|
|
||||||
import com.reandroid.arsc.header.TypeHeader;
|
import com.reandroid.arsc.header.TypeHeader;
|
||||||
import com.reandroid.arsc.io.BlockLoad;
|
|
||||||
import com.reandroid.arsc.io.BlockReader;
|
|
||||||
import com.reandroid.arsc.item.*;
|
import com.reandroid.arsc.item.*;
|
||||||
import com.reandroid.arsc.pool.SpecStringPool;
|
import com.reandroid.arsc.pool.SpecStringPool;
|
||||||
import com.reandroid.arsc.pool.TableStringPool;
|
import com.reandroid.arsc.pool.TableStringPool;
|
||||||
@ -199,7 +195,10 @@ public class TypeBlock extends Chunk<TypeHeader>
|
|||||||
.getSpecStringPool().getOrCreate(name);
|
.getSpecStringPool().getOrCreate(name);
|
||||||
entry = getOrCreateEntry((short) id);
|
entry = getOrCreateEntry((short) id);
|
||||||
if(entry.isNull()){
|
if(entry.isNull()){
|
||||||
entry.ensureComplex(getEntryArray().hasComplexEntry());
|
Boolean hasComplex = hasComplexEntry();
|
||||||
|
if(hasComplex != null){
|
||||||
|
entry.ensureComplex(hasComplex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
entry.setSpecReference(specString.getIndex());
|
entry.setSpecReference(specString.getIndex());
|
||||||
return entry;
|
return entry;
|
||||||
@ -216,6 +215,13 @@ public class TypeBlock extends Chunk<TypeHeader>
|
|||||||
public Entry getEntry(String entryName){
|
public Entry getEntry(String entryName){
|
||||||
return getEntryArray().getEntry(entryName);
|
return getEntryArray().getEntry(entryName);
|
||||||
}
|
}
|
||||||
|
public Boolean hasComplexEntry(){
|
||||||
|
SpecTypePair specTypePair = getParentSpecTypePair();
|
||||||
|
if(specTypePair != null){
|
||||||
|
return specTypePair.hasComplexEntry();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
public ResConfig getResConfig(){
|
public ResConfig getResConfig(){
|
||||||
return getHeaderBlock().getConfig();
|
return getHeaderBlock().getConfig();
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,9 @@ public class SpecTypePair extends BlockContainer<Block>
|
|||||||
this(new SpecBlock(), new TypeBlockArray());
|
this(new SpecBlock(), new TypeBlockArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean hasComplexEntry(){
|
||||||
|
return getTypeBlockArray().hasComplexEntry();
|
||||||
|
}
|
||||||
public void linkTableStringsInternal(TableStringPool tableStringPool){
|
public void linkTableStringsInternal(TableStringPool tableStringPool){
|
||||||
for(TypeBlock typeBlock:listTypeBlocks()){
|
for(TypeBlock typeBlock:listTypeBlocks()){
|
||||||
typeBlock.linkTableStringsInternal(tableStringPool);
|
typeBlock.linkTableStringsInternal(tableStringPool);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user