async partial void NextButtonClicked(Foundation.NSObject sender) { View.EndEditing(true); string code = StringUtils.RemoveNonIntegers(VerificationCodeTextField.Text.Trim()); bool allFieldsValid = ValidateAllFields(); if (!allFieldsValid) { return; } ShowHud(Strings.Hud.please_wait); try { var result = await TwilioServices.VerifyPhoneAsync(PhoneNumber, code); if (result != null && result.success) { var outlet = new Outlet(); outlet.Handle = PhoneNumber; outlet.Type = Outlet.outlet_type_phone; outlet.Name = PhoneNumber; var outletSaved = RealmServices.SaveOutlet(outlet); if (outletSaved) { var popToViewController = NavigationController.ViewControllers.Where(c => c.GetType() == typeof(MyOutletsViewController)).First(); NavigationController.PopToViewController(popToViewController, true); } else { ShowDuplicateEntryAlert(); } } else { VerificationCodeTextField.SetInvalid(); } } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } HideHud(); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.EnterPhoneNumberVerificationCode, container, false); PhoneNumberTextField = view.FindViewById <EditText>(Resource.Id.PhoneNumberTextField); PhoneNumberTextField.InputType = Android.Text.InputTypes.ClassNumber; var titleTextView = view.FindViewById <TextView>(Resource.Id.TitleTextView); titleTextView.Text = "Verify Phone Number"; var messageTextView = view.FindViewById <TextView>(Resource.Id.MessageTextView); messageTextView.Text = "We've sent you an text!"; var progressButton = view.FindViewById <Button>(Resource.Id.ProgressButton); progressButton.Click += async(sender, e) => { string code = StringUtils.RemoveNonIntegers(PhoneNumberTextField.Text.Trim()); bool allFieldsValid = ValidateAllFields(); if (!allFieldsValid) { return; } ShowHud(Strings.Hud.please_wait); try { var result = await TwilioServices.VerifyPhoneAsync(PhoneNumber, code); if (result != null && result.success) { var outlet = new Outlet(); outlet.Handle = PhoneNumber; outlet.Type = Outlet.outlet_type_phone; outlet.Name = PhoneNumber; var outletSaved = RealmServices.SaveOutlet(outlet); if (outletSaved) { var activity = Activity as BaseActivity; activity?.PopFragmentOverUntil(typeof(MyOutletsRecyclerViewFragment)); } else { ShowDuplicateEntryAlert(); } } else { PhoneNumberTextField.SetInvalid(Resources); } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } HideHud(); }; return(view); }