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

            var movieInputField = rootView.FindViewById <EditText>(Resource.Id.movieInputEditText);
            var searchBtn       = rootView.FindViewById <Button>(Resource.Id.getMovieButton);
            var progressBar     = rootView.FindViewById <ProgressBar>(Resource.Id.progressBar_cyclic);

            progressBar.Visibility = Android.Views.ViewStates.Invisible;

            // Get our button from the layout resource,
            // and attach an event to it
            searchBtn.Click += async(object sender, EventArgs e) =>
            {
                var manager = (InputMethodManager)this.Context.GetSystemService(Context.InputMethodService);
                manager.HideSoftInputFromWindow(movieInputField.WindowToken, 0);

                progressBar.Visibility = Android.Views.ViewStates.Visible;
                searchBtn.Enabled      = false;

                if (movieInputField.Text != "")
                {
                    this._movieCollection._movies = await FilmAPISearches.PopulateMovieListAsync(FilmAPISearches.movieApi, await FilmAPISearches.movieApi.SearchByTitleAsync(movieInputField.Text));
                }

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

                this.StartActivity(intent);
                progressBar.Visibility = Android.Views.ViewStates.Invisible;
                searchBtn.Enabled      = true;
            };

            return(rootView);
        }
Exemplo n.º 2
0
        public async System.Threading.Tasks.Task GetTopRatedAsync()
        {
            this._movieCollection._movies = await FilmAPISearches.PopulateMovieListAsync(FilmAPISearches.movieApi, await FilmAPISearches.movieApi.GetTopRatedAsync());

            _listView.Adapter       = new MovieListAdapter(this.Activity, this._movieCollection._movies);
            _progressBar.Visibility = Android.Views.ViewStates.Gone;
        }
        private async void SearchButton_Clicked(object sender, EventArgs e)
        {
            this.ActivityIndicator.IsRunning = true;
            this._filmCollection._movies     = FilmAPISearches.FindMovieTitles(await FilmAPISearches.movieApi.SearchByTitleAsync(this.SearchBar.Text));
            await this.Navigation.PushAsync(new MovieListPage(this._filmCollection));

            this.ActivityIndicator.IsRunning = false;
        }