Пример #1
0
        private void InitView()
        {
            binding.editSearch.AddTextChangedAction((s, start, before, count) =>
            {
                var visible = count > 0 || start > 0;
                ToggleCloseButtonVisible(visible);
            });


            binding.editSearch.Touch += (sender, e) =>
            {
                var evt = e.Event;
                if (evt.Action == MotionEventActions.Up)
                {
                    var shouldClear = false;
                    if (LocaleUtil.ShouldRtl(Context))
                    {
                        int rightEdgeOfRightDrawable = binding.editSearch.Left + GetCloseDrawable().Bounds.Width();
                        shouldClear = evt.RawX <= rightEdgeOfRightDrawable;
                    }
                    else
                    {
                        int leftEdgeOfRightDrawable = binding.editSearch.Right - GetCloseDrawable().Bounds.Width();
                        shouldClear = evt.RawX >= leftEdgeOfRightDrawable;
                    }

                    if (shouldClear)
                    {
                        ClearText();
                        e.Handled = true;
                    }
                }
                e.Handled = false;
            };
        }
            public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
            {
                var searchResult = GetItem(position);
                var itemBinding  = holder as SearchResultItemViewBinder;

                itemBinding.SetSearchResult(searchResult);

                var icon = ContextCompat.GetDrawable(Context, searchResult.iconRes);

                if (Build.VERSION.SdkInt >= Build.VERSION_CODES.JellyBeanMr1)
                {
                    itemBinding.txtType.SetCompoundDrawablesRelativeWithIntrinsicBounds(icon, null, null, null);
                }
                else if (LocaleUtil.ShouldRtl(Context))
                {
                    itemBinding.txtType.SetCompoundDrawablesWithIntrinsicBounds(null, null, icon, null);
                }
                else
                {
                    itemBinding.txtType.SetCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
                }

                BindText(itemBinding.txtSearchResult, searchResult, binding.searchToolbar.GetText());

                itemBinding.Root.SetOnClickAction(v =>
                                                  activityNavigator.ShowSessionDetail(Context as Activity, searchResult.session, REQ_DETAIL));
            }