Permalink
Browse files

fixed a NullRefException when checking the distance.

  • Loading branch information...
1 parent c4a1337 commit b53016cd78d3392a84249f1b69133f0daabbf1b0 @topgenorth committed May 4, 2012
Showing with 7 additions and 5 deletions.
  1. +6 −5 dotnet/YegBuildings/model/BuildingHelper.cs
  2. +1 −0 dotnet/YegBuildings/views/BuildingRowHolder.cs
@@ -46,17 +46,18 @@ public static void SetSelectedBuildingIndex(this Bundle bundle, int index)
}
/// <summary>
- /// Returns the distance in metres to the specified location.
+ /// Returns the distance in metres to the specified location.
/// </summary>
- /// <param name="location"></param>
- /// <returns></returns>
+ /// <param name="location"> </param>
+ /// <returns> </returns>
public static int GetDistanceTo(this Building building, Location location)
{
- if (building == null)
+ if ((building == null) || (location == null))
+ {
return 0;
+ }
var buildingLocation = new Location("me") {Latitude = building.Latitude, Longitude = building.Longitude};
return (int) buildingLocation.DistanceTo(location);
-
}
}
}
@@ -37,6 +37,7 @@ public void PopulateFrom(Building building, Location location)
if (location == null)
{
_distanceView.Visibility = ViewStates.Gone;
+ return;
}
_distanceView.Text = building.GetDistanceTo(location) + " metres.";

0 comments on commit b53016c

Please sign in to comment.