/// <summary> /// Refreshes the data. /// </summary> protected override async Task RefreshAsync(bool force, CancellationToken token) { if (Settings.Stations.Count == 0) { var defaultStationsResponse = await _transportService.GetDefaultStationsAsync(token); if (defaultStationsResponse.Status != TransportStatus.Success) { throw new Exception("An error occurred on the server while fetching the default stations."); } Settings.Stations = new ObservableCollection <Station>(defaultStationsResponse.Stations); } if (SelectedStation == null && Settings.SortByPosition) { var locationAndStatus = await _locationService.GetLocationAsync(); var location = locationAndStatus.Item1; LocationStatus = locationAndStatus.Item2; if (LocationStatus != GeoLocationStatus.Error) { SelectedStation = Settings.Stations.OrderBy(s => s.Position.DistanceTo(location)).First(); } } if (SelectedStation == null) { SelectedStation = Settings.Stations.First(); } if (!token.IsCancellationRequested) { Trips = Settings.Stations .Where(s => s != SelectedStation) .Select(to => new StationTrips(_transportService, SelectedStation, to)) .ToArray(); foreach (var trip in Trips) { trip.StartRefresh(); } } }