public void RegisterUser() { if (ValidateInput()) { DismissKeyboard(); AppController.Utility.ExecuteDelayedAction(300, default(System.Threading.CancellationToken), () => { if (_isRegisteringUser) { return; } _isRegisteringUser = true; _password = this.PasswordText.Text; // Prevent user form tapping views while logging ((MainActivity)this.Activity).BlockUI(); // Create a new cancellation token for this request _cts = new CancellationTokenSource(); AppController.RegisterUser(_cts, _email, _password, // Service call success (data) => { var f = new RegistrationDoneFragment(); this.FragmentManager.PopBackStack("BeforeRegistration0Fragment", (int)PopBackStackFlags.Inclusive); this.FragmentManager.BeginTransaction() .AddToBackStack("BeforeRegistrationDoneFragment") .Replace(Resource.Id.ContentLayout, f, "RegistrationDoneFragment") .Commit(); }, // Service call error (error) => { this.PasswordText.RequestFocus(); Toast.MakeText(this.Activity.Application, error, ToastLength.Long).Show(); }, // Service call finished () => { _isRegisteringUser = false; // Allow user to tap views ((MainActivity)this.Activity).UnblockUI(); }); }); } }
public void RegisterUser() { if (ValidateInput()) { DismissKeyboard(); AppController.Utility.ExecuteDelayedAction(300, default(System.Threading.CancellationToken), () => { if (_isRegisteringUser) { return; } _isRegisteringUser = true; _password = this.PasswordText.Text; // Prevent user form tapping views while logging ((MainViewController)this.MainViewController).BlockUI(); // Create a new cancellation token for this request _cts = new CancellationTokenSource(); AppController.RegisterUser(_cts, _email, _password, // Service call success (data) => { var c = new RegistrationDoneViewController(); this.NavigationController.PopToViewController(this.NavigationController.ViewControllers.Single(x => x is LoginViewController), false); this.NavigationController.PushViewController(c, true); }, // Service call error (error) => { this.PasswordText.RequestUserInput(); UIToast.MakeText(error, UIToastLength.Long).Show(); }, // Service call finished () => { _isRegisteringUser = false; // Allow user to tap views ((MainViewController)this.MainViewController).UnblockUI(); }); }); } }