Ejemplo n.º 1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            NavMgr.RegisterBackNav(PageIndex.PageAnimeList, _lastArgs);
            _lastArgs = e.Parameter as ProfilePageNavigationArgs;

            base.OnNavigatedTo(e);
        }
Ejemplo n.º 2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            _lastArgs = e.Parameter as ProfilePageNavigationArgs;
            Utils.GetMainPageInstance().CurrentStatus = $"{Credentials.UserName} - Profile";


            base.OnNavigatedTo(e);
        }
Ejemplo n.º 3
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            _lastArgs = e.Parameter as ProfilePageNavigationArgs;
            ViewModelLocator.Main.CurrentStatus = $"{Credentials.UserName} - Profile";

            NavMgr.RegisterBackNav(PageIndex.PageAnimeList, null);

            base.OnNavigatedTo(e);
        }
Ejemplo n.º 4
0
 public void RegisterBackNav(ProfilePageNavigationArgs args)
 {
     RegisterBackNav(PageIndex.PageProfile, args);
 }
Ejemplo n.º 5
0
 public ProfilePageFragment(ProfilePageNavigationArgs args)
 {
     _args = args;
 }
Ejemplo n.º 6
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     _lastArgs = e.Parameter as ProfilePageNavigationArgs;
     base.OnNavigatedTo(e);
 }
Ejemplo n.º 7
0
        public async Task LoadProfileData(ProfilePageNavigationArgs args, bool force = false)
        {
            if (args == null)
            {
                args = PrevArgs;
            }
            else
            {
                PrevArgs = args;
            }

            if (args == null)
            {
                return;
            }

            AboutMeHtmlContent       = null;
            AboutMeWebViewVisibility = false;


            if (args.TargetUser == Credentials.UserName && args.AllowBackNavReset)
            {
                ViewModelLocator.NavMgr.ResetMainBackNav();
                if (ViewModelLocator.Mobile)
                {
                    ViewModelLocator.NavMgr.RegisterBackNav(PageIndex.PageAnimeList, null);
                }
            }

            if (_currUser == null || _currUser != args.TargetUser || force)
            {
                LoadingVisibility = true;
                await
                Task.Run(
                    async() =>
                    CurrentData = await new ProfileQuery(false, args?.TargetUser ?? "").GetProfileData(force));

                _currUser = args.TargetUser ?? Credentials.UserName;
            }
            FavAnime    = new List <AnimeItemViewModel>();
            FavManga    = new List <AnimeItemViewModel>();
            RecentManga = new List <AnimeItemViewModel>();
            RecentAnime = new List <AnimeItemViewModel>();
            ViewModelLocator.GeneralMain.CurrentStatus = $"{_currUser} - Profile";
            var authenticatedUser = args.TargetUser.Equals(Credentials.UserName,
                                                           StringComparison.CurrentCultureIgnoreCase);

            RaisePropertyChanged(() => CurrentData);
            LoadingVisibility = false;
            RaisePropertyChanged(() => IsPinned);
            RaisePropertyChanged(() => PinProfileVisibility);
            MalComments         = new ObservableCollection <MalComment>(CurrentData.Comments);
            FavouriteCharacters =
                new List <FavouriteViewModel>(
                    CurrentData.FavouriteCharacters.Select(character => new FavouriteViewModel(character)));
            FavouriteStaff =
                new List <FavouriteViewModel>(CurrentData.FavouritePeople.Select(staff => new FavouriteViewModel(staff)));

            CommentInputBoxVisibility = !string.IsNullOrEmpty(CurrentData.ProfileMemId); //posting restricted
            LoadingAboutMeVisibility  = AboutMeWebViewVisibility = false;
            if (authenticatedUser)
            {
                _initialized = true;
                var list = new List <AnimeItemViewModel>();
                foreach (var id in CurrentData.FavouriteAnime)
                {
                    var data = await ViewModelLocator.AnimeList.TryRetrieveAuthenticatedAnimeItem(id);

                    if (data != null)
                    {
                        list.Add((data as AnimeItemViewModel).ParentAbstraction.ViewModel);
                    }
                }
                FavAnime = list;
                list     = new List <AnimeItemViewModel>();
                foreach (var id in CurrentData.FavouriteManga)
                {
                    var data = await ViewModelLocator.AnimeList.TryRetrieveAuthenticatedAnimeItem(id, false);

                    if (data != null)
                    {
                        list.Add((data as AnimeItemViewModel).ParentAbstraction.ViewModel);
                    }
                }
                FavManga = list;
                list     = new List <AnimeItemViewModel>();
                foreach (var id in CurrentData.RecentAnime)
                {
                    var data = await ViewModelLocator.AnimeList.TryRetrieveAuthenticatedAnimeItem(id);

                    if (data != null)
                    {
                        list.Add((data as AnimeItemViewModel).ParentAbstraction.ViewModel);
                    }
                }
                RecentAnime = list;
                list        = new List <AnimeItemViewModel>();
                foreach (var id in CurrentData.RecentManga)
                {
                    var data = await ViewModelLocator.AnimeList.TryRetrieveAuthenticatedAnimeItem(id, false);

                    if (data != null)
                    {
                        list.Add((data as AnimeItemViewModel).ParentAbstraction.ViewModel);
                    }
                }
                RecentManga = list;
                MyFriends   = CurrentData.Friends;
            }
            else
            {
                if (!_animeLibraryDataStorage.OthersAbstractions.ContainsKey(args.TargetUser ?? ""))
                {
                    LoadingOhersLibrariesProgressVisiblity = true;
                    var data = new List <ILibraryData>();
                    await
                    Task.Run(
                        async() =>
                        data =
                        await
                        new LibraryListQuery(args.TargetUser, AnimeListWorkModes.Anime).GetLibrary(false));

                    var abstractions = new List <AnimeItemAbstraction>();
                    foreach (var libraryData in data)
                    {
                        abstractions.Add(new AnimeItemAbstraction(false, libraryData as AnimeLibraryItemData));
                    }

                    await
                    Task.Run(
                        async() =>
                        data =
                        await
                        new LibraryListQuery(args.TargetUser, AnimeListWorkModes.Manga).GetLibrary(false));

                    var mangaAbstractions = new List <AnimeItemAbstraction>();
                    foreach (
                        var libraryData in data)
                    {
                        mangaAbstractions.Add(new AnimeItemAbstraction(false, libraryData as MangaLibraryItemData));
                    }

                    lock (_animeLibraryDataStorage.OthersAbstractions)
                    {
                        if (!_animeLibraryDataStorage.OthersAbstractions.ContainsKey(args.TargetUser))
                        {
                            _animeLibraryDataStorage.OthersAbstractions.Add(args.TargetUser,
                                                                            new Tuple <List <AnimeItemAbstraction>, List <AnimeItemAbstraction> >(abstractions,
                                                                                                                                                  mangaAbstractions));
                        }
                    }

                    LoadingOhersLibrariesProgressVisiblity = false;
                }

                var source = _animeLibraryDataStorage.OthersAbstractions[args.TargetUser];
                var list   = new List <AnimeItemViewModel>();
                foreach (var id in CurrentData.FavouriteAnime)
                {
                    var data = source.Item1.FirstOrDefault(abs => abs.Id == id);

                    if (data != null)
                    {
                        list.Add(data.ViewModel);
                    }
                }
                FavAnime = list;
                list     = new List <AnimeItemViewModel>();
                foreach (var id in CurrentData.FavouriteManga)
                {
                    var data = source.Item2.FirstOrDefault(abs => abs.Id == id);

                    if (data != null)
                    {
                        list.Add(data.ViewModel);
                    }
                }
                FavManga = list;
                list     = new List <AnimeItemViewModel>();
                foreach (var id in CurrentData.RecentAnime)
                {
                    var data = source.Item1.FirstOrDefault(abs => abs.Id == id);

                    if (data != null)
                    {
                        list.Add(data.ViewModel);
                    }
                }
                RecentAnime = list;
                list        = new List <AnimeItemViewModel>();
                foreach (var id in CurrentData.RecentManga)
                {
                    var data = source.Item2.FirstOrDefault(abs => abs.Id == id);

                    if (data != null)
                    {
                        list.Add(data.ViewModel);
                    }
                }
                RecentManga = list;
            }
            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
            };

            EmptyRecentAnimeNoticeVisibility   = RecentAnime.Count == 0;
            EmptyRecentMangaNoticeVisibility   = RecentManga.Count == 0;
            EmptyFavCharactersNoticeVisibility = CurrentData.FavouriteCharacters.Count == 0;
            EmptyFavAnimeNoticeVisibility      = FavAnime.Count == 0;
            EmptyFavMangaNoticeVisibility      = FavManga.Count == 0;
            EmptyFavPeopleNoticeVisibility     = CurrentData.FavouritePeople.Count == 0;
            EmptyCommentsNoticeVisibility      = CurrentData.Comments.Count == 0;
            OnInitialized?.Invoke();
        }
Ejemplo n.º 8
0
 public void RegisterBackNav(ProfilePageNavigationArgs args)
 {
     //throw new NotImplementedException();
 }