コード例 #1
0
        private View CreateCharacterDetailsView(AniList.Models.CharacterModels.Character character)
        {
            var retView         = LayoutInflater.Inflate(Resource.Layout.View_CharacterDetails, null);
            var imageView       = retView.FindViewById <ImageView>(Resource.Id.Character_Image);
            var descriptionView = retView.FindViewById <TextView>(Resource.Id.Character_Description);
            var nameView        = retView.FindViewById <TextView>(Resource.Id.Character_Name);
            var altNamesView    = retView.FindViewById <TextView>(Resource.Id.Character_AltNames);

            ImageLoader.LoadImage(imageView, character.Image?.Large);
            descriptionView.TextFormatted = FromHtml(character.Description ?? "(No Description Available)");
            nameView.Text = character.Name?.GetFormattedName(true);

            var altNames = character.Name?.Alternative?.Where(x => !string.IsNullOrWhiteSpace(x)).ToList();

            altNamesView.Text = altNames?.Any() == true
                ? $"Also known as: {string.Join(", ", altNames)}"
                : "";

            return(retView);
        }
コード例 #2
0
        public void SetupCharacterView(AniList.Models.CharacterModels.Character character)
        {
            var adapter = new FragmentlessViewPagerAdapter();

            adapter.AddView(CreateCharacterDetailsView(character), "Details");

            if (character.Anime?.PageInfo?.Total > 0)
            {
                adapter.AddView(CreateCharacterMediaView(character.Id, MediaType.Anime), "Anime");
            }

            if (character.Manga?.PageInfo?.Total > 0)
            {
                adapter.AddView(CreateCharacterMediaView(character.Id, MediaType.Manga), "Manga");
            }

            ViewPager.OffscreenPageLimit = adapter.Count - 1;
            ViewPager.Adapter            = adapter;

            TabLayout.SetupWithViewPager(ViewPager);
        }