Esempio n. 1
0
        private void DeregisterWatcher()
        {
            SentCoordinateRequest = false;

            Messenger.Default.Unregister <GpsWatcherResponseMessage>(this);

            LoadingBarMessage.Send(LoadingBarMessageReason.Hide);
        }
Esempio n. 2
0
        public void RegisterWatcher()
        {
            SentCoordinateRequest = true;

            Messenger.Default.Register <GpsWatcherResponseMessage>(this, (action) => UserLocationFound(action));

            GpsWatcherMessage.Send(GpsWatcherMessageReason.Start);

            LoadingBarMessage.Send(LoadingBarMessageReason.Show);
        }
Esempio n. 3
0
        private void StopGpsWatcher()
        {
            if (watcher != null)
            {
                watcher.Stop();

                gpsWatcherStatus = GpsWatcherState.Stopped;

                LoadingBarMessage.Send(LoadingBarMessageReason.Hide);
            }
        }
Esempio n. 4
0
        private void PopulateTrip(Guid id)
        {
            if (SelectedPathOption.Trip != null)
            {
                TripMessage.Send(SelectedPathOption.Trip);
                return;
            }

            Action getTrip = async() =>
            {
                LoadingBarMessage.Send(LoadingBarMessageReason.Show);

                try
                {
                    if (cancellationTokenSource == null)
                    {
                        cancellationTokenSource = new CancellationTokenSource();
                    }
                    else
                    {
                        cancellationTokenSource.Cancel();
                        cancellationTokenSource = new CancellationTokenSource();
                    }
                    Trip trip = await BumbleApi.Trip(cancellationTokenSource.Token, user, id);

                    cancellationTokenSource = null;

                    PathOptions.Where(x => x.TripId == id).FirstOrDefault().Trip = trip;

                    SimpleIoc.Default.Unregister <PathResultsModel>();

                    SimpleIoc.Default.Register <PathResultsModel>(() =>
                    {
                        return(this);
                    });

                    TripMessage.Send(trip);
                }
                catch (Exception)
                {
                }

                cancellationTokenSource = null;

                LoadingBarMessage.Send(LoadingBarMessageReason.Hide);
            };

            DispatcherHelper.CheckBeginInvokeOnUI(getTrip);
        }
Esempio n. 5
0
        private void StartGpsWatcher()
        {
            if (gpsWatcherStatus != GpsWatcherState.Running)
            {
                LoadingBarMessage.Send(LoadingBarMessageReason.Show);
                // Prevent multiple view models from starting the watcher.
                gpsWatcherStatus = GpsWatcherState.Running;

                if (watcher == null)
                {
                    watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
                    watcher.MovementThreshold = 20;
                    watcher.StatusChanged    += new EventHandler <GeoPositionStatusChangedEventArgs>(WatcherStatusChanged);
                    watcher.PositionChanged  += new EventHandler <GeoPositionChangedEventArgs <GeoCoordinate> >(WatcherPositionChanged);
                    watcher.Start();
                }
                else
                {
                    watcher.Start();
                }
            }
        }
 private void HideHeaderLoader()
 {
     LoadingBarMessage.Send(LoadingBarMessageReason.Hide);
 }
 private void ShowHeaderLoader()
 {
     LoadingBarMessage.Send(LoadingBarMessageReason.Show);
 }
Esempio n. 8
0
 protected void HideHeaderLoader()
 {
     LoadingBarMessage.Send(LoadingBarMessageReason.Hide);
 }
Esempio n. 9
0
 protected void ShowHeaderLoader()
 {
     LoadingBarMessage.Send(LoadingBarMessageReason.Show);
 }
Esempio n. 10
0
        public void UserLocationFound(Coordinate coordinate)
        {
            if (sentCoordinateRequest)
            {
                sentCoordinateRequest = false;

                if (cancellationTokenSource == null || cancellationTokenSource.Token.IsCancellationRequested)
                {
                    ClearButton();
                    return;
                }

                // Change text to finding address.
                switch (this.Type)
                {
                case SearchType.Location:
                    // Check if still finding location (there is a chance that a favourite was loaded in this time).
                    if (TextLocation == AppResources.WhereToFindingLocationTextBoxWaterMark)
                    {
                        TextLocation = AppResources.WhereToFindingAddressWaterMark;
                    }
                    else
                    {
                        return;
                    }
                    break;

                case SearchType.Destination:
                    // Check if still finding location (there is a chance that a favourite was loaded in this time).
                    if (TextDestination == AppResources.WhereToFindingLocationTextBoxWaterMark)
                    {
                        TextDestination = AppResources.WhereToFindingAddressWaterMark;
                    }
                    else
                    {
                        return;
                    }
                    break;
                }

                Action getAddress = async() =>
                {
                    LoadingBarMessage.Send(LoadingBarMessageReason.Show);

                    try
                    {
                        Address userAddress = await BumbleApiService.ReverseGeoCode(cancellationTokenSource.Token, user, coordinate);

                        switch (this.Type)
                        {
                        case SearchType.Location:
                            // Check if still finding location (there is a chance that a favourite was loaded in this time).
                            if (TextLocation == AppResources.WhereToFindingAddressWaterMark)
                            {
                                TextLocation = userAddress.ShortAddressText;
                            }
                            else
                            {
                                LoadingBarMessage.Send(LoadingBarMessageReason.Hide);
                                return;
                            }
                            break;

                        case SearchType.Destination:
                            // Check if still finding location (there is a chance that a favourite was loaded in this time).
                            if (TextDestination == AppResources.WhereToFindingAddressWaterMark)
                            {
                                TextDestination = userAddress.ShortAddressText;
                            }
                            else
                            {
                                LoadingBarMessage.Send(LoadingBarMessageReason.Hide);
                                return;
                            }
                            break;
                        }

                        // Don't lose the user's location, so create a new address object.
                        TripOptions.SetAsAddress(userAddress);

                        OnChanged(EventArgs.Empty);
                    }
                    catch (Exception e)
                    {
                        ClearButton();

                        if (e.Message != "Cancelled")
                        {
                            Messenger.Default.Send <CustomPopupMessage>(new CustomPopupMessage(CustomPopupMessageType.Error, e.Message, AppResources.CustomPopupGenericOkMessage, null));
                        }
                    }

                    LoadingBarMessage.Send(LoadingBarMessageReason.Hide);
                };

                DispatcherHelper.CheckBeginInvokeOnUI(getAddress);
            }
        }
Esempio n. 11
0
        private void LoadAnnouncements()
        {
            if (isLoadingAnnouncements)
            {
                return;
            }

            isLoadingAnnouncements = true;

            IEnumerable <TransportMode> modes = UnitOfWork.TransportModeRepository.GetAll();

            if (!modes.Any(x => x.IsEnabled))
            {
                isLoadingAnnouncements = false;

                base.ShowPopup(CustomPopupMessageType.Error, AppResources.WhereToNoModesErrorPopupText, AppResources.CustomPopupGenericOkMessage, null);

                return;
            }

            IEnumerable <OperatorSetting> operatorSettings = UnitOfWork.OperatorSettingRepository.GetAll();

            if (!operatorSettings.Any(x => x.IsEnabled))
            {
                isLoadingAnnouncements = false;

                base.ShowPopup(CustomPopupMessageType.Error, AppResources.WhereToNoModesErrorPopupText, AppResources.CustomPopupGenericOkMessage, null);

                return;
            }

            Action loadAnnouncements = async() =>
            {
                LoadingBarMessage.Send(LoadingBarMessageReason.Show);

                try
                {
                    List <string> excludedModes     = modes.Where(x => x.IsEnabled == false).Select(x => x.ApplicationTransportMode.ToString()).ToList();
                    List <string> excludedOperators = operatorSettings.Where(x => x.IsEnabled == false).Select(x => x.OperatorName).ToList();

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

                    this.Announcements.Clear();
                    this.Announcements.AddRange(await BumbleApi.Announcements(cancellationTokenSource.Token, user, excludedModes, excludedOperators));
                }
                catch (Exception e)
                {
                    if (e.Message != "Cancelled")
                    {
                        base.ShowPopup(CustomPopupMessageType.Error, e.Message, AppResources.CustomPopupGenericOkMessage, null);
                    }
                }

                if (this.Announcements.Count() == 0)
                {
                    NoResultsVisibility = Visibility.Visible;
                }
                else
                {
                    NoResultsVisibility = Visibility.Collapsed;
                }

                isLoadingAnnouncements = false;
                LoadingBarMessage.Send(LoadingBarMessageReason.Hide);
            };

            DispatcherHelper.CheckBeginInvokeOnUI(loadAnnouncements);
        }