/// <summary>
        /// Ons the create.
        /// </summary>
        /// <param name="savedInstanceState">Saved instance state.</param>
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            //Layout gets inflated here
            base.OnCreate(savedInstanceState);

            viewModel = new MovieExplorerViewModel();

            await viewModel.LoadModels(AppConfig.TopRated);

            await viewModel.LoadModels(AppConfig.Popular);

            await viewModel.LoadModels(AppConfig.NowPlaying);

            // Create a new fragment and a transaction.
            FragmentTransaction  fragmentTx = this.FragmentManager.BeginTransaction();
            MovieCategoryAdapter adapter    = new MovieCategoryAdapter(this, viewModel);

            MovieCategoryFragment <MovieExplorerViewModel> aCategoryFragment = new MovieCategoryFragment <MovieExplorerViewModel>(viewModel, adapter, async() =>
            {
                viewModel.Categories.Clear();
                await viewModel.LoadModels(AppConfig.TopRated);
                await viewModel.LoadModels(AppConfig.Popular);
                await viewModel.LoadModels(AppConfig.NowPlaying);
            });

            // The fragment will have the ID of Resource.Id.fragment_container.
            fragmentTx.Add(Resource.Id.movie_explorer_container, aCategoryFragment);

            // Commit the transaction.
            fragmentTx.Commit();

            //Turn off back arrows
            SupportActionBar.SetDisplayHomeAsUpEnabled(false);
            SupportActionBar.SetHomeButtonEnabled(false);
        }
示例#2
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var data = Intent.GetStringExtra("movie");

            var movie = Newtonsoft.Json.JsonConvert.DeserializeObject <MovieModel>(data);

            viewModel       = new MovieDetailViewModel();
            viewModel.Movie = movie;

            await viewModel.GetSimilarMovies(movie.Id);

            FindViewById <TextView>(Resource.Id.movie_overview).Text = movie.Overview;
            FindViewById <TextView>(Resource.Id.movie_title).Text    = movie.Title;
            FindViewById <TextView>(Resource.Id.release_date).Text   = "Release date: 01/05/2001";          //TODO: format this date!
            FindViewById <TextView>(Resource.Id.votes_amount).Text   = Convert.ToString(movie.VoteCount);


            ImageView coverImageView = FindViewById <ImageView>(Resource.Id.movie_cover);
            var       url            = await viewModel.GetMovieCover(movie.Id);

            try
            {
                Uri uri = Uri.Parse(url);
                Picasso.With(this).Load(uri).Fit().Into(coverImageView);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error getting the movie cover image: ", ex.Message);
            }

            //// Create a new fragment and a transaction.
            Android.App.FragmentTransaction fragmentTx = this.FragmentManager.BeginTransaction();
            MovieDetailAdapter adapter = new MovieDetailAdapter(this, viewModel);

            MovieCategoryFragment <MovieDetailViewModel> aCategoryFragment = new MovieCategoryFragment <MovieDetailViewModel>(viewModel, adapter);

            ////// The fragment will have the ID of Resource.Id.fragment_container.
            fragmentTx.Add(Resource.Id.similar_movies, aCategoryFragment);
            ////// Commit the transaction.
            fragmentTx.Commit();
        }