From 93850ff82075404eebfd6923e7253cf19cf84690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ryszard=20Wi=C5=9Bniewski?= Date: Mon, 22 Mar 2010 16:12:09 +0100 Subject: [PATCH] +ResValueFactory.factory(int type, int value) --- .../res/data/value/ResValueFactory.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/brut/androlib/res/data/value/ResValueFactory.java b/src/brut/androlib/res/data/value/ResValueFactory.java index 7da0d312..91fe35ba 100644 --- a/src/brut/androlib/res/data/value/ResValueFactory.java +++ b/src/brut/androlib/res/data/value/ResValueFactory.java @@ -17,6 +17,7 @@ package brut.androlib.res.data.value; +import android.util.TypedValue; import brut.androlib.AndrolibException; import brut.androlib.res.data.ResPackage; import brut.androlib.res.jni.JniBagItem; @@ -36,6 +37,35 @@ public class ResValueFactory { this.mPackage = pakage_; } + public ResScalarValue factory(int type, int value) + throws AndrolibException { + switch (type) { + case TypedValue.TYPE_REFERENCE: + return newReference(value); + case TypedValue.TYPE_ATTRIBUTE: + return newReference(value, true); + case TypedValue.TYPE_FLOAT: + return new ResFloatValue(Float.intBitsToFloat(value)); + case TypedValue.TYPE_DIMENSION: + return new ResDimenValue(value); + case TypedValue.TYPE_FRACTION: + return new ResFractionValue(value); + case TypedValue.TYPE_INT_BOOLEAN: + return new ResBoolValue(value != 0); + } + + if (type >= TypedValue.TYPE_FIRST_COLOR_INT + && type <= TypedValue.TYPE_LAST_COLOR_INT) { + return new ResColorValue(value); + } + if (type >= TypedValue.TYPE_FIRST_INT + && type <= TypedValue.TYPE_LAST_INT) { + return new ResIntValue(value); + } + + throw new AndrolibException("Invalid value type: "+ type); + } + public ResScalarValue factory(String string) throws AndrolibException { if (string.isEmpty()) { return new ResStringValue(string);