From 6c98d60922a61d4f5e2b108caa1e7d16fffcd7a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ryszard=20Wi=C5=9Bniewski?= Date: Wed, 1 Sep 2010 22:29:33 +0200 Subject: [PATCH] ResPackage: generating list of files to decode and list of values*/* files on demand. --- src/brut/androlib/res/data/ResPackage.java | 49 ++++++++++++---------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/src/brut/androlib/res/data/ResPackage.java b/src/brut/androlib/res/data/ResPackage.java index 63ae2dac..5e9f8a10 100644 --- a/src/brut/androlib/res/data/ResPackage.java +++ b/src/brut/androlib/res/data/ResPackage.java @@ -39,9 +39,6 @@ public class ResPackage { new LinkedHashMap(); private final Map mTypes = new LinkedHashMap(); - private final Set mFiles = new LinkedHashSet(); - private final Map, ResValuesFile> mValuesFiles = - new LinkedHashMap, ResValuesFile>(); private final Set mSynthesizedRes = new HashSet(); private ResValueFactory mValueFactory; @@ -111,11 +108,37 @@ public class ResPackage { } public Set listFiles() { - return mFiles; + Set ret = new HashSet(); + for (ResResSpec spec : mResSpecs.values()) { + for (ResResource res : spec.listResources()) { + if (res.getValue() instanceof ResFileValue) { + ret.add(res); + } + } + } + return ret; } public Collection listValuesFiles() { - return mValuesFiles.values(); + Map, ResValuesFile> ret = + new HashMap, ResValuesFile>(); + for (ResResSpec spec : mResSpecs.values()) { + for (ResResource res : spec.listResources()) { + if (res.getValue() instanceof ResXmlSerializable) { + ResType type = res.getResSpec().getType(); + ResConfig config = res.getConfig(); + Duo key = + new Duo(type, config); + ResValuesFile values = ret.get(key); + if (values == null) { + values = new ResValuesFile(this, type, config); + ret.put(key, values); + } + values.addResource(res); + } + } + } + return ret.values(); } public ResTable getResTable() { @@ -153,22 +176,6 @@ public class ResPackage { } public void addResource(ResResource res) { - ResValue value = res.getValue(); - if (value instanceof ResFileValue) { - mFiles.add(res); - } - if (value instanceof ResXmlSerializable) { - ResType type = res.getResSpec().getType(); - ResConfig config = res.getConfig(); - Duo key = - new Duo(type, config); - ResValuesFile values = mValuesFiles.get(key); - if (values == null) { - values = new ResValuesFile(this, type, config); - mValuesFiles.put(key, values); - } - values.addResource(res); - } } public void addSynthesizedRes(int resId) {