protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); Xamarin.Insights.Initialize(Xamarin.Insights.DebugModeKey, this); if (!string.IsNullOrWhiteSpace(Settings.RegisteredEmail)) { Xamarin.Insights.Identify(Settings.RegisteredEmail, Xamarin.Insights.Traits.Email, Settings.RegisteredEmail); } Utils.Sharer = new Share(); Utils.Reminder = new ReminderService(); Utils.Message = new MessageDialog(); AndroidUtils.SnackbarView = FindViewById <LinearLayout>(Resource.Id.main); AndroidUtils.Context = this; var email = FindViewById <EditText>(Resource.Id.text_email); var notify = FindViewById <Button>(Resource.Id.button_notify); var share = FindViewById <Button>(Resource.Id.button_share); var calendar = FindViewById <Button>(Resource.Id.button_calendar); var progress = FindViewById <ProgressBar>(Resource.Id.progressBar); email.Text = Utils.Sharer.GetEmail(); email.TextChanged += (sender, e) => { notify.Enabled = SaveTheDateHelper.IsValidEmail(email.Text); }; notify.Enabled = SaveTheDateHelper.IsValidEmail(email.Text); share.Click += (sender, e) => SaveTheDateHelper.Share(); calendar.Click += (sender, e) => SaveTheDateHelper.AddToCalendar(); notify.Click += async(sender, e) => { if (Settings.IsRegistered) { Settings.IsRegistered = false; SetupUI(); return; } email.Enabled = notify.Enabled = calendar.Enabled = share.Enabled = false; progress.Visibility = ViewStates.Visible; await SaveTheDateHelper.RegisterForNotifications(email.Text); progress.Visibility = ViewStates.Invisible; email.Enabled = notify.Enabled = calendar.Enabled = share.Enabled = true; SetupUI(); }; SetupUI(); }
async partial void btnNotifyMe_TouchUpInside(NotifyButton sender) { ResignFirstResponder(); if (Settings.IsRegistered) { Settings.IsRegistered = false; SetupUI2(); return; } progressBar.StartAnimating(); btnShare.Enabled = false; btnNotifyMe.Enabled = false; btnAddToCalendar.Enabled = false; await SaveTheDateHelper.RegisterForNotifications(tbxEmailAddress.Text); btnShare.Enabled = true; btnNotifyMe.Enabled = true; btnAddToCalendar.Enabled = true; progressBar.StopAnimating(); SetupUI2(); }