/// <summary> /// Methods used to HideKeyboard /// </summary> //private void HideKeyboard(Android.Views.View v) //{ // if (_imm.IsActive) // { // _imm.HideSoftInputFromWindow(v.WindowToken, HideSoftInputFlags.None); // } //} #endregion #region ===== Events ====================================================================== /// <summary> /// Save the sos alert /// </summary> private async void SaveButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(AlertTitleEditText.Text)) { AlertTitleEditText.RequestFocus(); if (_imm == null) { _imm = (InputMethodManager)GetSystemService(InputMethodService); } _imm.ShowSoftInput(AlertTitleEditText, ShowFlags.Implicit); Toast.MakeText(this, Resource.String.alertSOS_cannotSaveTitle, ToastLength.Long).Show(); return; } else if (App.Locator.AlertSOS.LsRecipients.Count < 1) { Toast.MakeText(this, Resource.String.alertSOS_cannotSaveContact, ToastLength.Long).Show(); return; } else if (string.IsNullOrEmpty(AlertBodyEditText.Text)) { AlertBodyEditText.RequestFocus(); if (_imm == null) { _imm = (InputMethodManager)GetSystemService(InputMethodService); } _imm.ShowSoftInput(AlertBodyEditText, ShowFlags.Implicit); Toast.MakeText(this, Resource.String.alertSOS_cannotSaveContent, ToastLength.Long).Show(); return; } LoadingLayout.Visibility = ViewStates.Visible; if (await App.Locator.AlertSOS.InsertOrUpdateAlertSOS(AlertTitleEditText.Text, AlertBodyEditText.Text)) { LoadingLayout.Visibility = ViewStates.Gone; Finish(); } LoadingLayout.Visibility = ViewStates.Gone; }
/// <summary> /// Save the alert /// </summary> private async void SaveButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(AlertTitleEditText.Text)) { AlertTitleEditText.RequestFocus(); if (_imm == null) { _imm = (InputMethodManager)GetSystemService(InputMethodService); } _imm.ShowSoftInput(AlertTitleEditText, ShowFlags.Implicit); Toast.MakeText(this, Resource.String.alertSOS_cannotSaveTitle, ToastLength.Long).Show(); return; } else if (App.Locator.Alert.LsRecipients.Count < 1) { Toast.MakeText(this, Resource.String.alertSOS_cannotSaveContact, ToastLength.Long).Show(); return; } else if (string.IsNullOrEmpty(AlertBodyEditText.Text)) { AlertBodyEditText.RequestFocus(); if (_imm == null) { _imm = (InputMethodManager)GetSystemService(InputMethodService); } _imm.ShowSoftInput(AlertBodyEditText, ShowFlags.Implicit); Toast.MakeText(this, Resource.String.alertSOS_cannotSaveContent, ToastLength.Long).Show(); return; } var result = false; if (App.Locator.Alert.IdAlert == 0) { if (App.Locator.ModeZone.WaitingForAlerts) { if (!App.Locator.ModeZone.EditingAlerts) { result = await App.Locator.Alert.InsertAlert(AlertTitleEditText.Text, AlertBodyEditText.Text); } else { result = await App.Locator.Alert.UpdateAlert(AlertTitleEditText.Text, AlertBodyEditText.Text); } } else { result = await App.Locator.Alert.InsertAlert(AlertTitleEditText.Text, AlertBodyEditText.Text); } } else { if (App.Locator.ModeZone.WaitingForAlerts && App.Locator.ModeZone.EditingAlerts) { result = await App.Locator.Alert.UpdateAlert(AlertTitleEditText.Text, AlertBodyEditText.Text); } else { result = await App.Locator.Alert.UpdateAlert(AlertTitleEditText.Text, AlertBodyEditText.Text); } } if (result) { Finish(); } }