コード例 #1
0
        private async void OuterPivotItemChanged(string tag)
        {
            if (!_initialized)
            {
                return;
            }
            switch (tag)
            {
            case "Favs":
                RecentManga = new ObservableCollection <AnimeItemViewModel>();
                RecentAnime = new ObservableCollection <AnimeItemViewModel>();
                InnerPivotItemChanged(CurrentlySelectedInnerPivotItem.Tag as string);
                _loadedRecent = false;
                break;

            case "Recent":
                if (_loadedRecent)
                {
                    break;
                }
                _loadedRecent = true;
                //in case of duplicate we have to clear this
                FavAnime        = new ObservableCollection <AnimeItemViewModel>();
                FavManga        = new ObservableCollection <AnimeItemViewModel>();
                _loadedFavManga = false;
                _loadedFavAnime = false;
                foreach (var id in CurrentData.RecentAnime)
                {
                    var data = await ViewModelLocator.AnimeList.TryRetrieveAuthenticatedAnimeItem(id);

                    if (data != null)
                    {
                        RecentAnime.Add(data as AnimeItemViewModel);
                    }
                }
                foreach (var id in CurrentData.RecentManga)
                {
                    var data = await ViewModelLocator.AnimeList.TryRetrieveAuthenticatedAnimeItem(id, false);

                    if (data != null)
                    {
                        RecentManga.Add(data as AnimeItemViewModel);
                    }
                }
                EmptyRecentAnimeNoticeVisibility = RecentAnime.Count == 0
                        ? Visibility.Visible
                        : Visibility.Collapsed;
                EmptyRecentMangaNoticeVisibility = RecentManga.Count == 0
                        ? Visibility.Visible
                        : Visibility.Collapsed;
                break;

            case "Stats":
                if (_loadedStats)
                {
                    return;
                }
                _loadedStats = true;
                await CurrentData.PopulateWatchStats();

                RaisePropertyChanged(() => CurrentData);
                AnimeChartValues = new List <int>
                {
                    CurrentData.AnimeWatching,
                    CurrentData.AnimeCompleted,
                    CurrentData.AnimeOnHold,
                    CurrentData.AnimeDropped,
                    CurrentData.AnimePlanned
                };
                MangaChartValues = new List <int>
                {
                    CurrentData.MangaReading,
                    CurrentData.MangaCompleted,
                    CurrentData.MangaOnHold,
                    CurrentData.MangaDropped,
                    CurrentData.MangaPlanned
                };
                break;
            }
        }