Example #1
0
        private void AddStations()
        {
            ShowLoader();
            Stations.Clear();
            SearchResults.Clear();

            cancellationTokenSource.Cancel();
            cancellationTokenSource = new CancellationTokenSource();

            Stations.AddRange(UnitOfWork.PublicStopRepository.GetNearby(30));

            timerMapMoved.Start();

            ShowStopsList();
        }
Example #2
0
        private void TimerTickSearch(object sender, EventArgs e)
        {
            timerSearch.Stop();

            ShowHeaderLoader();

            if (isStopSearch)
            {
                IEnumerable <PublicStop> stops = UnitOfWork.PublicStopRepository.GetByName(searchText);

                Stations.Clear();
                Stations.AddRange(stops);

                ShowStopsList();
                HideHeaderLoader();
            }
            else
            {
                cancellationTokenSource.Cancel();
                cancellationTokenSource = new CancellationTokenSource();

                Action search = async() =>
                {
                    try
                    {
                        SearchResults.Clear();
                        SearchResults.AddRange(await BumbleApiService.PlacesOfInterest(cancellationTokenSource.Token, user, SearchText, null));
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message != AppResources.ApiErrorTaskCancelled)
                        {
                            base.ShowPopup(CustomPopupMessageType.Error, ex.Message, AppResources.CustomPopupGenericOkMessage, null);
                        }

                        ClearSearchTextBox();
                    }

                    ShowSearchList();
                    HideHeaderLoader();
                };

                DispatcherHelper.CheckBeginInvokeOnUI(search);
            }
        }
Example #3
0
        protected override async Task FetchDataAsync()
        {
            var stations = await base.Api.GetAsync <List <StationModel> >(
                $"{Constants.Endpoints.Stations}?{Constants.ApiOptions.IncludeDeleted}");

            var regions = await base.Api.GetAsync <List <RegionModel> >(
                $"{Constants.Endpoints.Regions}?{Constants.ApiOptions.IncludeDeleted}");

            var castedStations = stations.Select(s => new StationViewModel(s, Save, Cancel));
            var castedRegions  = regions.Select(r => new RegionViewModel(r, Save, Cancel));

            Stations.AddRange(castedStations);
            Regions.AddRange(castedRegions);

            var selectedStationId = Navigator.GetNavigationData <Guid>();

            if (selectedStationId != null && selectedStationId != Guid.Empty)
            {
                this.Selected = Stations.FirstOrDefault(s => s.Id == selectedStationId);
            }
        }
Example #4
0
 /// <summary>
 /// Removes all irrelevant or doubled up stations from the stations list.
 /// </summary>
 public void RemoveIrrelevantStations()
 {
     Stations.Clear();
     Stations.AddRange(GetBestStationsDistChecked(true));
 }