TraktPlugin.GUI.GUIRecentAddedMovies.SendRecentlyAddedToFacade C# (CSharp) Méthode

SendRecentlyAddedToFacade() private méthode

private SendRecentlyAddedToFacade ( IEnumerable activities ) : void
activities IEnumerable
Résultat void
        private void SendRecentlyAddedToFacade(IEnumerable<TraktActivity.Activity> activities)
        {
            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            // protected profiles might return null
            if (activities == null || activities.Count() == 0)
            {
                GUIUtils.ShowNotifyDialog(GUIUtils.PluginName(), Translation.UserHasNoRecentAddedMovies);
                PreviousUser = CurrentUser;
                CurrentUser = TraktSettings.Username;
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            int itemId = 0;
            var movieImages = new List<GUITmdbImage>();

            // Add each item added
            foreach (var activity in activities)
            {
                // bad data in API
                if (activity.Movie == null)
                    continue;

                // add image for download
                var images = new GUITmdbImage { MovieImages = new TmdbMovieImages { Id = activity.Movie.Ids.Tmdb } };
                movieImages.Add(images);

                var item = new GUIMovieListItem(activity.Movie.Title, (int)TraktGUIWindows.RecentAddedMovies);

                // add user added date as second label
                item.Label2 = activity.Timestamp.FromISO8601().ToShortDateString();
                item.TVTag = activity.Movie;
                item.Movie = activity.Movie;
                item.Images = images;
                item.Date = activity.Timestamp.FromISO8601().ToLongDateString();
                item.ItemId = Int32.MaxValue - itemId;
                item.IsPlayed = activity.Movie.IsWatched();
                item.IconImage = GUIImageHandler.GetDefaultPoster(false);
                item.IconImageBig = GUIImageHandler.GetDefaultPoster();
                item.ThumbnailImage = GUIImageHandler.GetDefaultPoster();
                item.OnItemSelected += OnMovieSelected;
                Utils.SetDefaultIcons(item);
                Facade.Add(item);
                itemId++;
            }

            // set Facade Layout
            Facade.SetCurrentLayout(Enum.GetName(typeof(Layout), CurrentLayout));
            GUIControl.FocusControl(GetID, Facade.GetID);

            if (PreviousSelectedIndex >= activities.Count())
                Facade.SelectIndex(PreviousSelectedIndex - 1);
            else
                Facade.SelectIndex(PreviousSelectedIndex);

            // set facade properties
            GUIUtils.SetProperty("#itemcount", activities.Count().ToString());
            GUIUtils.SetProperty("#Trakt.Items", string.Format("{0} {1}", activities.Count().ToString(), activities.Count() > 1 ? Translation.Movies : Translation.Movie));

            // Download movie images Async and set to facade
            GUIMovieListItem.GetImages(movieImages);
        }