From 6a75830a4ff0f9ee6463f7c4e483cc5fb0b35b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ryszard=20Wi=C5=9Bniewski?= Date: Wed, 1 Sep 2010 18:57:39 +0200 Subject: [PATCH] +ResPackage.getOrCreateConfig(). --- src/brut/androlib/res/data/ResPackage.java | 10 ++++++++++ src/brut/androlib/res/decoder/ARSCDecoder.java | 14 +++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/brut/androlib/res/data/ResPackage.java b/src/brut/androlib/res/data/ResPackage.java index 810880c5..63ae2dac 100644 --- a/src/brut/androlib/res/data/ResPackage.java +++ b/src/brut/androlib/res/data/ResPackage.java @@ -84,6 +84,16 @@ public class ResPackage { return config; } + public ResConfig getOrCreateConfig(ResConfigFlags flags) + throws AndrolibException { + ResConfig config = mConfigs.get(flags); + if (config == null) { + config = new ResConfig(flags); + mConfigs.put(flags, config); + } + return config; + } + public List listTypes() { return new ArrayList(mTypes.values()); } diff --git a/src/brut/androlib/res/decoder/ARSCDecoder.java b/src/brut/androlib/res/decoder/ARSCDecoder.java index 4f6bd3d0..4a142227 100644 --- a/src/brut/androlib/res/decoder/ARSCDecoder.java +++ b/src/brut/androlib/res/decoder/ARSCDecoder.java @@ -155,16 +155,8 @@ public class ARSCDecoder { } } - ResConfig config; - if (flags.isInvalid && ! mKeepBroken) { - config = null; - } else if (mPkg.hasConfig(flags)) { - config = mPkg.getConfig(flags); - } else { - config = new ResConfig(flags); - mPkg.addConfig(config); - } - mConfig = config; + mConfig = flags.isInvalid && ! mKeepBroken ? + null : mPkg.getOrCreateConfig(flags); for (int i = 0; i < entryOffsets.length; i++) { if (entryOffsets[i] != -1) { @@ -174,7 +166,7 @@ public class ARSCDecoder { } } - return config; + return mConfig; } private void readEntry() throws IOException, AndrolibException {