Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added regex fix and updated API url.

  • Loading branch information...
commit a893ace1870d1e717c3e0d0b452c1c22b6338840 1 parent 16525b2
@follesoe authored
View
6 MonoBus/BusBuddy.cs
@@ -10,7 +10,7 @@ public class BusBuddy
public BusBuddy()
{
- _restClient = new RestClient("http://api.busbuddy.norrs.no:8080/api/1.2/");
+ _restClient = new RestClient("http://api.busbuddy.no/api/1.3");
_restClient.AddDefaultParameter("apiKey", "HwSJ6xL9wCUnpegC");
}
@@ -24,9 +24,9 @@ public void GetBusStops(Action<BusStopResponse> callback)
});
}
- public void GetDepartures(int busStopId, Action<DeparturesResponse> callback)
+ public void GetDepartures(int locationId, Action<DeparturesResponse> callback)
{
- var request = new RestRequest("departures/" + busStopId);
+ var request = new RestRequest("departures/" + locationId);
request.RequestFormat = DataFormat.Json;
_restClient.ExecuteAsync<DeparturesResponse>(request, (RestResponse<DeparturesResponse> response) => {
View
19 MonoBus/Model/BusStop.cs
@@ -1,11 +1,28 @@
using System;
+using System.Text.RegularExpressions;
namespace MonoBus
{
public class BusStop
{
+ private static Regex _nameRegex = new Regex(@"\((\d+)\)");
+
public int BusStopId { get; set; }
- public string Name { get; set; }
+
+ private string _name;
+ public string Name
+ {
+ get { return _name; }
+ set
+ {
+ if(_nameRegex.IsMatch(value)) {
+ _name = _nameRegex.Replace(value, "").Trim();
+ } else {
+ _name = value;
+ }
+ }
+ }
+
public string NameWithAbbreviations { get; set; }
public string BusStopMaintainer { get; set; }
public int LocationId { get; set; }
View
1  MonoBus/MonoBus.csproj
@@ -64,6 +64,7 @@
<Reference Include="RestSharp.MonoTouch">
<HintPath>..\lib\RestSharp.MonoTouch.dll</HintPath>
</Reference>
+ <Reference Include="MonoTouch.Dialog-1" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
View
2  MonoBus/Views/DeparturesTable.cs
@@ -46,7 +46,7 @@ public void LoadDepartures()
_tvc.TableView.ReloadData();
}
- _busBuddy.GetDepartures(_tvc.SelectedBusStop.BusStopId, response => {
+ _busBuddy.GetDepartures(_tvc.SelectedBusStop.LocationId, response => {
_tvc.Response = response;
InvokeOnMainThread(() => _tvc.TableView.ReloadData());
});
Please sign in to comment.
Something went wrong with that request. Please try again.