mirror of
https://github.com/revanced/ARSCLib.git
synced 2025-05-01 14:44:27 +02:00
create separate EntryGroup for Type
This commit is contained in:
parent
c244c37dc8
commit
c69c85d8c2
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.reandroid.arsc.container;
|
package com.reandroid.arsc.container;
|
||||||
|
|
||||||
|
import com.reandroid.arsc.array.EntryArray;
|
||||||
import com.reandroid.arsc.chunk.ChunkType;
|
import com.reandroid.arsc.chunk.ChunkType;
|
||||||
import com.reandroid.arsc.array.TypeBlockArray;
|
import com.reandroid.arsc.array.TypeBlockArray;
|
||||||
import com.reandroid.arsc.base.Block;
|
import com.reandroid.arsc.base.Block;
|
||||||
@ -22,6 +23,7 @@ import com.reandroid.arsc.base.BlockContainer;
|
|||||||
import com.reandroid.arsc.chunk.PackageBlock;
|
import com.reandroid.arsc.chunk.PackageBlock;
|
||||||
import com.reandroid.arsc.chunk.SpecBlock;
|
import com.reandroid.arsc.chunk.SpecBlock;
|
||||||
import com.reandroid.arsc.chunk.TypeBlock;
|
import com.reandroid.arsc.chunk.TypeBlock;
|
||||||
|
import com.reandroid.arsc.group.EntryGroup;
|
||||||
import com.reandroid.arsc.header.HeaderBlock;
|
import com.reandroid.arsc.header.HeaderBlock;
|
||||||
import com.reandroid.arsc.io.BlockReader;
|
import com.reandroid.arsc.io.BlockReader;
|
||||||
import com.reandroid.arsc.item.TypeString;
|
import com.reandroid.arsc.item.TypeString;
|
||||||
@ -31,10 +33,7 @@ import com.reandroid.json.JSONConvert;
|
|||||||
import com.reandroid.json.JSONObject;
|
import com.reandroid.json.JSONObject;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SpecTypePair extends BlockContainer<Block>
|
public class SpecTypePair extends BlockContainer<Block>
|
||||||
implements JSONConvert<JSONObject>, Comparable<SpecTypePair>{
|
implements JSONConvert<JSONObject>, Comparable<SpecTypePair>{
|
||||||
@ -53,6 +52,40 @@ public class SpecTypePair extends BlockContainer<Block>
|
|||||||
public SpecTypePair(){
|
public SpecTypePair(){
|
||||||
this(new SpecBlock(), new TypeBlockArray());
|
this(new SpecBlock(), new TypeBlockArray());
|
||||||
}
|
}
|
||||||
|
public Map<Integer, EntryGroup> createEntryGroups(){
|
||||||
|
Map<Integer, EntryGroup> map = new HashMap<>();
|
||||||
|
for(TypeBlock typeBlock:listTypeBlocks()){
|
||||||
|
EntryArray entryArray = typeBlock.getEntryArray();
|
||||||
|
for(Entry entry:entryArray.listItems()){
|
||||||
|
if(entry==null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int id = entry.getResourceId();
|
||||||
|
EntryGroup entryGroup = map.get(id);
|
||||||
|
if(entryGroup == null){
|
||||||
|
entryGroup = new EntryGroup(id);
|
||||||
|
map.put(id, entryGroup);
|
||||||
|
}
|
||||||
|
entryGroup.add(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
public EntryGroup createEntryGroup(int id){
|
||||||
|
id = 0xffff & id;
|
||||||
|
EntryGroup entryGroup = null;
|
||||||
|
for(TypeBlock typeBlock:listTypeBlocks()){
|
||||||
|
Entry entry = typeBlock.getEntry(id);
|
||||||
|
if(entry == null){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(entryGroup == null){
|
||||||
|
entryGroup = new EntryGroup(entry.getResourceId());
|
||||||
|
}
|
||||||
|
entryGroup.add(entry);
|
||||||
|
}
|
||||||
|
return entryGroup;
|
||||||
|
}
|
||||||
public void destroy(){
|
public void destroy(){
|
||||||
getSpecBlock().destroy();
|
getSpecBlock().destroy();
|
||||||
getTypeBlockArray().destroy();
|
getTypeBlockArray().destroy();
|
||||||
|
@ -164,7 +164,10 @@ public class EntryGroup extends ItemGroup<Entry> {
|
|||||||
return "en".equals(lang);
|
return "en".equals(lang);
|
||||||
}
|
}
|
||||||
public Entry getDefault(){
|
public Entry getDefault(){
|
||||||
Iterator<Entry> itr=iterator(true);
|
return getDefault(true);
|
||||||
|
}
|
||||||
|
public Entry getDefault(boolean skipNull){
|
||||||
|
Iterator<Entry> itr=iterator(skipNull);
|
||||||
while (itr.hasNext()){
|
while (itr.hasNext()){
|
||||||
Entry entry =itr.next();
|
Entry entry =itr.next();
|
||||||
if(entry.isDefault()){
|
if(entry.isDefault()){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user