Loading tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java +7 −5 Original line number Original line Diff line number Diff line Loading @@ -63,11 +63,11 @@ public final class ResourceHelper { * Returns the color value represented by the given string value * Returns the color value represented by the given string value * @param value the color value * @param value the color value * @return the color as an int * @return the color as an int * @throw NumberFormatException if the conversion failed. * @throws NumberFormatException if the conversion failed. */ */ public static int getColor(String value) { public static int getColor(String value) { if (value != null) { if (value != null) { if (value.startsWith("#") == false) { if (!value.startsWith("#")) { throw new NumberFormatException( throw new NumberFormatException( String.format("Color value '%s' must start with #", value)); String.format("Color value '%s' must start with #", value)); } } Loading Loading @@ -113,7 +113,7 @@ public final class ResourceHelper { public static ColorStateList getColorStateList(ResourceValue resValue, BridgeContext context) { public static ColorStateList getColorStateList(ResourceValue resValue, BridgeContext context) { String value = resValue.getValue(); String value = resValue.getValue(); if (value != null && RenderResources.REFERENCE_NULL.equals(value) == false) { if (value != null && !RenderResources.REFERENCE_NULL.equals(value)) { // first check if the value is a file (xml most likely) // first check if the value is a file (xml most likely) File f = new File(value); File f = new File(value); if (f.isFile()) { if (f.isFile()) { Loading Loading @@ -360,7 +360,7 @@ public final class ResourceHelper { */ */ public static boolean parseFloatAttribute(String attribute, String value, public static boolean parseFloatAttribute(String attribute, String value, TypedValue outValue, boolean requireUnit) { TypedValue outValue, boolean requireUnit) { assert requireUnit == false || attribute != null; assert !requireUnit || attribute != null; // remove the space before and after // remove the space before and after value = value.trim(); value = value.trim(); Loading Loading @@ -411,7 +411,7 @@ public final class ResourceHelper { if (end.length() == 0) { if (end.length() == 0) { if (outValue != null) { if (outValue != null) { if (requireUnit == false) { if (!requireUnit) { outValue.type = TypedValue.TYPE_FLOAT; outValue.type = TypedValue.TYPE_FLOAT; outValue.data = Float.floatToIntBits(f); outValue.data = Float.floatToIntBits(f); } else { } else { Loading Loading @@ -489,6 +489,8 @@ public final class ResourceHelper { private static void applyUnit(UnitEntry unit, TypedValue outValue, float[] outScale) { private static void applyUnit(UnitEntry unit, TypedValue outValue, float[] outScale) { outValue.type = unit.type; outValue.type = unit.type; // COMPLEX_UNIT_SHIFT is 0 and hence intelliJ complains about it. Suppress the warning. //noinspection PointlessBitwiseExpression outValue.data = unit.unit << TypedValue.COMPLEX_UNIT_SHIFT; outValue.data = unit.unit << TypedValue.COMPLEX_UNIT_SHIFT; outScale[0] = unit.scale; outScale[0] = unit.scale; } } Loading Loading
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java +7 −5 Original line number Original line Diff line number Diff line Loading @@ -63,11 +63,11 @@ public final class ResourceHelper { * Returns the color value represented by the given string value * Returns the color value represented by the given string value * @param value the color value * @param value the color value * @return the color as an int * @return the color as an int * @throw NumberFormatException if the conversion failed. * @throws NumberFormatException if the conversion failed. */ */ public static int getColor(String value) { public static int getColor(String value) { if (value != null) { if (value != null) { if (value.startsWith("#") == false) { if (!value.startsWith("#")) { throw new NumberFormatException( throw new NumberFormatException( String.format("Color value '%s' must start with #", value)); String.format("Color value '%s' must start with #", value)); } } Loading Loading @@ -113,7 +113,7 @@ public final class ResourceHelper { public static ColorStateList getColorStateList(ResourceValue resValue, BridgeContext context) { public static ColorStateList getColorStateList(ResourceValue resValue, BridgeContext context) { String value = resValue.getValue(); String value = resValue.getValue(); if (value != null && RenderResources.REFERENCE_NULL.equals(value) == false) { if (value != null && !RenderResources.REFERENCE_NULL.equals(value)) { // first check if the value is a file (xml most likely) // first check if the value is a file (xml most likely) File f = new File(value); File f = new File(value); if (f.isFile()) { if (f.isFile()) { Loading Loading @@ -360,7 +360,7 @@ public final class ResourceHelper { */ */ public static boolean parseFloatAttribute(String attribute, String value, public static boolean parseFloatAttribute(String attribute, String value, TypedValue outValue, boolean requireUnit) { TypedValue outValue, boolean requireUnit) { assert requireUnit == false || attribute != null; assert !requireUnit || attribute != null; // remove the space before and after // remove the space before and after value = value.trim(); value = value.trim(); Loading Loading @@ -411,7 +411,7 @@ public final class ResourceHelper { if (end.length() == 0) { if (end.length() == 0) { if (outValue != null) { if (outValue != null) { if (requireUnit == false) { if (!requireUnit) { outValue.type = TypedValue.TYPE_FLOAT; outValue.type = TypedValue.TYPE_FLOAT; outValue.data = Float.floatToIntBits(f); outValue.data = Float.floatToIntBits(f); } else { } else { Loading Loading @@ -489,6 +489,8 @@ public final class ResourceHelper { private static void applyUnit(UnitEntry unit, TypedValue outValue, float[] outScale) { private static void applyUnit(UnitEntry unit, TypedValue outValue, float[] outScale) { outValue.type = unit.type; outValue.type = unit.type; // COMPLEX_UNIT_SHIFT is 0 and hence intelliJ complains about it. Suppress the warning. //noinspection PointlessBitwiseExpression outValue.data = unit.unit << TypedValue.COMPLEX_UNIT_SHIFT; outValue.data = unit.unit << TypedValue.COMPLEX_UNIT_SHIFT; outScale[0] = unit.scale; outScale[0] = unit.scale; } } Loading