コード例 #1
0
ファイル: TasksPage.xaml.cs プロジェクト: paparakri/Hirundo
        public TasksPage()
        {
            InitializeComponent();

            Debug.WriteLine("===== IN TASKS PAGE");
            database = SQLite_Android.GetConnection();

            GoToHabit = new Command(MoveToTask);

            render_tasks();

            var scrollView = new ScrollView {
                Content = grid
            };

            this.Content = scrollView;
        }
コード例 #2
0
ファイル: NewHabitVM.cs プロジェクト: paparakri/Hirundo
 public SQLiteController()
 {
     database = SQLite_Android.GetConnection();
 }
コード例 #3
0
        public override void OnReceive(Context context, Intent intent)
        {
            var message = intent.GetStringExtra("message");
            var title   = intent.GetStringExtra("title");
            var id      = intent.GetStringExtra("id");

            if (title == "Um Minuto de Presença")
            {
                id = id.Remove(id.Length - 1);

                var notIntent     = new Intent(context, typeof(MainActivity));
                var contentIntent = PendingIntent.GetActivity(context, 0, notIntent, PendingIntentFlags.CancelCurrent);
                var manager       = NotificationManagerCompat.From(context);

                SQLite_Android   sqlite = new SQLite_Android();
                PlatformNotifier pf     = new PlatformNotifier();
                NotificacaoDAO   dao    = new NotificacaoDAO(sqlite.GetConnection(), pf);
                ObservableCollection <Notificacao> notificacoes = dao.Notificacoes;
                var numero = Convert.ToInt32(id);

                var notificacao = (from not in notificacoes
                                   where not.ID == numero
                                   select not).FirstOrDefault <Notificacao>();

                if (!notificacao.Repetir)
                {
                    dao.DesativarNotificacao(notificacao);
                }

                //gerando notificacao para disparo

                var builder = new Notification.Builder(context)
                              .SetContentIntent(contentIntent)
                              .SetSmallIcon(Resource.Drawable.ic_notification)
                              .SetContentTitle(title)
                              .SetContentText(message)
                              .SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis())
                              .SetAutoCancel(true);

                if (notificacao.Vibrar)
                {
                    builder.SetDefaults(NotificationDefaults.Vibrate);
                }

                if (notificacao.Som)
                {
                    builder.SetSound(Android.Net.Uri.Parse("android.resource://" + context.ApplicationContext.PackageName + "/Raw/" + Resource.Raw.som_notificacao));
                }

                var notification = builder.Build();
                manager.Notify(0, notification);
            }
            else
            {
                SQLite_Android   sqlite = new SQLite_Android();
                PlatformNotifier pf     = new PlatformNotifier();
                NotificacaoDAO   dao    = new NotificacaoDAO(sqlite.GetConnection(), pf);
                ObservableCollection <Notificacao> notificacoes = dao.Notificacoes;

                for (int i = 0; i < notificacoes.Count; i++)
                {
                    if (notificacoes[i].Ativado)
                    {
                        dao.AtivarNotificacao(notificacoes[i]);
                    }
                }
            }
        }
コード例 #4
0
        public void callCustomDialog(bool hummingMaximo, bool umdpMaximo, MeditacaoUMDPViewModel umdpvm)
        {
            SQLite_Android sqlite = new SQLite_Android();
            MeditacaoDAO   dao    = new MeditacaoDAO(sqlite.GetConnection());
            Meditacao      tempos = dao.TemposMeditacao[0];

            umdp = umdpvm;

            hummingConcluido = !hummingMaximo;
            umdpConcluido    = !umdpMaximo;

            var context = Android.App.Application.Context;

            var inflater = context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater;

            var view = inflater.Inflate(Resource.Layout.layout1, null);

            var layoutHumming   = view.FindViewById <Android.Widget.LinearLayout>(Resource.Id.layoutHumming);
            var layoutUMDP      = view.FindViewById <Android.Widget.LinearLayout>(Resource.Id.layoutUMDP);
            var layoutPrincipal = view.FindViewById <Android.Widget.LinearLayout>(Resource.Id.layoutPrincipal);

            btHummingSim = view.FindViewById <Android.Widget.Button>(Resource.Id.btHummingSim);
            btHummingNao = view.FindViewById <Android.Widget.Button>(Resource.Id.btHummingNao);

            btUMDPSim = view.FindViewById <Android.Widget.Button>(Resource.Id.btUMDPSim);
            btUMDPNao = view.FindViewById <Android.Widget.Button>(Resource.Id.btUMDPNao);

            btHummingSim.Click += (sender, args) =>
            {
                tempos.TempoMaximoHumming += 5;
                dao.AtualizarMeditacao(tempos);
                acoesBotoesHumming();
            };

            btHummingNao.Click += (sender, args) =>
            {
                acoesBotoesHumming();
            };

            btUMDPSim.Click += (sender, args) =>
            {
                tempos.TempoMaximoUMDP += 5;
                dao.AtualizarMeditacao(tempos);
                acoesBotoesUMDP();
            };

            btUMDPNao.Click += (sender, args) =>
            {
                acoesBotoesUMDP();
            };

            if (!hummingMaximo)
            {
                layoutPrincipal.RemoveView(layoutHumming);
                //layoutHumming.Visibility = ViewStates.Invisible;
            }
            if (!umdpMaximo)
            {
                layoutPrincipal.RemoveView(layoutUMDP);
                //layoutUMDP.Visibility = ViewStates.Invisible;
            }

            AlertDialog.Builder builder = new AlertDialog.Builder(Forms.Context)
                                          .SetView(view);

            alert = builder.Create();

            alert.SetCanceledOnTouchOutside(false);

            alert.Show();
        }