Skip to content

Commit

Permalink
fixes TC-5784 - check that the view's layout is not null before compa…
Browse files Browse the repository at this point in the history
…ring it to horizontal or vertical layout arrangements
  • Loading branch information
xavierlacot committed Dec 2, 2015
1 parent 785638b commit a0ec81c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public TiView(TiViewProxy proxy) {
super(proxy);
LayoutArrangement arrangement = LayoutArrangement.DEFAULT;

if (proxy.hasProperty(TiC.PROPERTY_LAYOUT)) {
if (proxy.hasPropertyAndNotNull(TiC.PROPERTY_LAYOUT)) {
String layoutProperty = TiConvert.toString(proxy.getProperty(TiC.PROPERTY_LAYOUT));
if (layoutProperty.equals(TiC.LAYOUT_HORIZONTAL)) {
arrangement = LayoutArrangement.HORIZONTAL;
Expand Down
10 changes: 10 additions & 0 deletions android/titanium/src/java/org/appcelerator/kroll/KrollProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,16 @@ public boolean hasProperty(String name)
return properties.containsKey(name);
}

/**
* @param name the lookup key.
* @return true if the proxy contains this property and it is not null, false otherwise.
* @module.api
*/
public boolean hasPropertyAndNotNull(String name)
{
return properties.containsKeyAndNotNull(name);
}

/**
* Returns the property value given its key.
* Properties are cached on the Proxy and updated from JS for relevant annotated APIs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ public static double toDouble(HashMap<String, Object> hashMap, String key)
}

/**
* Converts a vlaue into a String. If value is null, a default value is returned.
* Converts a value into a String. If value is null, a default value is returned.
* @param value the value to convert.
* @param defaultString the default value.
* @return a String.
Expand Down

0 comments on commit a0ec81c

Please sign in to comment.