Example #1
0
        //This only runs the first time the page is made, so when a user first logs in (due to page caching)
        protected override async void OnInitialize()//
        {
            base.OnInitialize();
            currentUserName = AppDataAccessor.GetUsername();
            BindableCollection <Season> downloadedSeasons = await DownloadAccessor.Instance.GetDownloadsModel(true);

            if (ServiceAccessor.ConnectedToInternet())
            {
                SeasonsDropDown = await GetSortedSeasons();
            }
            else
            {
                SeasonsDropDown = downloadedSeasons;
            }

            string savedSeasonId = AppDataAccessor.GetTeamContext().seasonID;

            if (savedSeasonId != null && SeasonsDropDown.Any())
            {
                SelectedSeason = SeasonsDropDown.Where(u => u.seasonId == savedSeasonId).FirstOrDefault() ?? SeasonsDropDown[0];
            }
            else
            {
                SelectedSeason = SeasonsDropDown.LastOrDefault(u => u.year >= DateTime.Now.Year) ?? SeasonsDropDown[0];
                AppDataAccessor.SetTeamContext(SelectedSeason.seasonId, SelectedSeason.owningTeam.teamID);
            }

            if (!SeasonsDropDown.Any())
            {
                //show message here if no seasons
            }
        }
Example #2
0
        protected override void OnActivate()//called every page load
        {
            base.OnActivate();
            if (currentUserName != AppDataAccessor.GetUsername())
            {
                Groups = new BindableCollection <HubGroupViewModel>();//clears old page after logout
                OnInitialize();
            }
            SettingsPane.GetForCurrentView().CommandsRequested += CharmsData.SettingCharmManager_HubCommandsRequested;

            ProgressRingVisibility = Visibility.Collapsed;
            ProgressRingIsActive   = false;

            PageIsEnabled = true;
            LastViewedResponse response = AppDataAccessor.GetLastViewed();

            if (response.ID != null && ServiceAccessor.ConnectedToInternet())
            {
                Game LastViewedGame = new Game {
                    gameId = response.ID, opponent = response.name, date = DateTime.Parse(response.timeStamp)
                };                                                                                                                           //this is actually a playlist - not a game
                GameViewModel lastViewed = new GameViewModel(LastViewedGame, true, isLastviewed: true);
                lastViewed.Thumbnail = response.thumbnail;
                lastViewed.Stretch   = "UniformToFill";
                LastViewedVM         = new HubGroupViewModel()
                {
                    Name = "Last Viewed", Games = new BindableCollection <GameViewModel>()
                };
                LastViewedVM.Games.Add(lastViewed);

                if (Groups.Count == 0 && (NoScheduleEntriesText == null || NoScheduleEntriesText == ""))
                {
                    ProgressRingVisibility = Visibility.Visible;
                    ProgressRingIsActive   = true;
                }

                if (Groups.Count >= 3)
                {
                    HubGroupViewModel oldLastViewed = Groups.Where(u => u.Name == "Last Viewed").FirstOrDefault();
                    if (oldLastViewed != null)
                    {
                        Groups[Groups.IndexOf(oldLastViewed)] = LastViewedVM;
                    }
                    else
                    {
                        Groups.Insert(1, LastViewedVM);
                    }
                }
            }
        }
Example #3
0
        public async Task AddClipsAndHeadersForPlaylist(Playlist playlist)
        {
            if (ServiceAccessor.ConnectedToInternet())
            {
                playlist.clips = new BindableCollection <Clip>();
                ClipResponse response = await ServiceAccessor.GetPlaylistClipsAndHeaders(playlist.playlistId);

                if (response.status == SERVICE_RESPONSE.SUCCESS)
                {
                    playlist.clips          = response.clips;
                    playlist.displayColumns = response.DisplayColumns;
                }
                else
                {
                }
            }
        }
Example #4
0
        public async Task FetchThumbnailsAndPlaylistCounts()
        {
            int numLists = 0;

            if (ServiceAccessor.ConnectedToInternet())
            {
                // Get the playlists for the game
                PlaylistResponse playResponse = await ServiceAccessor.GetCategoryPlaylists(GameModel.categories.ToList());

                foreach (Category cat in GameModel.categories)
                {
                    cat.playlists = playResponse.playlists[cat.categoryId];
                }

                // Count the playlists and get a thumbnail
                foreach (KeyValuePair <string, BindableCollection <Playlist> > entry in playResponse.playlists)
                {
                    numLists += entry.Value.Count;

                    if (Thumbnail == "ms-appx:///Assets/hudl-mark-gray.png")
                    {
                        foreach (Playlist playlist in entry.Value)
                        {
                            if (playlist.thumbnailLocation != null)
                            {
                                Thumbnail = playlist.thumbnailLocation;
                                Stretch   = "UniformToFill";
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (Category cat in GameModel.categories)
                {
                    numLists += cat.playlists.Count;
                }
            }
            //Populate the NumPlaylists field with the counter
            NumPlaylists = numLists.ToString();
        }
Example #5
0
        private void PopulateGroups()
        {
            BindableCollection <HubGroupViewModel> NewGroups = new BindableCollection <HubGroupViewModel>();

            //If these aren't set here, if there is no schedule, these still link to another season's next and last games.
            _previousGame = null;
            _nextGame     = null;

            games = selectedSeason.games;
            if (ServiceAccessor.ConnectedToInternet())
            {
                games = selectedSeason.games;

                GetNextPreviousGames();
                NextGameVM.Games = new BindableCollection <GameViewModel>();
                LastGameVM.Games = new BindableCollection <GameViewModel>();

                if (_previousGame != null)
                {
                    GameViewModel previous = new GameViewModel(_previousGame, true, isPreviousGame: true);
                    previous.FetchPlaylists = previous.FetchThumbnailsAndPlaylistCounts();
                    previous.IsLargeView    = true;
                    LastGameVM.Games.Add(previous);
                }
                if (_nextGame != null)
                {
                    GameViewModel next = new GameViewModel(_nextGame, true, isNextGame: true);
                    next.IsLargeView    = true;
                    next.FetchPlaylists = next.FetchThumbnailsAndPlaylistCounts();
                    NextGameVM.Games.Add(next);
                }

                LastViewedResponse response = AppDataAccessor.GetLastViewed();
                if (response.ID != null)
                {
                    NewGroups.Add(LastViewedVM);
                }

                if (NextGameVM.Games.Count() > 0)
                {
                    NewGroups.Add(NextGameVM);
                }
                if (LastGameVM.Games.Count() > 0)
                {
                    NewGroups.Add(LastGameVM);
                }
            }

            if (games != null)
            {
                HubGroupViewModel schedule = new HubGroupViewModel()
                {
                    Name = "Schedule", Games = new BindableCollection <GameViewModel>()
                };
                HubGroupViewModel otherItems = new HubGroupViewModel()
                {
                    Name = "Other", Games = new BindableCollection <GameViewModel>()
                };
                foreach (Game g in games)
                {
                    GameViewModel gamevm = new GameViewModel(g);
                    gamevm.FetchPlaylists = gamevm.FetchThumbnailsAndPlaylistCounts();
                    if (g.Classification == 1)
                    {
                        schedule.Games.Add(gamevm);
                    }
                    else
                    {
                        otherItems.Games.Add(gamevm);
                    }
                }
                if (schedule.Games.Count > 0)
                {
                    NewGroups.Add(schedule);
                }
                if (otherItems.Games.Count > 0)
                {
                    NewGroups.Add(otherItems);
                }
            }

            ProgressRingVisibility = Visibility.Collapsed;
            ProgressRingIsActive   = false;

            if (NewGroups.Count == 0)
            {
                NoScheduleEntriesText = "There are no schedule entries for this season";
            }
            else
            {
                NoScheduleEntriesText = "";
            }

            Groups = NewGroups;
        }