Exemple #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.Title = "Search";

            this.View.BackgroundColor = UIColor.FromRGB(70, 0, 0);

            this._yCoord = StartY;

            var titleField = this.createTitleField();

            var searchButton = this.createButton("Search");

            activitySpinner = new Spinner(this.View.Frame).activitySpinner;

            searchButton.TouchUpInside += async(sender, args) =>
            {
                var apiService = new ApiService();

                searchButton.Enabled = false;
                activitySpinner.StartAnimating();

                MovieDbFactory.RegisterSettings(new MyDbSettings());

                titleField.ResignFirstResponder();

                List <FilmInfo> movies = await apiService.getMoviesByTitle(titleField.Text);

                movies = await _downloader.downloadPosters(movies);

                this.NavigationController.PushViewController(new MovieListController(movies), true);

                activitySpinner.StopAnimating();
                searchButton.Enabled = true;
            };

            this.View.AddSubview(activitySpinner);
            this.View.AddSubview(titleField);
            this.View.AddSubview(searchButton);
        }
        public override async void  ViewDidAppear(bool animated)
        {
            if (this._reload)
            {
                activitySpinner = new Spinner(this.View.Frame).activitySpinner;
                this.View.AddSubview(activitySpinner);
                activitySpinner.StartAnimating();

                var results = await _apiService.getTopRatedMovies();

                results = await _downloader.downloadPosters(results);

                _movieList.AddRange(results);

                this.TableView.ReloadData();
                activitySpinner.StopAnimating();

                this.TableView.Source = new MovieListSource(this._movieList, OnSelectedMovie);
            }

            this._reload = true;
        }