예제 #1
0
 public void HideBuildButtons()
 {
     foreach (ActionButtonType buttonType in buttonTypes)
     {
         ActionButton foundButton = ActionButtons.Instance.buttons.Find(item => item.ButtonType == buttonType);
         if (foundButton.GetType() == typeof(BuildButton))
         {
             foundButton.Hide();
         }
     }
 }
        protected override void InitBindings()
        {
            Bindings.Add(this.SetBinding(() => ViewModel.Clubs).WhenSourceChanges(() =>
            {
                if (ViewModel.MyClubs == null)
                {
                    List.ClearFlingAdapter();
                    List.Adapter = null;
                }
                else
                {
                    List.ClearFlingAdapter();
                    List.InjectFlingAdapter(ViewModel.Clubs, ViewHolderFactory, DataTemplateFull, DataTemplateFling, DataTemplateBasic, ContainerTemplate);
                }
            }));

            Bindings.Add(
                this.SetBinding(() => ViewModel.EmptyNoticeVisibility,
                                () => EmptyNotice.Visibility).ConvertSourceToTarget(Converters.BoolToVisibility));

            Bindings.Add(this.SetBinding(() => ViewModel.SearchQuery).WhenSourceChanges(() =>
            {
                if (!_settingQuery)
                {
                    SearchView.SetQuery(ViewModel.SearchQuery, false);
                }
                if (ViewModel.SearchQuery?.Length > 2)
                {
                    ActionButton.Show();
                }
                else
                {
                    ActionButton.Hide();
                }
            }));

            if (Build.VERSION.SdkInt >= BuildVersionCodes.M)
            {
                List.SetOnScrollChangeListener(new ScrollListener(i =>
                {
                    if (ViewModel.Loading || !ViewModel.MoreButtonVisibility || List.Adapter == null ||
                        ViewModel.QueryType == MalClubQueries.QueryType.My)
                    {
                        return;
                    }
                    if (List.Adapter.Count - List.FirstVisiblePosition <= 2)
                    {
                        ViewModel.MoreCommand.Execute(null);
                    }
                }));
            }


            SearchView.FindViewById(Resource.Id.search_close_btn).Alpha     = 1;
            SearchView.FindViewById(Resource.Id.search_close_btn).Clickable = true;
            SearchView.FindViewById(Resource.Id.search_close_btn).SetOnClickListener(new OnClickListener(view =>
            {
                SearchView.SetQuery("", false);
                ViewModel.SearchCommand.Execute(null);
            }));

            SearchView.QueryTextChange += SearchViewOnQueryTextChange;
            SearchView.QueryTextSubmit += SearchViewOnQueryTextSubmit;

            ActionButton.SetOnClickListener(new OnClickListener(v => OpenFiltersDrawer()));
        }