void PopUpAlmoco(string msg) { var hrsDeAlmoco = new List <DateTime>(); InvokeOnMainThread(() => hrsDeAlmoco = genController.GetAlmoco()); if (hrsDeAlmoco.Count == 1) { var timeAlmoco = hrsDeAlmoco[0].ToString("HH:mm"); msg = "Iniciado as: " + timeAlmoco + "\n\n" + msg; } var alert = UIAlertController.Create("Horario de Almoco", msg, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Nao", UIAlertActionStyle.Cancel, (actionCancel) => { MetricsManager.TrackEvent("CancelAlmoco"); if (msg.Contains("Gostaria de finalizar o horario de almoco em seu ponto eletronico ?")) { var app = new AppDelegate(); app.ExecAPIs(); Process.GetCurrentProcess().CloseMainWindow(); } })); alert.AddAction(UIAlertAction.Create("Sim", UIAlertActionStyle.Default, (actionOK) => { if (SetAlmoco()) { var app = new AppDelegate(); app.ExecAPIs(); var contentAlmoco = new UNMutableNotificationContent { Title = "Aviso", Subtitle = "Termino do horario de almoco", Body = "10 Minutos restantes para o fim do horario de almoco" }; var notificationTimerAlmoco = UNNotificationRequest.FromIdentifier(requestID, contentAlmoco, UNTimeIntervalNotificationTrigger.CreateTrigger(60 * 50, false)); var contentAlmocoInicio = new UNMutableNotificationContent { Title = "Aviso", Subtitle = "Inicio do horario de almoco", Body = "Iniciado as: " + DateTime.Now.ToString("HH:mm") }; var notificationInicioAlmoco = UNNotificationRequest.FromIdentifier(requestIDInicio, contentAlmocoInicio, UNTimeIntervalNotificationTrigger.CreateTrigger(60 * 50, false)); UNUserNotificationCenter.Current.AddNotificationRequest(notificationTimerAlmoco, (err) => { }); UNUserNotificationCenter.Current.AddNotificationRequest(notificationInicioAlmoco, (err) => { }); Process.GetCurrentProcess().CloseMainWindow(); } })); alert.View.TintColor = UIColor.FromRGB(10, 88, 90); PresentViewController(alert, true, null); }
protected void IniPopUpAlmoco(string msg) { var hrsDeAlmoco = controller.GetAlmoco(); if (hrsDeAlmoco.Count == 1) { var timeAlmoco = hrsDeAlmoco[0].ToString("HH:mm"); msg = "Iniciado as: " + timeAlmoco + "\n\n" + msg; } Android.App.AlertDialog.Builder dialogBuilder; dialogBuilder = new Android.App.AlertDialog.Builder(this, Resource.Style.DialogTheme); dialogBuilder.SetTitle(Resources.GetString(Resource.String.hr_almoco)); dialogBuilder.SetMessage(msg); dialogBuilder.SetNegativeButton(Resources.GetString(Resource.String.nao), delegate { if (controller.IsHrDeAlmoco()) { Toast.MakeText(this, Resources.GetString(Resource.String.dialog_ainda_no_almoco), ToastLength.Long).Show(); var intent = new Intent(Intent.ActionMain); intent.AddCategory(Intent.CategoryHome); intent.SetFlags(ActivityFlags.NewTask); StartActivity(intent); OverridePendingTransition(Resource.Animation.abc_slide_in_bottom, Resource.Animation.abc_slide_out_bottom); } }); dialogBuilder.SetPositiveButton(Resources.GetString(Resource.String.sim), delegate { MetricsManager.TrackEvent("CancelAlmoco"); if (SetAlmoco()) { var alarmIntent = new Intent(this, typeof(AlarmReceiverAlmoco)); alarmIntent.PutExtra("title", Resources.GetString(Resource.String.hr_almoco)); alarmIntent.PutExtra("message", Resources.GetString(Resource.String.min_horario_de_almoco)); var pending = PendingIntent.GetBroadcast(this, (int)TipoNotificacao.AlarmeAlmoco, alarmIntent, PendingIntentFlags.UpdateCurrent); var alarmManager = GetSystemService(AlarmService).JavaCast <AlarmManager>(); //50 minutos = 3000000 alarmManager.Set(AlarmType.ElapsedRealtime, SystemClock.ElapsedRealtime() + 3000000, pending); Toast.MakeText(this, Resources.GetString(Resource.String.almoco_ini), ToastLength.Long).Show(); FecharActivity(); } }); modelActivity.dialog = dialogBuilder.Create(); modelActivity.dialog.Show(); }