Beispiel #1
0
        private void SetSearchChoice(SearchItem searchItem)
        {
            TripOptions.SetAsAddress(new Address(searchItem.Name, searchItem.Name, searchItem.Location));

            switch (this.Type)
            {
            case SearchType.Location:
                // Change text to the search item name.
                TextLocation = searchItem.Name;

                ClearButtonVisibilityLocation = Visibility.Visible;
                break;

            case SearchType.Destination:
                // Change text to the search item name.
                TextDestination = searchItem.Name;

                ClearButtonVisibilityDestination = Visibility.Visible;;
                break;
            }

            OnChanged(EventArgs.Empty);
        }
Beispiel #2
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);
            }
        }