private void GetAttitudesData() { try { if (_attitudesID != -1) { Log.Info(TAG, "GetAttitudesData: Attempting to find Attitudes with ID - " + _attitudesID.ToString()); _attitudes = GlobalData.StructuredPlanAttitudes.Find(attitude => attitude.AttitudesID == _attitudesID); if (_attitudes == null) { Log.Error(TAG, "GetAttitudesData: _attitudes is NULL"); } } } catch (Exception e) { Log.Error(TAG, "GetAttitudesData: Exception - " + e.Message); if (GlobalData.ShowErrorDialog) { ErrorDisplay.ShowErrorAlert(this, e, GetString(Resource.String.ErrorStructuredPlanAttitudeDialogGetData), "StructuredPlanAttitudesDialogActivity.GetAttitudesData"); } } }
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); int attitudesID = -1; string toWhat = ""; ConstantsAndTypes.ATTITUDE_TYPES type = ConstantsAndTypes.ATTITUDE_TYPES.Cautious; int belief = 0; int feeling = -1; ConstantsAndTypes.ACTION_TYPE action = ConstantsAndTypes.ACTION_TYPE.Maintain; string actionOf = ""; if (resultCode == Result.Ok) { if (data != null) { if (data.HasExtra("attitudesID")) { attitudesID = data.GetIntExtra("attitudesID", -1); } if (data.HasExtra("toWhat")) { toWhat = data.GetStringExtra("toWhat"); } if (data.HasExtra("type")) { type = (ConstantsAndTypes.ATTITUDE_TYPES)data.GetIntExtra("type", 0); } if (data.HasExtra("belief")) { belief = data.GetIntExtra("belief", 0); } if (data.HasExtra("feeling")) { feeling = data.GetIntExtra("feeling", -1); } if (data.HasExtra("action")) { action = (ConstantsAndTypes.ACTION_TYPE)data.GetIntExtra("action", -1); } if (data.HasExtra("actionOf")) { actionOf = data.GetStringExtra("actionOf"); } try { Attitudes attitudesItem = null; if (attitudesID == -1) { //new item attitudesItem = new Attitudes(); attitudesItem.IsNew = true; attitudesItem.IsDirty = false; } else { attitudesItem = GlobalData.StructuredPlanAttitudes.Find(attitude => attitude.AttitudesID == attitudesID); attitudesItem.IsNew = false; attitudesItem.IsDirty = true; } attitudesItem.ToWhat = toWhat; attitudesItem.TypeOf = type; attitudesItem.Belief = belief; attitudesItem.Feeling = feeling; attitudesItem.Action = action; attitudesItem.ActionOf = actionOf; attitudesItem.Save(); if (attitudesID == -1) { GlobalData.StructuredPlanAttitudes.Add(attitudesItem); } UpdateAdapter(); } catch (Exception e) { Log.Error(TAG, "OnActivityResult: Exception - " + e.Message); if (GlobalData.ShowErrorDialog) { ErrorDisplay.ShowErrorAlert(this, e, GetString(Resource.String.ErrorStructuredPlanAttitudesConfirm), "StructuredPlanAttitudes.OnActivityResult"); } } } } if (resultCode == Result.Canceled) { Toast.MakeText(this, Resource.String.StructuredplanNoChangesToast, ToastLength.Short).Show(); } }