Esempio n. 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.Title = "Movie Search";

            this.View.BackgroundColor = UIColor.FromRGB(0.714f, 0.98f, 1);

            this._yCoord = StartY;

            var prompt = CreatePrompt();

            var nameField = CreateNameField();

            var greetingButton = CreateButton("Get movies");

            greetingButton.TouchUpInside += async(sender, args) =>
            {
                if (nameField.Text != "")
                {
                    this._movies.AllMovies.Clear();
                    nameField.ResignFirstResponder();
                    greetingButton.Enabled = false;

                    //create the spinner whilst finding movies
                    var spinner = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Gray);

                    spinner.Frame = new CGRect(HorizontalMargin, this._yCoord, this.View.Bounds.Width - 2 * HorizontalMargin, 50);
                    this.View.AddSubview(spinner);
                    spinner.StartAnimating();

                    var movieApi = MovieDbFactory.Create <DM.MovieApi.MovieDb.Movies.IApiMovieRequest>().Value;
                    DM.MovieApi.ApiResponse.ApiSearchResponse <DM.MovieApi.MovieDb.Movies.MovieInfo> response = await movieApi.SearchByTitleAsync(nameField.Text);

                    foreach (var i in response.Results)
                    {
                        var movie = new Movie();
                        await setMovieInfo.setInfo(i, movieApi, movie);

                        this._movies.AllMovies.Add(movie);
                    }

                    this.NavigationController.PushViewController(new MovieListController(this._movies.AllMovies), true);
                    spinner.StopAnimating();
                    greetingButton.Enabled = true;
                }
            };

            this.View.AddSubview(prompt);
            this.View.AddSubview(nameField);
            this.View.AddSubview(greetingButton);
        }
Esempio n. 2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Set our view from the "main" layout resource
            //SetContentView(Resource.Layout.Main);
            var rootView = inflater.Inflate(Resource.Layout.MovieInput, container, false);

            // Get our button from the layout resource,
            // and attach an event to it
            var button  = rootView.FindViewById <Button>(Resource.Id.searchButton);
            var search  = rootView.FindViewById <EditText>(Resource.Id.searchTextField);
            var spinner = rootView.FindViewById <ProgressBar>(Resource.Id.marker_progress);

            button.Click += async delegate {
                button.Enabled = false;
                search.Enabled = false;

                _movies.AllMovies.Clear();
                var manager = (InputMethodManager)Context.GetSystemService(Context.InputMethodService);
                manager.HideSoftInputFromWindow(search.WindowToken, 0);

                spinner.Visibility = ViewStates.Visible;

                //get movies corresponding to request
                var movieApi = MovieDbFactory.Create <DM.MovieApi.MovieDb.Movies.IApiMovieRequest>().Value;
                DM.MovieApi.ApiResponse.ApiSearchResponse <DM.MovieApi.MovieDb.Movies.MovieInfo> response = await movieApi.SearchByTitleAsync(search.Text);


                //insert results into arrays
                if (response != null)
                {
                    foreach (var i in response.Results)
                    {
                        var resp = await movieApi.GetCreditsAsync(i.Id);

                        var response2 = await movieApi.FindByIdAsync(i.Id);

                        var tmpmovie = new Movie();

                        _movies.AddMovie(i, resp, response2, tmpmovie);
                    }
                }

                var intent = new Intent(Context, typeof(MovieListActivity));
                intent.PutExtra("movieList", JsonConvert.SerializeObject(_movies.AllMovies));
                StartActivity(intent);

                spinner.Visibility = ViewStates.Gone;
                button.Enabled     = true;
                search.Enabled     = true;
                search.Text        = "";
            };
            return(rootView);
        }
Esempio n. 3
0
        public async Task FetchTopRatedMovies()
        {
            _movies.AllMovies.Clear();

            var movieApi = MovieDbFactory.Create <DM.MovieApi.MovieDb.Movies.IApiMovieRequest>().Value;

            DM.MovieApi.ApiResponse.ApiSearchResponse <DM.MovieApi.MovieDb.Movies.MovieInfo> response = await movieApi.GetTopRatedAsync();

            if (response != null)
            {
                foreach (var i in response.Results)
                {
                    var resp = await movieApi.GetCreditsAsync(i.Id);

                    var response2 = await movieApi.FindByIdAsync(i.Id);

                    var tmpmovie = new Movie();

                    _movies.AddMovie(i, resp, response2, tmpmovie);
                }
            }

            var listview = rootView.FindViewById <ListView>(Resource.Id.namelistview);

            listview.Adapter = new MovieListAdapter(this.Activity, _movies.AllMovies);

            listview.ItemClick += clickHandler;

            spinner.Visibility = ViewStates.Gone;
        }
Esempio n. 4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            MovieDbFactory.RegisterSettings(new ApiConnectionClass());

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            var button      = FindViewById <Button>(Resource.Id.searchButton);
            var search      = FindViewById <EditText>(Resource.Id.searchTextField);
            var movieResult = FindViewById <TextView>(Resource.Id.movieResult);

            //var movieResult = FindViewById<TextView>(2131099651);


            button.Click += async delegate
            {
                var manager = (InputMethodManager)this.GetSystemService(InputMethodService);
                manager.HideSoftInputFromWindow(search.WindowToken, 0);

                var movieApi = MovieDbFactory.Create <DM.MovieApi.MovieDb.Movies.IApiMovieRequest>().Value;

                DM.MovieApi.ApiResponse.ApiSearchResponse <DM.MovieApi.MovieDb.Movies.MovieInfo> response = await movieApi.SearchByTitleAsync(search.Text);

                var movie = response.Results[0].Title;

                movieResult.Text = movie;
            };
        }