Merge "LayoutLib: Fix warnings in ResourceHelper." into lmp-dev

This commit is contained in:
Deepanshu Gupta
2014-09-04 01:46:54 +00:00
committed by Android (Google) Code Review

View File

@@ -63,11 +63,11 @@ public final class ResourceHelper {
* Returns the color value represented by the given string value
* @param value the color value
* @return the color as an int
* @throw NumberFormatException if the conversion failed.
* @throws NumberFormatException if the conversion failed.
*/
public static int getColor(String value) {
if (value != null) {
if (value.startsWith("#") == false) {
if (!value.startsWith("#")) {
throw new NumberFormatException(
String.format("Color value '%s' must start with #", value));
}
@@ -113,7 +113,7 @@ public final class ResourceHelper {
public static ColorStateList getColorStateList(ResourceValue resValue, BridgeContext context) {
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)
File f = new File(value);
if (f.isFile()) {
@@ -360,7 +360,7 @@ public final class ResourceHelper {
*/
public static boolean parseFloatAttribute(String attribute, String value,
TypedValue outValue, boolean requireUnit) {
assert requireUnit == false || attribute != null;
assert !requireUnit || attribute != null;
// remove the space before and after
value = value.trim();
@@ -411,7 +411,7 @@ public final class ResourceHelper {
if (end.length() == 0) {
if (outValue != null) {
if (requireUnit == false) {
if (!requireUnit) {
outValue.type = TypedValue.TYPE_FLOAT;
outValue.data = Float.floatToIntBits(f);
} else {
@@ -489,6 +489,8 @@ public final class ResourceHelper {
private static void applyUnit(UnitEntry unit, TypedValue outValue, float[] outScale) {
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;
outScale[0] = unit.scale;
}