public void TestTraktPersonMovieCreditsDefaultConstructor()
        {
            var movieCredits = new TraktPersonMovieCredits();

            movieCredits.Cast.Should().BeNull();
            movieCredits.Crew.Should().BeNull();
        }
Esempio n. 2
0
        public override async Task <ITraktPersonMovieCredits> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktPersonMovieCredits)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var movieCreditsCastReader = new PersonMovieCreditsCastItemArrayJsonReader();
                var movieCreditsCrewReader = new PersonMovieCreditsCrewObjectJsonReader();

                ITraktPersonMovieCredits movieCredits = new TraktPersonMovieCredits();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PERSON_MOVIE_CREDITS_PROPERTY_NAME_CAST:
                        movieCredits.Cast = await movieCreditsCastReader.ReadArrayAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PERSON_MOVIE_CREDITS_PROPERTY_NAME_CREW:
                        movieCredits.Crew = await movieCreditsCrewReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(movieCredits);
            }

            return(await Task.FromResult(default(ITraktPersonMovieCredits)));
        }
        private void SendMovieCreditsToFacade(TraktPersonMovieCredits credits)
        {
            if (credits == null)
            {
                GUIUtils.ShowNotifyDialog(Translation.Error, Translation.ErrorGeneral);
                CurrentView = View.Summary;
                LoadPersonSummary();
                return;
            }

            // clear facade
            GUIControl.ClearControl(GetID, Facade.GetID);

            // set the current view
            CurrentView = View.MovieCredits;

            var personImages = new List <GUITmdbImage>();

            int itemId             = 0;
            GUIPersonListItem item = null;

            // Add all the Cast and Crew items
            if (credits.Cast != null && credits.Cast.Count > 0)
            {
                // add image for download
                var images = new GUITmdbImage {
                    PeopleImages = new TmdbPeopleImages {
                        Id = CurrentPerson.Ids.TmdbId
                    }
                };
                personImages.Add(images);

                item                 = new GUIPersonListItem(Translation.Actor, (int)TraktGUIWindows.PersonSummary);
                item.Label2          = string.Format(Translation.MovieCount, credits.Cast.Count);
                item.TVTag           = Credit.Cast;
                item.MusicTag        = credits;
                item.Images          = images;
                item.ItemId          = Int32.MaxValue - itemId;
                item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
                item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
                item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
                item.OnItemSelected += OnItemSelected;
                Utils.SetDefaultIcons(item);
                Facade.Add(item);
                itemId++;
            }

            if (credits.Crew != null)
            {
                if (credits.Crew.Production != null && credits.Crew.Production.Count > 0)
                {
                    // add image for download
                    var images = new GUITmdbImage {
                        PeopleImages = new TmdbPeopleImages {
                            Id = CurrentPerson.Ids.TmdbId
                        }
                    };
                    personImages.Add(images);

                    item                 = new GUIPersonListItem(Translation.Production, (int)TraktGUIWindows.PersonSummary);
                    item.Label2          = string.Format(Translation.MovieCount, credits.Crew.Production.Count);
                    item.TVTag           = Credit.Production;
                    item.MusicTag        = credits;
                    item.Images          = images;
                    item.ItemId          = Int32.MaxValue - itemId;
                    item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
                    item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
                    item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
                    item.OnItemSelected += OnItemSelected;
                    Utils.SetDefaultIcons(item);
                    Facade.Add(item);
                    itemId++;
                }

                if (credits.Crew.Directing != null && credits.Crew.Directing.Count > 0)
                {
                    // add image for download
                    var images = new GUITmdbImage {
                        PeopleImages = new TmdbPeopleImages {
                            Id = CurrentPerson.Ids.TmdbId
                        }
                    };
                    personImages.Add(images);

                    item                 = new GUIPersonListItem(Translation.Directing, (int)TraktGUIWindows.PersonSummary);
                    item.Label2          = string.Format(Translation.MovieCount, credits.Crew.Directing.Count);
                    item.TVTag           = Credit.Directing;
                    item.MusicTag        = credits;
                    item.Images          = images;
                    item.ItemId          = Int32.MaxValue - itemId;
                    item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
                    item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
                    item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
                    item.OnItemSelected += OnItemSelected;
                    Utils.SetDefaultIcons(item);
                    Facade.Add(item);
                    itemId++;
                }

                if (credits.Crew.Writing != null && credits.Crew.Writing.Count > 0)
                {
                    // add image for download
                    var images = new GUITmdbImage {
                        PeopleImages = new TmdbPeopleImages {
                            Id = CurrentPerson.Ids.TmdbId
                        }
                    };
                    personImages.Add(images);

                    item                 = new GUIPersonListItem(Translation.Writing, (int)TraktGUIWindows.PersonSummary);
                    item.Label2          = string.Format(Translation.MovieCount, credits.Crew.Writing.Count);
                    item.TVTag           = Credit.Writing;
                    item.MusicTag        = credits;
                    item.Images          = images;
                    item.ItemId          = Int32.MaxValue - itemId;
                    item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
                    item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
                    item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
                    item.OnItemSelected += OnItemSelected;
                    Utils.SetDefaultIcons(item);
                    Facade.Add(item);
                    itemId++;
                }

                if (credits.Crew.Art != null && credits.Crew.Art.Count > 0)
                {
                    // add image for download
                    var images = new GUITmdbImage {
                        PeopleImages = new TmdbPeopleImages {
                            Id = CurrentPerson.Ids.TmdbId
                        }
                    };
                    personImages.Add(images);

                    item                 = new GUIPersonListItem(Translation.Art, (int)TraktGUIWindows.PersonSummary);
                    item.Label2          = string.Format(Translation.MovieCount, credits.Crew.Art.Count);
                    item.TVTag           = Credit.Art;
                    item.MusicTag        = credits;
                    item.Images          = images;
                    item.ItemId          = Int32.MaxValue - itemId;
                    item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
                    item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
                    item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
                    item.OnItemSelected += OnItemSelected;
                    Utils.SetDefaultIcons(item);
                    Facade.Add(item);
                    itemId++;
                }

                if (credits.Crew.Camera != null && credits.Crew.Camera.Count > 0)
                {
                    // add image for download
                    var images = new GUITmdbImage {
                        PeopleImages = new TmdbPeopleImages {
                            Id = CurrentPerson.Ids.TmdbId
                        }
                    };
                    personImages.Add(images);

                    item                 = new GUIPersonListItem(Translation.Camera, (int)TraktGUIWindows.PersonSummary);
                    item.Label2          = string.Format(Translation.MovieCount, credits.Crew.Camera.Count);
                    item.TVTag           = Credit.Camera;
                    item.MusicTag        = credits;
                    item.Images          = images;
                    item.ItemId          = Int32.MaxValue - itemId;
                    item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
                    item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
                    item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
                    item.OnItemSelected += OnItemSelected;
                    Utils.SetDefaultIcons(item);
                    Facade.Add(item);
                    itemId++;
                }

                if (credits.Crew.CostumeAndMakeUp != null && credits.Crew.CostumeAndMakeUp.Count > 0)
                {
                    // add image for download
                    var images = new GUITmdbImage {
                        PeopleImages = new TmdbPeopleImages {
                            Id = CurrentPerson.Ids.TmdbId
                        }
                    };
                    personImages.Add(images);

                    item                 = new GUIPersonListItem(Translation.CostumeAndMakeUp, (int)TraktGUIWindows.PersonSummary);
                    item.Label2          = string.Format(Translation.MovieCount, credits.Crew.CostumeAndMakeUp.Count);
                    item.TVTag           = Credit.CostumeAndMakeUp;
                    item.MusicTag        = credits;
                    item.Images          = images;
                    item.ItemId          = Int32.MaxValue - itemId;
                    item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
                    item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
                    item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
                    item.OnItemSelected += OnItemSelected;
                    Utils.SetDefaultIcons(item);
                    Facade.Add(item);
                    itemId++;
                }

                if (credits.Crew.Sound != null && credits.Crew.Sound.Count > 0)
                {
                    // add image for download
                    var images = new GUITmdbImage {
                        PeopleImages = new TmdbPeopleImages {
                            Id = CurrentPerson.Ids.TmdbId
                        }
                    };
                    personImages.Add(images);

                    item                 = new GUIPersonListItem(Translation.Sound, (int)TraktGUIWindows.PersonSummary);
                    item.Label2          = string.Format(Translation.MovieCount, credits.Crew.Sound.Count);
                    item.TVTag           = Credit.Sound;
                    item.MusicTag        = credits;
                    item.Images          = images;
                    item.ItemId          = Int32.MaxValue - itemId;
                    item.IconImage       = GUIImageHandler.GetDefaultPoster(false);
                    item.IconImageBig    = GUIImageHandler.GetDefaultPoster();
                    item.ThumbnailImage  = GUIImageHandler.GetDefaultPoster();
                    item.OnItemSelected += OnItemSelected;
                    Utils.SetDefaultIcons(item);
                    Facade.Add(item);
                    itemId++;
                }
            }

            if (Facade.Count == 0)
            {
                GUIUtils.ShowNotifyDialog(Translation.MovieCredits, Translation.NoCreditsFound);
                CurrentView = View.Summary;
                LoadPersonSummary();
                return;
            }

            // Set Facade Layout
            Facade.CurrentLayout = GUIFacadeControl.Layout.List;
            GUIControl.FocusControl(GetID, Facade.GetID);

            // set facade properties
            GUIUtils.SetProperty("#itemcount", Facade.Count.ToString());

            GUIPersonListItem.GetImages(personImages, false);
        }