Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-16562] Handle cases when value is null #45

Merged
merged 3 commits into from
Jul 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file not shown.
1 change: 1 addition & 0 deletions android/documentation/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Change Log
<pre>
v2.1.6 Handle null values for attributes. [TIMOB-16562]
v2.1.5 Update Google Play Services library and its assets. [TIMOB-16510]
v2.1.4 Implement tilt, bearing, zoom, compassEnabled properties [TIMOB-16180].
Implement maxZoomLevel, minZoomLevel, update Google Play Services SDK [TIMOB-16180].
Expand Down
2 changes: 1 addition & 1 deletion android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 2.1.5
version: 2.1.6
apiversion: 2
description: External version of Map module to support new Google Map v2 sdk
author: Hieu Pham
Expand Down
8 changes: 7 additions & 1 deletion android/src/ti/map/AnnotationProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,18 @@ public int getIconImageHeight()
return iconImageHeight;
}

@Override
public boolean hasProperty(String name)
{
return (super.getProperty(name) != null);
}

@Override
public void onPropertyChanged(String name, Object value)
{
super.onPropertyChanged(name, value);

if (marker == null) {
if (marker == null || value == null) {
return;
}

Expand Down
20 changes: 15 additions & 5 deletions android/src/ti/map/RouteProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,15 @@ public void processOptions() {
public void addLocation(Object loc, ArrayList<LatLng> locationArray, boolean list) {
if (loc instanceof HashMap) {
HashMap<String, String> point = (HashMap<String, String>) loc;
LatLng location = new LatLng(TiConvert.toDouble(point.get(TiC.PROPERTY_LATITUDE)), TiConvert.toDouble(point.get(TiC.PROPERTY_LONGITUDE)));
if (list) {
locationArray.add(location);
} else {
options.add(location);
Object latitude = point.get(TiC.PROPERTY_LATITUDE);
Object longitude = point.get(TiC.PROPERTY_LONGITUDE);
if (longitude != null && latitude != null) {
LatLng location = new LatLng(TiConvert.toDouble(latitude), TiConvert.toDouble(longitude));
if (list) {
locationArray.add(location);
} else {
options.add(location);
}
}
}
}
Expand Down Expand Up @@ -152,5 +156,11 @@ else if (name.equals(TiC.PROPERTY_WIDTH)) {
}

}

@Override
public boolean hasProperty(String name)
{
return (super.getProperty(name) != null);
}

}
21 changes: 13 additions & 8 deletions android/src/ti/map/TiUIMapView.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ public void processMapProperties(KrollDict d)
public void propertyChanged(String key, Object oldValue, Object newValue, KrollProxy proxy)
{

if (newValue == null) {
return;
}

if (key.equals(TiC.PROPERTY_USER_LOCATION)) {
setUserLocationEnabled(TiConvert.toBoolean(newValue));
} else if (key.equals(MapModule.PROPERTY_USER_LOCATION_BUTTON)) {
Expand Down Expand Up @@ -256,21 +260,22 @@ public void updateCamera(HashMap<String, Object> dict)
// latitudeDelta / longitudeDelta bounds are centered on screen at the greatest possible zoom level.
boolean anim = animate;
if (dict.containsKey(TiC.PROPERTY_ANIMATE)) {
anim = TiConvert.toBoolean(dict, TiC.PROPERTY_ANIMATE);
anim = TiConvert.toBoolean(dict, TiC.PROPERTY_ANIMATE, animate);
}
if (dict.containsKey(MapModule.PROPERTY_BEARING)) {
bearing = TiConvert.toFloat(dict, MapModule.PROPERTY_BEARING);
bearing = TiConvert.toFloat(dict, MapModule.PROPERTY_BEARING, 0);
}
if (dict.containsKey(MapModule.PROPERTY_TILT)) {
tilt = TiConvert.toFloat(dict, MapModule.PROPERTY_TILT);
tilt = TiConvert.toFloat(dict, MapModule.PROPERTY_TILT, 0);
}
if (dict.containsKey(MapModule.PROPERTY_ZOOM)) {
zoom = TiConvert.toFloat(dict, MapModule.PROPERTY_ZOOM);
zoom = TiConvert.toFloat(dict, MapModule.PROPERTY_ZOOM, 0);
}
if (dict.containsKey(TiC.PROPERTY_LATITUDE)) {
// Workaround for toDouble since there is no method that allows you to set defaults
if (dict.containsKey(TiC.PROPERTY_LATITUDE) && dict.get(TiC.PROPERTY_LATITUDE) != null) {
latitude = TiConvert.toDouble(dict, TiC.PROPERTY_LATITUDE);
}
if (dict.containsKey(TiC.PROPERTY_LONGITUDE)) {
if (dict.containsKey(TiC.PROPERTY_LONGITUDE) && dict.get(TiC.PROPERTY_LONGITUDE) != null) {
longitude = TiConvert.toDouble(dict, TiC.PROPERTY_LONGITUDE);
}

Expand All @@ -281,11 +286,11 @@ public void updateCamera(HashMap<String, Object> dict)
cameraBuilder.tilt(tilt);
cameraBuilder.zoom(zoom);

if (dict.containsKey(TiC.PROPERTY_LATITUDE_DELTA)) {
if (dict.containsKey(TiC.PROPERTY_LATITUDE_DELTA) && dict.get(TiC.PROPERTY_LATITUDE_DELTA) != null) {
latitudeDelta = TiConvert.toDouble(dict, TiC.PROPERTY_LATITUDE_DELTA);
}

if (dict.containsKey(TiC.PROPERTY_LONGITUDE_DELTA)) {
if (dict.containsKey(TiC.PROPERTY_LONGITUDE_DELTA) && dict.get(TiC.PROPERTY_LONGITUDE_DELTA) != null) {
longitudeDelta = TiConvert.toDouble(dict, TiC.PROPERTY_LONGITUDE_DELTA);
}

Expand Down