Exemplo n.º 1
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.CrueltySpot);        

            //_loadingDialog = LoadingDialogManager.ShowLoadingDialog(this);
            _loadingDialog = DialogManager.ShowLoadingDialog(this, "Retrieving Cruelty Spot Details");

            // Event Handlers
            IssueButton.Click += (sender, args) => SetViewState(CrueltySpotViewState.TheIssue);
            TakeActionButton.Click += (sender, args) => SetViewState(CrueltySpotViewState.TakeAction);

            var crueltySpotId = Intent.GetStringExtra(AppConstants.CrueltySpotIdKey);
            var crueltySpotsService = new CrueltySpotsService();
            _crueltySpot = await crueltySpotsService.GetByIdAsync(crueltySpotId, true);
            RunOnUiThread(() =>
                {
                    var formattedAddress = String.Format("{0}\n{1}", _crueltySpot.Address, _crueltySpot.CityStateAndZip);
                    FindViewById<TextView>(Resource.Id.Name).Text = _crueltySpot.Name;
                    FindViewById<TextView>(Resource.Id.Address).Text = formattedAddress;
                    var resourceId = ResourceHelper.GetDrawableResourceId(this, _crueltySpot.CrueltySpotCategory.IconName, ResourceSize.Medium);
                    FindViewById<ImageView>(Resource.Id.CrueltyTypeImage).SetImageResource(resourceId);
                    SetViewState(CrueltySpotViewState.TakeAction);
                    _loadingDialog.Hide();

                    var showSuccessAddedAlert = Intent.GetBooleanExtra(AppConstants.ShowCrueltySpotAddedSuccessfullyKey, false);
                    if (showSuccessAddedAlert)
                    {
                        DialogManager.ShowAlertDialog(this, "Thanks!", "...for reporting animal cruelty here. This location is now on the map so others can take action!", true);
                    }

                    FindViewById<TextView>(Resource.Id.issueName).Text = _crueltySpot.CrueltySpotCategory.Name;
                    FindViewById<TextView>(Resource.Id.issueDescription).Text = _crueltySpot.CrueltySpotCategory.Description;
                });
        }