Ejemplo n.º 1
0
        private async void InitView()
        {
            SetContentView(Resource.Layout.questionnaire_countries);

            _title        = FindViewById <TextView>(Resource.Id.countries_title);
            _subtitle     = FindViewById <TextView>(Resource.Id.countries_subtitle);
            _footer       = FindViewById <TextView>(Resource.Id.questionnaire_countries_footer);
            _nextButton   = FindViewById <Button>(Resource.Id.countries_button);
            _recyclerView = FindViewById <RecyclerView>(Resource.Id.countries_list);
            _progressBar  = FindViewById <ProgressBar>(Resource.Id.progress_bar);
            _closeButton  = FindViewById <Button>(Resource.Id.close_cross_btn);

            //Accessibility
            _closeButton.ContentDescription = InformationAndConsentViewModel.CLOSE_BUTTON_ACCESSIBILITY_LABEL;
            _title.SetAccessibilityDelegate(AccessibilityUtils.GetHeadingAccessibilityDelegate());

            _closeButton.Click += new StressUtils.SingleClick(OnExitClick).Run;
            _nextButton.Click  += new StressUtils.SingleClick(OnNextButtonClick).Run;

            _title.Text      = QuestionnaireCountriesViewModel.COUNTRY_QUESTIONAIRE_HEADER_TEXT;
            _subtitle.Text   = QuestionnaireCountriesViewModel.COUNTRY_QUESTIONAIRE_INFORMATION_TEXT;
            _footer.Text     = QuestionnaireCountriesViewModel.COUNTRY_QUESTIONAIRE_FOOTER;
            _nextButton.Text = QuestionnaireCountriesViewModel.COUNTRY_QUESTIONAIRE_BUTTON_TEXT;

            RunOnUiThread(() => ShowSpinner(true));

            _countries.AddRange(
                await _viewModel.GetListOfCountriesAsync() ??
                new List <CountryDetailsViewModel>());

            if (!_countries.Any())
            {
                RunOnUiThread(() => ShowSpinner(false));
                OnServerError();
                return;
            }
            RunOnUiThread(() => ShowSpinner(false));

            QuestionnaireCountriesSelectionAdapter adapter = new QuestionnaireCountriesSelectionAdapter(_countries);

            LinearLayoutManager layoutManager = new LinearLayoutManager(this);

            _recyclerView.SetLayoutManager(layoutManager);

            _recyclerView.SetAdapter(adapter);

            View rootView = Window.DecorView.RootView;

            rootView.LayoutDirection = LayoutUtils.GetLayoutDirection();
        }
Ejemplo n.º 2
0
        async void SetupTableView()
        {
            _spinner     = StyleUtil.ShowSpinner(View, UIActivityIndicatorViewStyle.WhiteLarge);
            _countryList = await _viewModel.GetListOfCountriesAsync();

            if (!_countryList.Any())
            {
                _spinner?.RemoveFromSuperview();
                OnServerError();
                return;
            }

            InvokeOnMainThread(() =>
            {
                TableViewHeightConstraint.Constant = _countryList.Count * CountryTableCell.ROW_HEIGHT;
                _spinner?.RemoveFromSuperview();
                CountryTableView.RegisterNibForCellReuse(CountryTableCell.Nib, CountryTableCell.Key);
                CountryTableView.Source = new CountryTableViewSource(_countryList);
                CountryTableView.ReloadData();
            });
        }