public async void finalizarMeditacao()
        {
            if (FinalizarMeditacao)
            {
                //acender tela
                DependencyService.Get <IWindowController>().acenderTela();

                var qualidadeDePresenca = await page.DisplayAlert("", "Houve Qualidade de Presença em sua prática?", "Sim", "Não");

                if (qualidadeDePresenca)
                {
                    Meditacao meditacao = dao.TemposMeditacao[0];
                    meditacao.TempoTotalMeditado += NumeroRepeticoes + numeroRepeticoesHumming;
                    dao.AtualizarMeditacao(meditacao);
                }

                bool aumentar_tempo_humming = NumeroRepeticoesHumming == tempoMaxHumming && NumeroRepeticoesHumming < 30;

                bool aumentar_tempo_ump = NumeroRepeticoes == tempoMaxUMDP;

                if (aumentar_tempo_humming || aumentar_tempo_ump)
                {
                    DependencyService.Get <ICustomDialog>().callCustomDialog(aumentar_tempo_humming, aumentar_tempo_ump, this);
                }
                else
                {
                    var resposta = await page.DisplayAlert("", "Deseja praticar novamente?", "Sim", "Não");

                    if (resposta)
                    {
                        FinalizarMeditacao = false;
                        comecarMeditacao();
                    }
                    else
                    {
                        await Navigation.PopAsync();
                    }
                    //apagar tela
                    DependencyService.Get <IWindowController>().apagarTela();
                }
            }
        }
        public AntesMeditacaoViewModel(MeditacaoDAO medDao)
        {
            Valor        = 1;
            ValorHumming = 0;
            flag         = true;

            dao = medDao;

            ajustaLimitesMaximosDeTempos();
            TempoMinimoUMDP = 1;

            //AudioHumming = dao.TemposMeditacao[0].AudioHumming;

            AudioHumming = verificarAudioExiste(dao.TemposMeditacao[0].AudioHumming, ListasDeSonsMeditacao.listaDeSonsHumming);

            //AudioUMP = dao.TemposMeditacao[0].AudioUMP;

            AudioUMP = verificarAudioExiste(dao.TemposMeditacao[0].AudioUMP, ListasDeSonsMeditacao.listaDeSonsUMP);

            ajustarTempoTotalMeditado();

            ComecaMeditacaoUMDP = new Command(async() =>
            {
                if (flag)
                {
                    flag                  = false;
                    var repeticoes        = (int)valor;
                    var repeticoesHumming = (int)valorHumming;
                    umdp                  = new MeditacaoUMDP(ListasDeSonsMeditacao.listaDeSonsHumming[AudioHumming], ListasDeSonsMeditacao.listaDeSonsUMP[AudioUMP], repeticoes, repeticoesHumming, dao);
                    await Navigation.PushAsync(umdp);
                    flag = true;
                }
            });

            AbrirListaDeSonsHumming = new Command(async() =>
            {
                var resposta           = await DependencyService.Get <ICustomListDialog>().showCustomListDialog(ListasDeSonsMeditacao.listaDeSonsHumming, AudioHumming);
                AudioHumming           = resposta;
                var meditacao          = dao.TemposMeditacao[0];
                meditacao.AudioHumming = AudioHumming;
                dao.AtualizarMeditacao(meditacao);
            });

            AbrirListaDeSonsUMP = new Command(async() =>
            {
                var resposta       = await DependencyService.Get <ICustomListDialog>().showCustomListDialog(ListasDeSonsMeditacao.listaDeSonsUMP, AudioUMP);
                AudioUMP           = resposta;
                var meditacao      = dao.TemposMeditacao[0];
                meditacao.AudioUMP = AudioUMP;
                dao.AtualizarMeditacao(meditacao);
            });

            DiminuirTempoDeHumming = new Command(() =>
            {
                if (ValorHumming > 0)
                {
                    ValorHumming--;
                }
            });

            AumentarTempoDeHumming = new Command(() =>
            {
                if (ValorHumming < TempoMaximoHumming)
                {
                    ValorHumming++;
                }
            });

            DiminuirTempoDeUMP = new Command(() =>
            {
                if (Valor > 1)
                {
                    Valor--;
                }
            });

            AumentarTempoDeUMP = new Command(() =>
            {
                if (Valor < TempoMaximoUMDP)
                {
                    Valor++;
                }
            });
        }
Exemple #3
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();
        }