Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 public void AddFavorite(BusStop busStop)
 {
     busStop.IsFavorite = true;
     _conn.BeginTransaction();
     _conn.Update(busStop);
     _conn.Commit();
 }
Exemplo n.º 3
0
 public void AddMostRecent(BusStop busStop)
 {
     busStop.LastAccess = DateTime.Now;
     _conn.Update(busStop);
 }
Exemplo n.º 4
0
 public void RemoveFavorite(BusStop busStop)
 {
     busStop.IsFavorite = false;
     _conn.BeginTransaction();
     _conn.Update(busStop);
     _conn.Commit();
 }
Exemplo n.º 5
0
 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);
 }
Exemplo n.º 6
0
        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();
            });
        }
Exemplo n.º 7
0
 private void GetRealTimeDataForBusStop(BusStop busStop)
 {
     ThreadPool.QueueUserWorkItem(o =>
          _sanntid.GetRealTimeData(busStop, stops => DisplayRealTimeData(busStop, stops)));
 }
Exemplo n.º 8
0
 public BusStopMapAnnotation(BusStop busStop)
 {
     _busStop = busStop;
 }
Exemplo n.º 9
0
 private void AddBusStopToMap(MKMapView map, BusStop busStop)
 {
     BusStopMapAnnotation annotation = new BusStopMapAnnotation(busStop);
     map.AddAnnotation(annotation);
 }
Exemplo n.º 10
0
 public BusStopViewController(BusStop stopInfo)
 {
     _busStop = stopInfo;
     _busStopRepository.AddMostRecent (_busStop);
     this.Title = _busStop.Name;
 }