public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var service = new MovieBrowserService();

            //Load the movies if empty
            if (PopularMovies.Count == 0)
            {
                var popularMovies = await service.GetPopularMovies();

                for (int i = 0; i < 20; i++)
                {
                    PopularMovies.Add(popularMovies.results[i]);
                }
            }
            //Load the tv shows if empty
            if (PopularTvShows.Count == 0)
            {
                var popularTvShows = await service.GetPopularTvShows();

                for (int i = 0; i < 20; i++)
                {
                    PopularTvShows.Add(popularTvShows.results[i]);
                }
            }

            await base.OnNavigatedToAsync(parameter, mode, state);
        }
Пример #2
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var personId = (int)parameter;
            var service  = new MovieBrowserService();

            //Don't borther the server if we dont have to
            if (Person == null)
            {
                Person = await service.GetPerson(personId);
            }
            //Load the movies if empty and order by descending popularity
            if (Movies.Count == 0)
            {
                PersonMovieCredits movieCredits = await service.GetPersonMovieCredits(personId);

                var movies = new List <PersonMovieCreditsCast>(movieCredits.cast.OrderByDescending(x => x.popularity));
                foreach (var item in movies)
                {
                    Movies.Add(item);
                }
            }
            //Load the tv shows if empty and order by descending popularity
            if (TvShows.Count == 0)
            {
                PersonTvShowCredits tvShowCredits = await service.GetPersonTvShowCredits(personId);

                var tvShows = new List <PersonTvShowCreditsCast>(tvShowCredits.cast.OrderByDescending(x => x.popularity));
                foreach (var item in tvShows)
                {
                    TvShows.Add(item);
                }
            }
            await base.OnNavigatedToAsync(parameter, mode, state);
        }
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var tvShowId = (int)parameter;
            var service  = new MovieBrowserService();

            //Don't borther the server if we dont have to
            if (TvShow == null)
            {
                TvShow = await service.GetTvShow(tvShowId);
            }
            //Load cast if empty
            if (CastList.Count == 0)
            {
                Credits credits = await service.GetTvShowCredits(tvShowId);

                for (int i = 0; i < credits.cast.Length; i++)
                {
                    CastList.Add(credits.cast[i]);
                }
            }
            //Load seasons if empty
            if (Seasons.Count == 0)
            {
                for (int i = 1; i <= TvShow.number_of_seasons; i++)
                {
                    Season season = await service.GetSeason(TvShow.id, i);

                    Seasons.Add(season);
                }
            }
            await base.OnNavigatedToAsync(parameter, mode, state);
        }
Пример #4
0
        /// <summary>
        /// Sends and asynchronous request to search movies, tv shows or people.
        /// </summary>
        /// <param name="queryString">Search query text - can't be empty</param>
        public async void Search(string queryString)
        {
            //The querySting needs to be URL encoded
            string encodedQuery = Uri.EscapeDataString(queryString);

            //Query validation: do nothing if invalid
            if (encodedQuery.Length == 0)
            {
                return;
            }

            //It can be a problem if we navigate back, because it loads again, so we have to clear it
            if (SearchResults.Count != 0)
            {
                SearchResults.Clear();
            }

            var         service = new MovieBrowserService();
            SearchMulti result  = await service.SearchMulti(encodedQuery);

            foreach (var item in result.results)
            {
                SearchResults.Add(item);
            }
        }
Пример #5
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var movieId = (int)parameter;
            var service = new MovieBrowserService();

            //Don't borther the server if we dont have to
            if (Movie == null)
            {
                Movie = await service.GetMovie(movieId);
            }
            //Load the cast if empty
            if (CastList.Count == 0)
            {
                Credits credits = await service.GetMovieCredits(movieId);

                for (int i = 0; i < credits.cast.Length; i++)
                {
                    CastList.Add(credits.cast[i]);
                }
            }
            await base.OnNavigatedToAsync(parameter, mode, state);
        }