public override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { if (mode != NavigationMode.Back) { ExecuteLoadBusStops(); } else { if (positions != null) { MapArea = GeoboundingBox.TryCompute(positions); if (MapArea != null) { Messenger.Default.Send <GeoboundingBoxMessage>(new GeoboundingBoxMessage(MapArea)); } } } Messenger.Default.Register <BusStopMessage>(this, (message) => { Debug.WriteLine($"Bus stop selected: {message.Payload.Title} - {message.Payload.AtcoCode}"); var parameters = new BusStopParameter(message.Payload.Title, message.Payload.AtcoCode); NavigationService.Navigate(typeof(BusStopDetailPage), parameters); }); return(Task.CompletedTask); }
private async Task getDepartures(BusStopParameter parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } using (var client = new TransportApiClient(ApiCredentials.appId, ApiCredentials.appKey)) { if (!(bool)UseLiveData) { var response = await client.BusTimetable(parameters.AtcoCode, DateTime.Now, true); if (response == null) { CommandBarTitle = $"Could not retrieve departures!"; } else { CommandBarTitle = $"Next buses from {parameters.StopName}"; populateTimetableDepartures(response); } } else { var response = await client.BusLive(parameters.AtcoCode, true, nextBuses : true); if (response == null) { CommandBarTitle = $"Could not retrieve departures!"; } else { CommandBarTitle = $"Next buses from {parameters.StopName}"; populateLiveDepartures(response); } } } }