Fix string comparison

This commit is contained in:
Rossen Hristov
2016-06-17 14:58:20 +03:00
parent 496839cf4e
commit b07ace7938

View File

@@ -22,15 +22,15 @@ public class BorderDrawable extends ColorDrawable {
private float borderWidth; private float borderWidth;
private int borderColor; private int borderColor;
private float borderRadius; private float borderRadius;
private String clipPath = ""; private String clipPath;
private int backgroundColor; private int backgroundColor;
private Bitmap backgroundImage; private Bitmap backgroundImage;
private float backgroundImageWidth; private float backgroundImageWidth;
private float backgroundImageHeight; private float backgroundImageHeight;
private String backgroundRepeat = ""; private String backgroundRepeat;
private String backgroundPosition = ""; private String backgroundPosition;
private CSSValue[] backgroundPositionParsedCSSValues; private CSSValue[] backgroundPositionParsedCSSValues;
private String backgroundSize = ""; private String backgroundSize;
private CSSValue[] backgroundSizeParsedCSSValues; private CSSValue[] backgroundSizeParsedCSSValues;
public BorderDrawable(float density){ public BorderDrawable(float density){
@@ -68,7 +68,8 @@ public class BorderDrawable extends ColorDrawable {
dirty = true; dirty = true;
} }
if (!this.clipPath.equals(clipPath)){
if (!compare(this.clipPath, clipPath)){
this.clipPath = clipPath; this.clipPath = clipPath;
dirty = true; dirty = true;
} }
@@ -93,18 +94,18 @@ public class BorderDrawable extends ColorDrawable {
dirty = true; dirty = true;
} }
if (!this.backgroundRepeat.equals(backgroundRepeat)){ if (!compare(this.backgroundRepeat, backgroundRepeat)){
this.backgroundRepeat = backgroundRepeat; this.backgroundRepeat = backgroundRepeat;
dirty = true; dirty = true;
} }
if (!this.backgroundPosition.equals(backgroundPosition)){ if (!compare(this.backgroundPosition, backgroundPosition)){
this.backgroundPosition = backgroundPosition; this.backgroundPosition = backgroundPosition;
this.backgroundPositionParsedCSSValues = backgroundPositionParsedCSSValues; this.backgroundPositionParsedCSSValues = backgroundPositionParsedCSSValues;
dirty = true; dirty = true;
} }
if (!this.backgroundSize.equals(backgroundSize)){ if (!compare(this.backgroundSize, backgroundSize)){
this.backgroundSize = backgroundSize; this.backgroundSize = backgroundSize;
this.backgroundSizeParsedCSSValues = backgroundSizeParsedCSSValues; this.backgroundSizeParsedCSSValues = backgroundSizeParsedCSSValues;
dirty = true; dirty = true;
@@ -115,6 +116,10 @@ public class BorderDrawable extends ColorDrawable {
} }
} }
private static boolean compare(String str1, String str2) {
return (str1 == null ? str2 == null : str1.equals(str2));
}
@Override @Override
public void draw(Canvas canvas) { public void draw(Canvas canvas) {
Rect bounds = this.getBounds(); Rect bounds = this.getBounds();