Ejemplo n.º 1
0
        protected override void InitBindings()
        {
            Bindings.Add(
                this.SetBinding(() => ViewModel.LoadingSpinnerVisibility).WhenSourceChanges(() =>
            {
                if (ViewModel.LoadingSpinnerVisibility)
                {
                    RecommendationItemLoading.Visibility = ViewStates.Visible;
                    return;
                }
                RecommendationItemLoading.Visibility = ViewStates.Gone;

                if (ViewModel.DetailItems.Count == 0 || RecommendationItemDetailsContainer.ChildCount > 0)
                {
                    return;
                }

                RecommendationItemDetailsContainer.SetAdapter(new RecommendationsFragmentDetailsAdapter(Activity,
                                                                                                        Resource.Layout.RecommendationItemDetailItem, ViewModel.DetailItems, true));
                RecommendationItemDescription.Text = ViewModel.Data.Description;
                RecommendationItemDepTitle.Text    = ViewModel.Data.DependentTitle;
                RecommendationItemRecTitle.Text    = ViewModel.Data.RecommendationTitle;
                if (ViewModel.Data.AnimeDependentData.ImgUrl != null)
                {
                    ImageService.Instance.LoadUrl(ViewModel.Data.AnimeDependentData.ImgUrl)
                    .FadeAnimation(false)
                    .Success(() => RecommendationItemDepImage.AnimateFadeIn())
                    .Into(RecommendationItemDepImage);
                }
                if (ViewModel.Data.AnimeRecommendationData.ImgUrl != null)
                {
                    ImageService.Instance.LoadUrl(ViewModel.Data.AnimeRecommendationData.ImgUrl)
                    .FadeAnimation(false)
                    .Success(() => RecommendationItemRecImage.AnimateFadeIn())
                    .Into(RecommendationItemRecImage);
                }
            }));

            RecommendationItemRecImageButton.SetCommand("Click", ViewModel.NavigateDepDetails);
            RecommendationItemDepImageButton.SetCommand("Click", ViewModel.NavigateRecDetails);
        }
Ejemplo n.º 2
0
        public void BindModel(RecommendationItemViewModel viewModel)
        {
            ViewModel = viewModel;

            if (RootView == null)
            {
                _delayForInit = true;
                return;
            }

            Bindings.ForEach(binding => binding.Detach());
            Bindings.Clear();

            Bindings.Add(
                this.SetBinding(() => ViewModel.LoadingSpinnerVisibility).WhenSourceChanges(() =>
            {
                if (ViewModel.LoadingSpinnerVisibility)
                {
                    RecommendationItemLoading.Visibility = ViewStates.Visible;
                    return;
                }
                else
                {
                    RecommendationItemLoading.Visibility = ViewStates.Gone;
                }



                RecommendationItemDescription.Text = ViewModel.Data.Description;
                RecommendationItemDepTitle.Text    = ViewModel.Data.DependentTitle;
                RecommendationItemRecTitle.Text    = ViewModel.Data.RecommendationTitle;
                if (ViewModel.Data.AnimeDependentData?.ImgUrl != null)
                {
                    RecommendationItemDepImage.Into(ViewModel.Data.AnimeDependentData.ImgUrl);
                }
                if (ViewModel.Data.AnimeRecommendationData?.ImgUrl != null)
                {
                    RecommendationItemRecImage.Into(ViewModel.Data.AnimeRecommendationData.ImgUrl);
                }

                if (ViewModel.DetailItems.Count == 0)
                {
                    return;
                }

                //Because adapter is slow here
                //
                RecommendationItemDetailItemType1.Text     = ViewModel.DetailItems[0].Item1;
                RecommendationItemDetailItemDepValue1.Text = ViewModel.DetailItems[0].Item2;
                if (string.IsNullOrEmpty(ViewModel.DetailItems[0].Item3))
                {
                    RecommendationItemDetailItemMyDepValue1.Visibility = ViewStates.Gone;
                }
                else
                {
                    RecommendationItemDetailItemMyDepValue1.Visibility = ViewStates.Visible;
                    RecommendationItemDetailItemMyDepValue1.Text       = ViewModel.DetailItems[0].Item3;
                }
                RecommendationItemDetailItemRecValue1.Text = ViewModel.DetailItems[0].Item4;
                if (string.IsNullOrEmpty(ViewModel.DetailItems[0].Item5))
                {
                    RecommendationItemDetailItemMyRecValue1.Visibility = ViewStates.Gone;
                }
                else
                {
                    RecommendationItemDetailItemMyRecValue1.Visibility = ViewStates.Visible;
                    RecommendationItemDetailItemMyRecValue1.Text       = ViewModel.DetailItems[0].Item5;
                }

                //
                RecommendationItemDetailItemType2.Text     = ViewModel.DetailItems[1].Item1;
                RecommendationItemDetailItemDepValue2.Text = ViewModel.DetailItems[1].Item2;
                if (string.IsNullOrEmpty(ViewModel.DetailItems[1].Item3))
                {
                    RecommendationItemDetailItemMyDepValue2.Visibility = ViewStates.Gone;
                }
                else
                {
                    RecommendationItemDetailItemMyDepValue2.Visibility = ViewStates.Visible;
                    RecommendationItemDetailItemMyDepValue2.Text       = ViewModel.DetailItems[1].Item3;
                }
                RecommendationItemDetailItemRecValue2.Text = ViewModel.DetailItems[1].Item4;
                if (string.IsNullOrEmpty(ViewModel.DetailItems[1].Item5))
                {
                    RecommendationItemDetailItemMyRecValue2.Visibility = ViewStates.Gone;
                }
                else
                {
                    RecommendationItemDetailItemMyRecValue2.Visibility = ViewStates.Visible;
                    RecommendationItemDetailItemMyRecValue2.Text       = ViewModel.DetailItems[1].Item5;
                }
                //
                RecommendationItemDetailItemType3.Text     = ViewModel.DetailItems[2].Item1;
                RecommendationItemDetailItemDepValue3.Text = ViewModel.DetailItems[2].Item2;
                if (string.IsNullOrEmpty(ViewModel.DetailItems[2].Item3))
                {
                    RecommendationItemDetailItemMyDepValue3.Visibility = ViewStates.Gone;
                }
                else
                {
                    RecommendationItemDetailItemMyDepValue3.Visibility = ViewStates.Visible;
                    RecommendationItemDetailItemMyDepValue3.Text       = ViewModel.DetailItems[2].Item3;
                }
                RecommendationItemDetailItemRecValue3.Text = ViewModel.DetailItems[2].Item4;
                if (string.IsNullOrEmpty(ViewModel.DetailItems[2].Item5))
                {
                    RecommendationItemDetailItemMyRecValue3.Visibility = ViewStates.Gone;
                }
                else
                {
                    RecommendationItemDetailItemMyRecValue3.Visibility = ViewStates.Visible;
                    RecommendationItemDetailItemMyRecValue3.Text       = ViewModel.DetailItems[2].Item5;
                }
                //
                RecommendationItemDetailItemType4.Text     = ViewModel.DetailItems[3].Item1;
                RecommendationItemDetailItemDepValue4.Text = ViewModel.DetailItems[3].Item2;
                if (string.IsNullOrEmpty(ViewModel.DetailItems[3].Item3))
                {
                    RecommendationItemDetailItemMyDepValue4.Visibility = ViewStates.Gone;
                }
                else
                {
                    RecommendationItemDetailItemMyDepValue4.Visibility = ViewStates.Visible;
                    RecommendationItemDetailItemMyDepValue4.Text       = ViewModel.DetailItems[3].Item3;
                }
                RecommendationItemDetailItemRecValue4.Text = ViewModel.DetailItems[3].Item4;
                if (string.IsNullOrEmpty(ViewModel.DetailItems[3].Item5))
                {
                    RecommendationItemDetailItemMyRecValue4.Visibility = ViewStates.Gone;
                }
                else
                {
                    RecommendationItemDetailItemMyRecValue4.Visibility = ViewStates.Visible;
                    RecommendationItemDetailItemMyRecValue4.Text       = ViewModel.DetailItems[3].Item5;
                }
                //
                RecommendationItemDetailItemType5.Text     = ViewModel.DetailItems[4].Item1;
                RecommendationItemDetailItemDepValue5.Text = ViewModel.DetailItems[4].Item2;
                if (string.IsNullOrEmpty(ViewModel.DetailItems[4].Item3))
                {
                    RecommendationItemDetailItemMyDepValue5.Visibility = ViewStates.Gone;
                }
                else
                {
                    RecommendationItemDetailItemMyDepValue5.Visibility = ViewStates.Visible;
                    RecommendationItemDetailItemMyDepValue5.Text       = ViewModel.DetailItems[4].Item3;
                }
                RecommendationItemDetailItemRecValue5.Text = ViewModel.DetailItems[4].Item4;
                if (string.IsNullOrEmpty(ViewModel.DetailItems[4].Item5))
                {
                    RecommendationItemDetailItemMyRecValue5.Visibility = ViewStates.Gone;
                }
                else
                {
                    RecommendationItemDetailItemMyRecValue5.Visibility = ViewStates.Visible;
                    RecommendationItemDetailItemMyRecValue5.Text       = ViewModel.DetailItems[4].Item5;
                }
                //
                RecommendationItemDetailItemType6.Text     = ViewModel.DetailItems[5].Item1;
                RecommendationItemDetailItemDepValue6.Text = ViewModel.DetailItems[5].Item2;
                if (string.IsNullOrEmpty(ViewModel.DetailItems[5].Item3))
                {
                    RecommendationItemDetailItemMyDepValue6.Visibility = ViewStates.Gone;
                }
                else
                {
                    RecommendationItemDetailItemMyDepValue6.Visibility = ViewStates.Visible;
                    RecommendationItemDetailItemMyDepValue6.Text       = ViewModel.DetailItems[5].Item3;
                }
                RecommendationItemDetailItemRecValue6.Text = ViewModel.DetailItems[5].Item4;
                if (string.IsNullOrEmpty(ViewModel.DetailItems[5].Item5))
                {
                    RecommendationItemDetailItemMyRecValue6.Visibility = ViewStates.Gone;
                }
                else
                {
                    RecommendationItemDetailItemMyRecValue6.Visibility = ViewStates.Visible;
                    RecommendationItemDetailItemMyRecValue6.Text       = ViewModel.DetailItems[5].Item5;
                }
            }));

            RecommendationItemRecImageButton.SetOnClickListener(new OnClickListener(view => ViewModel.NavigateRecDetails.Execute(null)));
            RecommendationItemDepImageButton.SetOnClickListener(new OnClickListener(view => ViewModel.NavigateDepDetails.Execute(null)));
        }