public bool AllowDetailsNavigation { private get; set; } = true; //Disabled when draggig grid item public async void NavigateDetails(PageIndex? sourceOverride = null, object argsOverride = null) { if (!AllowDetailsNavigation || (Settings.SelectedApiType == ApiType.Hummingbird && !ParentAbstraction.RepresentsAnime) || ViewModelLocator.AnimeDetails.Id == Id) return; var id = Id; if (_seasonalState && Settings.SelectedApiType == ApiType.Hummingbird) //id switch { id = await new AnimeDetailsHummingbirdQuery(id).GetHummingbirdId(); } var navArgs = new AnimeDetailsPageNavigationArgs(id, Title, null, this, argsOverride ?? ViewModelLocator.GeneralMain.GetCurrentListOrderParams()) { Source = sourceOverride ?? (ParentAbstraction.RepresentsAnime ? PageIndex.PageAnimeList : PageIndex.PageMangaList), AnimeMode = ParentAbstraction.RepresentsAnime }; if (sourceOverride != null) navArgs.Source = sourceOverride.Value; ViewModelLocator.GeneralMain.Navigate(PageIndex.PageAnimeDetails,navArgs); }
public void RegisterBackNav(AnimeDetailsPageNavigationArgs args) { RegisterBackNav(PageIndex.PageAnimeDetails,args); }
public void RegisterBackNav(AnimeDetailsPageNavigationArgs args) { //throw new NotImplementedException(); }
public static AnimeDetailsPageFragment BuildInstance(object args) { _navArgs = args as AnimeDetailsPageNavigationArgs; return new AnimeDetailsPageFragment(); }
public async void Init(AnimeDetailsPageNavigationArgs param) { Initialized = false; LoadingGlobal = true; //wait for UI await Task.Delay(5); ViewModelLocator.GeneralMain.IsCurrentStatusSelectable = true; _loadingAlternate = false; //details reset _loadedDetails = _loadedReviews = _loadedRecomm = _loadedRelated = _loadedVideos = false; //basic init assignment _animeItemReference = param.AnimeItem; AnimeMode = param.AnimeMode; Id = param.Id; Title = param.Title; if (Settings.SelectedApiType == ApiType.Mal) MalId = Id; else MalId = -1; //we will find this thing later //is manga stuff visibile if (AnimeMode) { MyVolumesVisibility = false; HiddenPivotItemIndex = -1; } else { MyVolumesVisibility = true; HiddenPivotItemIndex = 1; } //Add/Rem IsRemoveAnimeButtonEnabled = false; IsAddAnimeButtonEnabled = false; //favs IsFavourite = FavouritesManager.IsFavourite(AnimeMode ? FavouriteType.Anime : FavouriteType.Manga, Id.ToString()); //staff CharactersGridVisibility = MangaCharacterGridVisibility = false; LoadCharactersButtonVisibility = true; AnimeStaffData = null; MangaCharacterData = null; //so there will be no floting start/end dates MyDetailsVisibility = false; StartDateValid = false; EndDateValid = false; _alternateImgUrl = null; if (AnimeMode) { Status1Label = "Watching"; Status5Label = "Plan to watch"; WatchedEpsLabel = "Watched\nepisodes"; UpdateEpsUpperLabel = "Watched\nepisodes"; } else { Status1Label = "Reading"; Status5Label = "Plan to read"; WatchedEpsLabel = "Read\nchapters"; UpdateEpsUpperLabel = "Read\nchapters"; LoadCharactersButtonVisibility = false; } if (_animeItemReference == null || _animeItemReference is AnimeSearchItemViewModel || (_animeItemReference is AnimeItemViewModel && !(_animeItemReference as AnimeItemViewModel).Auth)) //if we are from search or from unauthenticated item let's look for proper abstraction { var possibleRef = await ViewModelLocator.AnimeList.TryRetrieveAuthenticatedAnimeItem(param.Id, AnimeMode); if (possibleRef == null) // else we don't have this item { //we may only prepare for its creation AddAnimeVisibility = true; MyDetailsVisibility = false; } else _animeItemReference = possibleRef; } // else we already have it if ((_animeItemReference as AnimeItemViewModel)?.Auth ?? false) { //we have item on the list , so there's valid data here MyDetailsVisibility = true; AddAnimeVisibility = false; IsRemoveAnimeButtonEnabled = true; IsAddAnimeButtonEnabled = false; PopulateStartEndDates(); //tags if (Settings.SelectedApiType == ApiType.Mal) { var tags = string.IsNullOrEmpty(_animeItemReference.Notes) ? new List<string>() : _animeItemReference.Notes.Contains(",") ? _animeItemReference.Notes.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries) .ToList() : new List<string> {_animeItemReference.Notes}; var collection = new ObservableCollection<string>(tags); MyTags = collection; } } else { IsRemoveAnimeButtonEnabled = false; IsAddAnimeButtonEnabled = true; } switch (param.Source) { case PageIndex.PageSearch: case PageIndex.PageMangaSearch: ExtractData(param.AnimeElement); if (PrevArgs != null) ViewModelLocator.NavMgr.RegisterBackNav(PrevArgs); ViewModelLocator.NavMgr.RegisterBackNav(param.Source, param.PrevPageSetup); break; case PageIndex.PageAnimeList: case PageIndex.PageMangaList: case PageIndex.PageProfile: case PageIndex.PageHistory: case PageIndex.PageArticles: case PageIndex.PageForumIndex: case PageIndex.PageStaffDetails: case PageIndex.PageCharacterDetails: case PageIndex.PagePopularVideos: await FetchData(false, param.Source); if (PrevArgs != null) ViewModelLocator.NavMgr.RegisterBackNav(PrevArgs); if (ViewModelLocator.Mobile || (!ViewModelLocator.Mobile && param.Source != PageIndex.PageProfile)) ViewModelLocator.NavMgr.RegisterBackNav(param.Source, param.PrevPageSetup); break; case PageIndex.PageAnimeDetails: await FetchData(); if (param.RegisterBackNav) //we are already going back { ViewModelLocator.NavMgr.RegisterBackNav(param.PrevPageSetup as AnimeDetailsPageNavigationArgs); } break; case PageIndex.PageRecomendations: ExtractData(param.AnimeElement); if (PrevArgs != null) ViewModelLocator.NavMgr.RegisterBackNav(PrevArgs); ViewModelLocator.NavMgr.RegisterBackNav(param.Source, param.PrevPageSetup); break; } PrevArgs = param; PrevArgs.RegisterBackNav = false; PrevArgs.Source = PageIndex.PageAnimeDetails; Initialized = true; DetailsPivotSelectedIndex = param.SourceTabIndex; }