private void UpdateGridView()
        {
            GridView.ClearFlingAdapter();
            switch (_mode)
            {
            case DisplayMode.Members:
                MembersToggle.Checked      = true;
                RelatedAnimeToggle.Checked = RelatedMangaToggle.Checked = false;

                _gridHelper.DetachGrid(GridView);
                GridView.SetColumnWidth(DimensionsHelper.DpToPx(70));
                GridView.LayoutParameters.Width = -1;
                GridView.SetNumColumns(-1);
                GridView.InjectFlingAdapter(ViewModel.Members, MemberDataTemplateFull, MemberDataTemplateFling, MemberContainerTemplate);
                break;

            case DisplayMode.Anime:
                RelatedAnimeToggle.Checked = true;
                MembersToggle.Checked      = RelatedMangaToggle.Checked = false;

                _gridHelper.RegisterGrid(GridView);
                GridView.SetColumnWidth(0);
                GridView.InjectFlingAdapter(ViewModel.AnimeRelations, DataTemplateFull, DataTemplateFling, AnimeContainerTemplate, DataTemplateBasic);
                break;

            case DisplayMode.Manga:
                RelatedMangaToggle.Checked = true;
                RelatedAnimeToggle.Checked = MembersToggle.Checked = false;

                _gridHelper.RegisterGrid(GridView);
                GridView.SetColumnWidth(0);
                GridView.InjectFlingAdapter(ViewModel.MangaRelations, DataTemplateFull, DataTemplateFling, MangaContainerTemplate, DataTemplateBasic);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #2
0
        private View GetTemplateDelegate(int i, Tuple <string, List <AnimeItemViewModel> > tuple, View convertView)
        {
            var view = convertView;

            if (view == null)
            {
                view = MainActivity.CurrentContext.LayoutInflater.Inflate(
                    Resource.Layout.CalendarPageSummaryTabContent, null);
            }

            view.FindViewById <TextView>(Resource.Id.CalendarPageSummaryTabContentHeader).Text = tuple.Item1;
            var grid = view.FindViewById <HeightAdjustingGridView>(Resource.Id.CalendarPageSummaryTabContentList);

            grid.AlwaysAdjust = true;
            grid.InjectAnimeListAdapter(Context, tuple.Item2, AnimeListDisplayModes.IndefiniteGrid, OnItemClick, false, true);
            _gridViewColumnHelper.RegisterGrid(grid);

            return(view);
        }
Exemple #3
0
        private View GetTemplateDelegate(int i, Tuple <string, List <AnimeItemViewModel> > tuple, View convertView)
        {
            var view = convertView;

            if (view == null)
            {
                view = MainActivity.CurrentContext.LayoutInflater.Inflate(
                    Resource.Layout.CalendarPageSummaryTabContent, null);
            }

            view.FindViewById <TextView>(Resource.Id.CalendarPageSummaryTabContentHeader).Text = tuple.Item1;
            var grid = view.FindViewById <GridView>(Resource.Id.CalendarPageSummaryTabContentList);

            grid.Adapter = new AnimeListItemsAdapter(MainActivity.CurrentContext,
                                                     Resource.Layout.AnimeGridItem, tuple.Item2, (model, view1, fling) => new AnimeGridItemBindingInfo(view1, model, fling, false));
            _gridViewColumnHelper.RegisterGrid(grid);

            return(view);
        }
        protected override void InitBindings()
        {
            CharacterDetailsPageAnimeographyGrid.AlwaysAdjust        =
                CharacterDetailsPageMangaographyGrid.AlwaysAdjust    =
                    CharacterDetailsPageVoiceActorsGrid.AlwaysAdjust = true;

            _gridViewColumnHelper.RegisterGrid(CharacterDetailsPageVoiceActorsGrid);
            _gridViewColumnHelper.RegisterGrid(CharacterDetailsPageMangaographyGrid);
            _gridViewColumnHelper.RegisterGrid(CharacterDetailsPageAnimeographyGrid);

            Bindings.Add(this.SetBinding(() => ViewModel.AnimeographyVisibility).WhenSourceChanges(() =>
            {
                if (ViewModel.AnimeographyVisibility)
                {
                    CharacterDetailsPageAnimeographyGrid.Visibility        = ViewStates.Visible;
                    CharacterDetailsPageAnimeographyEmptyNotice.Visibility = ViewStates.Gone;
                }
                else
                {
                    CharacterDetailsPageAnimeographyGrid.Visibility        = ViewStates.Gone;
                    CharacterDetailsPageAnimeographyEmptyNotice.Visibility = ViewStates.Visible;
                }
            }));
            Bindings.Add(this.SetBinding(() => ViewModel.MangaographyVisibility).WhenSourceChanges(() =>
            {
                if (ViewModel.MangaographyVisibility)
                {
                    CharacterDetailsPageMangaographyGrid.Visibility        = ViewStates.Visible;
                    CharacterDetailsPageMangaographyEmptyNotice.Visibility = ViewStates.Gone;
                }
                else
                {
                    CharacterDetailsPageMangaographyGrid.Visibility        = ViewStates.Gone;
                    CharacterDetailsPageMangaographyEmptyNotice.Visibility = ViewStates.Visible;
                }
            }));

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

            Bindings.Add(this.SetBinding(() => ViewModel.VoiceActors).WhenSourceChanges(() =>
            {
                if (ViewModel.VoiceActors == null)
                {
                    CharacterDetailsPageVoiceActorsGrid.Adapter = null;
                }
                else
                {
                    CharacterDetailsPageVoiceActorsGrid.Adapter = ViewModel.VoiceActors.GetAdapter(GetTemplateDelegate);
                }
            }));

            Bindings.Add(this.SetBinding(() => ViewModel.Data).WhenSourceChanges(() =>
            {
                if (ViewModel.VoiceActors == null)
                {
                    CharacterDetailsPageVoiceActorsGrid.Adapter = null;
                }
                else
                {
                    CharacterDetailsPageVoiceActorsGrid.Adapter = ViewModel.VoiceActors.GetAdapter(GetTemplateDelegate);
                }
            }));

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

            Bindings.Add(this.SetBinding(() => ViewModel.Data).WhenSourceChanges(() =>
            {
                if (ViewModel.Data == null)
                {
                    return;
                }

                CharacterDetailsPageDescription.Text = ViewModel.Data.Content;
                if (string.IsNullOrWhiteSpace(ViewModel.Data.ImgUrl))
                {
                    CharactersDetailsPageNoImgNotice.Visibility = ViewStates.Visible;
                }
                else
                {
                    CharactersDetailsPageNoImgNotice.Visibility = ViewStates.Gone;
                    CharacterDetailsPageImage.Into(ViewModel.Data.ImgUrl, null, img => img.HandleScaling());
                }
                CharactersPageFavButton.BindModel(ViewModel.FavouriteViewModel);

                if (ViewModel.Data.Animeography.Any())
                {
                    CharacterDetailsPageAnimeographyGrid.Adapter =
                        ViewModel.Data.Animeography.GetAdapter(GetTemplateDelegate);
                }
                if (ViewModel.Data.Mangaography.Any())
                {
                    CharacterDetailsPageMangaographyGrid.Adapter =
                        ViewModel.Data.Mangaography.GetAdapter(GetTemplateDelegate);
                }
            }));

            CharacterDetailsPageVoiceActorsGrid.EmptyView = CharacterDetailsPageVoiceActorsEmptyNotice;

            CharacterDetailsPageSpoilerButton.Click += CharacterDetailsPageSpoilerButtonOnClick;
            CharacterDetailsPageLinkButton.SetOnClickListener(new OnClickListener(view => ViewModel.OpenInMalCommand.Execute(null)));
        }