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; } }