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