protected override void AddItemInternal <U>(U response)
        {
            RTMovies movies = response as RTMovies;

            if (movies != null)
            {
                try
                {
                    Items.Clear();

                    foreach (var mi in movies.Movies.Select(t => new RTUpcomingMovie(
                                                                t.Id,
                                                                t.Title,
                                                                t.MPAARating,
                                                                t.Ratings.AudienceScore,
                                                                t.Ratings.CriticsScore,
                                                                t.Links.Clips,
                                                                t.Links.Reviews,
                                                                t.Links.Cast,
                                                                t.Posters.Original,
                                                                t.Synopsis,
                                                                this)))
                    {
                        Items.Add(mi);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            base.AddItemInternal <U>(response);
        }
示例#2
0
        public override void OnActivityCreated(Bundle savedInstanceState)
        {
            base.OnActivityCreated(savedInstanceState);

            // Get the movies
            RTMovies movies = (new RotTom.Portable.RottenTomatoesAPIClient(GetString(Resource.String.rottentomatoes_api_key))).GetRTMovies(RotTom.Portable.RT_MOVIES_CATEGORIES.BOX_OFFICE);

            this.ListAdapter = new BoxOfficeListAdapter(this.Activity, movies.movies);
        }
        public RTMovies GetRTMovies(RT_MOVIES_CATEGORIES category)
        {
            // Set up the URI base
            string uri = "http://api.rottentomatoes.com/api/public/v1.0/lists/movies/";

            // Choose the node based on the category
            switch (category)
            {
            case RT_MOVIES_CATEGORIES.BOX_OFFICE:
                uri += "box_office.json";
                break;

            case RT_MOVIES_CATEGORIES.IN_THEATERS:
                uri += "in_theaters.json";
                break;

            case RT_MOVIES_CATEGORIES.OPENING:
                uri += "opening.json";
                break;

            case RT_MOVIES_CATEGORIES.UPCOMING:
                uri += "upcoming.json";
                break;
            }
            uri += "?";

            // Add the API Key
            uri += "apikey=" + APIKey;

            // Get the API response JSON
            string APIResponse = webClient.getUriAsync(new Uri(uri)).Result;

            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.NullValueHandling = NullValueHandling.Ignore;
            RTMovies movies = JsonConvert.DeserializeObject <RTMovies>(APIResponse, settings);

            return(movies);
        }