mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-12 05:47:46 +01:00
+ResValueFactory.factory(int type, int value)
This commit is contained in:
parent
4213125d5f
commit
93850ff820
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user