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;
|
||||
|
||||
import com.reandroid.arsc.array.EntryArray;
|
||||
import com.reandroid.arsc.chunk.ChunkType;
|
||||
import com.reandroid.arsc.array.TypeBlockArray;
|
||||
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.SpecBlock;
|
||||
import com.reandroid.arsc.chunk.TypeBlock;
|
||||
import com.reandroid.arsc.group.EntryGroup;
|
||||
import com.reandroid.arsc.header.HeaderBlock;
|
||||
import com.reandroid.arsc.io.BlockReader;
|
||||
import com.reandroid.arsc.item.TypeString;
|
||||
@ -31,10 +33,7 @@ import com.reandroid.json.JSONConvert;
|
||||
import com.reandroid.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public class SpecTypePair extends BlockContainer<Block>
|
||||
implements JSONConvert<JSONObject>, Comparable<SpecTypePair>{
|
||||
@ -53,6 +52,40 @@ public class SpecTypePair extends BlockContainer<Block>
|
||||
public SpecTypePair(){
|
||||
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(){
|
||||
getSpecBlock().destroy();
|
||||
getTypeBlockArray().destroy();
|
||||
|
@ -164,7 +164,10 @@ public class EntryGroup extends ItemGroup<Entry> {
|
||||
return "en".equals(lang);
|
||||
}
|
||||
public Entry getDefault(){
|
||||
Iterator<Entry> itr=iterator(true);
|
||||
return getDefault(true);
|
||||
}
|
||||
public Entry getDefault(boolean skipNull){
|
||||
Iterator<Entry> itr=iterator(skipNull);
|
||||
while (itr.hasNext()){
|
||||
Entry entry =itr.next();
|
||||
if(entry.isDefault()){
|
||||
|
Loading…
x
Reference in New Issue
Block a user