public async void RefreshHubs(Hub reference, int quantity) { progress.Visibility = ViewStates.Visible; List<Hub> nearHubs = await reference.NearHubs(quantity); this.hubs.Clear(); this.hubs.AddRange(nearHubs); progress.Visibility = ViewStates.Gone; this.NotifyDataSetChanged(); }
private void OnPositionChanged(Geolocator sender, PositionChangedEventArgs e) { var geoCoordinate = new GeoCoordinate(e.Position.Coordinate.Latitude, e.Position.Coordinate.Longitude); var accuracy = e.Position.Coordinate.Accuracy; Dispatcher.BeginInvoke(async () => { pbLoading.Visibility = Visibility.Visible; mLocation.SetView(geoCoordinate, App.MAP_ZOOM); RefreshPin(geoCoordinate, accuracy); var mockHub = new Hub { Lat = geoCoordinate.Latitude, Lng = geoCoordinate.Longitude }; IList<HubViewModel> nearHubs = Enumerable.Empty<HubViewModel>().ToList(); try { nearHubs = (await mockHub.NearHubs(App.HUBS_IN_PROXIMITY, accuracy)) .Select(nh => new HubViewModel(nh)) .ToList(); } catch { MessageBox.Show("There was an error downloading the list of hubs. Please try again.", "error", MessageBoxButton.OK); } RefreshHubs(nearHubs); pbLoading.Visibility = Visibility.Collapsed; }); }