Example #1
0
 public override void OnReceive(Context context, Intent intent)
 {
     if (intent.Action == Intent.ActionBootCompleted)
     {
         Intent pushIntent = new Intent(context, typeof(GPSAndroid));
         context.StartService(pushIntent);
         InvokeAbortBroadcast();
     }
     else if (intent.Action == PercursoBLL.ACAO_PARAR_SIMULACAO)
     {
         GPSUtils.pararSimulacao();
         MensagemUtils.pararNotificaoPermanente(PercursoBLL.NOTIFICACAO_SIMULACAO_PERCURSO_ID);
         InvokeAbortBroadcast();
     }
     else if (intent.Action == PercursoBLL.ACAO_PARAR_GRAVACAO)
     {
         PercursoBLL regraPercurso = PercursoFactory.create();
         regraPercurso.pararGravacao();
         //MensagemUtils.pararNotificaoPermanente(PercursoBLL.NOTIFICACAO_GRAVAR_PERCURSO_ID);
         InvokeAbortBroadcast();
     }
     else if (intent.Action == "Fechar")
     {
         NotificationManager notificationManager = (NotificationManager)context.GetSystemService(Context.NotificationService);
         notificationManager.Cancel(1);
         System.Environment.Exit(0);
         Process.KillProcess(Process.MyPid());
     }
 }
Example #2
0
        private async void pararPercurso()
        {
            var retorno = await DisplayActionSheet("Tem certeza que deseja parar a gravação?", null, null, "Parar", "Continuar gravando");

            if (retorno == "Parar")
            {
                PercursoBLL regraPercurso = PercursoFactory.create();
                if (regraPercurso.pararGravacao())
                {
                    _RootLayout.Children.Remove(_PararButton);
                    _RootLayout.Children.Add(_GravarButton);

                    var percursos = regraPercurso.listar();
                    _PercursoListView.BindingContext = percursos;
                }
                else
                {
                    MensagemUtils.avisar("Não foi possível parar a gravação!");
                }
            }
        }
        void gravarPercurso(object sender, EventArgs e)
        {
            //Label gravarButton = (Label)sender;
            PercursoBLL regraPercurso = PercursoFactory.create();

            if (PercursoBLL.Gravando)
            {
                if (regraPercurso.pararGravacao())
                {
                    gravarLabel.Text = "Gravar Percurso!";
                    infoLabel.Text   = "Toque aqui para iniciar a gravação";
                    stackDescricaoGravando.Children.Add(gravarLabel);
                    stackDescricaoGravando.Children.Add(infoLabel);
                    stackDescricaoGravando.Children.Remove(desc);

                    icoPlay.Source = ImageSource.FromFile("Play.png");
                    Emagine.Utils.MensagemUtils.avisar("Gravação finalizada!");
                    Emagine.Utils.MensagemUtils.pararNotificaoPermanente(PercursoBLL.NOTIFICACAO_GRAVAR_PERCURSO_ID);

                    var percursos = regraPercurso.listar();
                    percursoListView.BindingContext = percursos;
                    percursoListView.ItemTemplate   = new DataTemplate(typeof(PercursoPageCell));
                    percursoListView.SetBinding(ListView.ItemsSourceProperty, new Binding("."));
                }
                else
                {
                    Emagine.Utils.MensagemUtils.avisar("Não foi possível parar a gravação!");
                }
            }
            else
            {
                if (regraPercurso.iniciarGravacao((s2, e2) =>
                {
                    tempoCorrendo.Text = e2.Ponto.TempoGravacao.ToString();
                    tempoParado.Text = e2.Ponto.TempoParadoStr;

                    paradas.Text = e2.Ponto.QuantidadeParadaStr;

                    velocidadeMedia.Text = e2.Ponto.VelocidadeMediaStr;

                    velocidadeMaxima.Text = e2.Ponto.VelocidadeMaximaStr;

                    radares.Text = e2.Ponto.QuantidadeRadarStr;
                }))
                {
                    stackDescricaoGravando.Children.Remove(gravarLabel);
                    stackDescricaoGravando.Children.Remove(infoLabel);
                    stackDescricaoGravando.Children.Add(desc);

                    /*
                     * //PercursoInfo percursoInfo = new PercursoInfo();
                     *
                     * tempoCorrendo.Text = percursoInfo.TempoGravacaoStr ;
                     *
                     * tempoParado.Text = percursoInfo.TempoParadoStr;
                     *
                     * paradas.Text = percursoInfo.QuantidadeParadaStr;
                     *
                     * velocidadeMedia.Text = percursoInfo.VelocidadeMediaStr;
                     *
                     * velocidadeMaxima.Text = percursoInfo.VelocidadeMaximaStr;
                     *
                     * radares.Text = percursoInfo.QuantidadeRadarStr;
                     */

                    icoPlay.Source = ImageSource.FromFile("Stop.png");
                    Emagine.Utils.MensagemUtils.avisar("Iniciando gravação do percurso!");
                    Emagine.Utils.MensagemUtils.notificarPermanente(
                        PercursoBLL.NOTIFICACAO_GRAVAR_PERCURSO_ID,
                        "Gravando Percurso...", "",
                        PercursoBLL.NOTIFICACAO_PARAR_PERCURSO_ID,
                        "Parar", PercursoBLL.ACAO_PARAR_GRAVACAO
                        );
                }
                else
                {
                    Emagine.Utils.MensagemUtils.avisar("Não foi possível iniciar a gravação!");
                }
            }
        }