From b07ace793841a1894ee00c26e385d48f716c6b68 Mon Sep 17 00:00:00 2001 From: Rossen Hristov Date: Fri, 17 Jun 2016 14:58:20 +0300 Subject: [PATCH] Fix string comparison --- .../nativescript/widgets/BorderDrawable.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/android/widgets/src/main/java/org/nativescript/widgets/BorderDrawable.java b/android/widgets/src/main/java/org/nativescript/widgets/BorderDrawable.java index 7acaac525..79b16511f 100644 --- a/android/widgets/src/main/java/org/nativescript/widgets/BorderDrawable.java +++ b/android/widgets/src/main/java/org/nativescript/widgets/BorderDrawable.java @@ -22,15 +22,15 @@ public class BorderDrawable extends ColorDrawable { private float borderWidth; private int borderColor; private float borderRadius; - private String clipPath = ""; + private String clipPath; private int backgroundColor; private Bitmap backgroundImage; private float backgroundImageWidth; private float backgroundImageHeight; - private String backgroundRepeat = ""; - private String backgroundPosition = ""; + private String backgroundRepeat; + private String backgroundPosition; private CSSValue[] backgroundPositionParsedCSSValues; - private String backgroundSize = ""; + private String backgroundSize; private CSSValue[] backgroundSizeParsedCSSValues; public BorderDrawable(float density){ @@ -68,7 +68,8 @@ public class BorderDrawable extends ColorDrawable { dirty = true; } - if (!this.clipPath.equals(clipPath)){ + + if (!compare(this.clipPath, clipPath)){ this.clipPath = clipPath; dirty = true; } @@ -93,18 +94,18 @@ public class BorderDrawable extends ColorDrawable { dirty = true; } - if (!this.backgroundRepeat.equals(backgroundRepeat)){ + if (!compare(this.backgroundRepeat, backgroundRepeat)){ this.backgroundRepeat = backgroundRepeat; dirty = true; } - if (!this.backgroundPosition.equals(backgroundPosition)){ + if (!compare(this.backgroundPosition, backgroundPosition)){ this.backgroundPosition = backgroundPosition; this.backgroundPositionParsedCSSValues = backgroundPositionParsedCSSValues; dirty = true; } - if (!this.backgroundSize.equals(backgroundSize)){ + if (!compare(this.backgroundSize, backgroundSize)){ this.backgroundSize = backgroundSize; this.backgroundSizeParsedCSSValues = backgroundSizeParsedCSSValues; 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 public void draw(Canvas canvas) { Rect bounds = this.getBounds();