コード例 #1
0
        public static void ApplyTo(EditText addressTextField, EditText numberTextField, Func <Address> currentAddress, Action <string> streetNumberOfAddressUpdated)
        {
            numberTextField.Text = "";

            numberTextField.EditorAction += (s, e) =>
            {
                if (e.ActionId == ImeAction.Done)
                {
                    numberTextField.ClearFocus();
                }
            };

            numberTextField.FocusChange += (s, e) =>
            {
                if (e.HasFocus)
                {
                    FocusOnNumber(addressTextField, numberTextField, currentAddress);
                    numberTextField.ShowKeyboard();
                }
                else
                {
                    var currentAddressValue = currentAddress();
                    currentAddressValue.ChangeStreetNumber(numberTextField.Text);

                    var newFullAddress = currentAddressValue.DisplayAddress;
                    if (streetNumberOfAddressUpdated != null)
                    {
                        streetNumberOfAddressUpdated(numberTextField.Text);
                    }
                    addressTextField.Text = newFullAddress;
                    numberTextField.Text  = "";
                    numberTextField.HideKeyboard();
                }
            };
        }
コード例 #2
0
        public static void ApplyTo(EditText editText, Action onFocus, Action onLostFocus)
        {
            if (editText == null)
            {
                return;
            }

            editText.FocusChange += (sender, e) =>
            {
                if (e.HasFocus)
                {
                    editText.ShowKeyboard();
                    onFocus();
                }
                else
                {
                    onLostFocus();
                    editText.HideKeyboard();
                }
            };

            editText.EditorAction += (sender, e) =>
            {
                if (e.ActionId == ImeAction.Done)
                {
                    editText.ClearFocus();
                }

                e.Handled = false;
            };
        }
コード例 #3
0
        public AddressPicker(Context context, IAttributeSet attrs) : base(Resource.Layout.Control_AddressPicker, context, attrs)
        {
            this.DelayBind(() =>
            {
                _searchList               = Content.FindViewById <LinearLayout>(Resource.Id.SearchList);
                _defaultList              = Content.FindViewById <LinearLayout>(Resource.Id.DefaultList);
                _favoriteAddressList      = Content.FindViewById <AddressListView>(Resource.Id.FavoriteAddressList);
                _recentAddressList        = Content.FindViewById <AddressListView>(Resource.Id.RecentAddressList);
                _nearbyAddressList        = Content.FindViewById <AddressListView>(Resource.Id.NearbyAddressList);
                _searchResultsAddressList = Content.FindViewById <AddressListView>(Resource.Id.SearchResultsAddressList);
                _addressEditText          = Content.FindViewById <EditText>(Resource.Id.addressEditText);
                _crossImageButton         = Content.FindViewById <ImageButton>(Resource.Id.crossImageButton);
                _scrollView               = Content.FindViewById <ScrollView>(Resource.Id.scrollView);
                _cancelButton             = Content.FindViewById <Button>(Resource.Id.cancelButton);

                _addressEditText.SetSelectAllOnFocus(true);
                _addressEditText.FocusChange += (sender, eventargs) =>
                {
                    if (_addressEditText.HasFocus)
                    {
                        _crossImageButton.Visibility = _addressEditText.Text == string.Empty ? ViewStates.Gone : ViewStates.Visible;
                        _crossImageButton.Click     += (s, e) => { _addressEditText.Text = string.Empty; };
                    }
                };
                _addressEditText.OnKeyDown()
                .Throttle(TimeSpan.FromMilliseconds(700))
                .ObserveOn(SynchronizationContext.Current)
                .Subscribe(text =>
                {
                    if (_addressEditText.HasFocus)
                    {
                        ExecuteSearchCommand(text);
                    }
                });

                _addressEditText.EditorAction += (sender, args) =>
                {
                    _crossImageButton.Visibility = ViewStates.Visible;
                    if (args.ActionId != ImeAction.Go)
                    {
                        return;
                    }
                };

                _scrollView.Touch += (s, e) =>
                {
                    _addressEditText.HideKeyboard();
                    e.Handled = false;
                };

                InitializeBinding();

                _searchResultsAddressList.OnSelectAddress = _nearbyAddressList.OnSelectAddress = _recentAddressList.OnSelectAddress = _favoriteAddressList.OnSelectAddress = address =>
                {
                    SelectedCommand.Execute(address);
                };
            });
        }
コード例 #4
0
        public void Close()
        {
            _addressEditText.HideKeyboard();
            _favoriteAddressList.Collapse();
            _recentAddressList.Collapse();
            _nearbyAddressList.Collapse();

            _collectionChangedSubscription.Disposable = null;
        }