Ejemplo n.º 1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var rootView = inflater.Inflate(Resource.Layout.TitleInput, container, false);

            // Get our button from the layout resource,
            // and attach an event to it
            textField = rootView.FindViewById <EditText>(Resource.Id.titleInput);
            var listButton = rootView.FindViewById <Button>(Resource.Id.listButton);
            var spinner    = rootView.FindViewById <ProgressBar>(Resource.Id.progressBar1);

            spinner.Visibility = ViewStates.Invisible;


            listButton.Click += async(object sender, EventArgs e) =>
            {
                HideInput();
                listButton.Enabled = false;
                spinner.Visibility = ViewStates.Visible;
                List <Movie> movies = await _api.GetMoviesByTitle(textField.Text);

                spinner.Visibility = ViewStates.Invisible;
                listButton.Enabled = true;

                var intent = new Intent(this.Context, typeof(MovieListActivity));
                intent.PutExtra("movieList", JsonConvert.SerializeObject(movies));
                this.StartActivity(intent);
            };

            return(rootView);
        }
        private UIButton searchButton(UIActivityIndicatorView loading, UITextField name)
        {
            var sb = UIButton.FromType(UIButtonType.RoundedRect);

            sb.Frame = new CGRect(StartX, StartY + 2 * Height, this.View.Bounds.Width - 2 * StartX, Height);
            sb.SetTitle("Search", UIControlState.Normal);

            sb.TouchUpInside += async(sender, args) =>
            {
                loading.StartAnimating();
                loading.Hidden = false;
                name.ResignFirstResponder();
                _movies = await _api.GetMoviesByTitle(name.Text);

                await _imgDl.DownloadImages(_movies);

                await _imgDl.DownloadBackdrops(_movies);

                loading.StopAnimating();
                loading.Hidden = true;
                this.NavigationController.PushViewController(new MovieListController(this._movies), true);
            };

            return(sb);
        }