Ejemplo n.º 1
0
        public void loadRecent()
        {
            if (!Loading)
            {
                this.EmptyRecent.Visibility = System.Windows.Visibility.Collapsed;
                this.indicator = App.ShowLoading(this);
                this.Loading   = true;
                App.ViewModel.clearRecent();
                TraktShow[]  shows  = showController.getRecentShows();
                TraktMovie[] movies = movieController.getRecentMovies();

                List <Object> mergedList = new List <object>();
                mergedList.AddRange(shows);
                mergedList.AddRange(movies);

                mergedList.Sort((x, y) => DateTime.Compare(DateTime.Parse(y.ToString()), (DateTime.Parse(x.ToString()))));

                foreach (Object movieOrShow in mergedList)
                {
                    if (App.ViewModel.RecentItems.Count == 12)
                    {
                        break;
                    }

                    if (typeof(TraktShow) == movieOrShow.GetType())
                    {
                        TraktShow         show     = (TraktShow)movieOrShow;
                        ListItemViewModel newModel = new ListItemViewModel()
                        {
                            ImageSource = show.Images.Poster, Tvdb = show.tvdb_id, Type = "show"
                        };
                        App.ViewModel.RecentItems.Add(newModel);
                        newModel.LoadPosterImage();
                    }
                    else
                    {
                        TraktMovie        movie    = (TraktMovie)movieOrShow;
                        ListItemViewModel newModel = new ListItemViewModel()
                        {
                            ImageSource = movie.Images.Poster, Imdb = movie.imdb_id, Type = "movie"
                        };
                        App.ViewModel.RecentItems.Add(newModel);
                        newModel.LoadPosterImage();
                    }
                }

                if (App.ViewModel.RecentItems.Count == 0)
                {
                    this.EmptyRecent.Visibility = System.Windows.Visibility.Visible;
                }

                App.ViewModel.NotifyPropertyChanged("RecentItems");

                this.indicator.IsVisible = false;
                this.Loading             = false;
            }
        }
Ejemplo n.º 2
0
        private async void LoadRelatedShows()
        {
            this.progressBarLoading.Visibility = System.Windows.Visibility.Visible;

            TraktShow[] relatedShows = await showController.getRelatedShows(this.Show.tvdb_id);

            foreach (TraktShow relatedShow in relatedShows)
            {
                ListItemViewModel newModel = new ListItemViewModel()
                {
                    ImageSource = relatedShow.Images.Poster, Tvdb = relatedShow.tvdb_id, Type = "show"
                };
                App.ShowViewModel.RelatedShows.Add(newModel);
                newModel.LoadPosterImage();
            }

            App.ShowViewModel.RefreshRelatedShows();
            this.progressBarLoading.Visibility = System.Windows.Visibility.Collapsed;
        }
Ejemplo n.º 3
0
        private void LongListSelector_ItemRealized(object sender, ItemRealizationEventArgs e)
        {
            ListItemViewModel model = (ListItemViewModel)e.Container.DataContext;

            model.LoadPosterImage();
        }