public List<BusStop> GetBusStopsList(string busStopJson) { var jObject = JObject.Parse(busStopJson); var stops = new List<BusStop>(); foreach (var stop in jObject.SelectToken("Fermate")) { var id = GetTokenValue(stop.SelectToken("cinFermata")); var stopCode = GetTokenValue(stop.SelectToken("codAzNodo")); var name = GetTokenValue(stop.SelectToken("descrizione")); var lat = Convert.ToDouble(GetTokenValue(stop.SelectToken("lat"))); var lon = Convert.ToDouble(GetTokenValue(stop.SelectToken("lon"))); name = name.Replace(stopCode, "").Replace("()", "").Trim(); var location = ConvertWSCoordinates(lat, lon); var busStop = new BusStop(id, stopCode, name, location); busStop.TowardsCentre = stopCode[4].Equals('1'); stops.Add(busStop); } return stops; }
public void AddFavorite(BusStop busStop) { busStop.IsFavorite = true; _conn.BeginTransaction(); _conn.Update(busStop); _conn.Commit(); }
public void AddMostRecent(BusStop busStop) { busStop.LastAccess = DateTime.Now; _conn.Update(busStop); }
public void RemoveFavorite(BusStop busStop) { busStop.IsFavorite = false; _conn.BeginTransaction(); _conn.Update(busStop); _conn.Commit(); }
public void GetRealTimeData(BusStop busStop, Action<List<StopTime>> callback) { var client = GetClient(); client.getUserRealTimeForecastCompleted += (s, e) => { var stopTimes = new StopTimeConverter().GetStopTimes(e.Result); callback(stopTimes); }; client.getUserRealTimeForecastAsync(Authentication, GetHandShake(), busStop.Id); }
private void DisplayRealTimeData(BusStop stop, List<StopTime> stopTimes) { var sb = new StringBuilder(); sb.AppendLine("Sanntidsdata for " + stop.Name); foreach(var stopTime in stopTimes) { sb.AppendLine(stopTime.ToString()); } if(!stopTimes.Any()) { sb.AppendLine("Fant ingen data for holdeplassen."); } InvokeOnMainThread(() => { _result.Text += Environment.NewLine + sb.ToString(); _activityIndicator.StopAnimating(); }); }
private void GetRealTimeDataForBusStop(BusStop busStop) { ThreadPool.QueueUserWorkItem(o => _sanntid.GetRealTimeData(busStop, stops => DisplayRealTimeData(busStop, stops))); }
public BusStopMapAnnotation(BusStop busStop) { _busStop = busStop; }
private void AddBusStopToMap(MKMapView map, BusStop busStop) { BusStopMapAnnotation annotation = new BusStopMapAnnotation(busStop); map.AddAnnotation(annotation); }
public BusStopViewController(BusStop stopInfo) { _busStop = stopInfo; _busStopRepository.AddMostRecent (_busStop); this.Title = _busStop.Name; }