Esempio n. 1
0
        private void CarregarItens(SwipeRefreshLayout refresher)
        {
            refresher.Refreshing = true;

            ThreadPool.QueueUserWorkItem(o =>
            {
                new ClasseRepositorio(App.Instancia.Token)
                .ObterClasses(App.Instancia.UsuarioId)
                .ContinueWith(task =>
                {
                    try
                    {
                        if (task.Exception != null)
                        {
                            Activity.RunOnUiThread(() => Snackbar.Make(ContentLayout, task.Exception.Message, Snackbar.LengthIndefinite)
                                                   .SetAction(Resource.String.ok, v => { })
                                                   .Show());
                            return;
                        }

                        if (task.Result != null && task.Result.Any())
                        {
                            Activity.RunOnUiThread(() => _adapter.LoadList(task.Result.ToList()));
                        }
                    }
                    finally
                    {
                        Activity.RunOnUiThread(() => refresher.Refreshing = false);
                    }
                });
            });
        }
Esempio n. 2
0
        private void AtualizarDados(DateTime data)
        {
            _textMes.Text = data.ToString("MM/yyyy");

            _dataAtual = new DateTime(data.Year, data.Month, 1);

            _adapter.Clear();

            var setor       = _adapterSetor.GetItem(_comboSetor.SelectedItemPosition).Numero;
            var congregacao = _adapterCongregacao.GetItem(_comboCongregacao.SelectedItemPosition).Id;

            var dialog = LoadingDialog();

            dialog.Show();

            ThreadPool.QueueUserWorkItem(o =>
            {
                new RelatorioRepositorio(App.Instancia.Token)
                .ObterRelatorio(setor, congregacao, _dataAtual.Year, _dataAtual.Month)
                .ContinueWith(task =>
                {
                    try
                    {
                        if (task.Exception != null)
                        {
                            Activity.RunOnUiThread(() =>
                            {
                                _textSetor.Text              = "-";
                                _textCongregacao.Text        = "-";
                                _textOfertaMes.Text          = "-";
                                _textOfertaDepartamento.Text = "-";

                                Snackbar.Make(ContentLayout, task.Exception.Message, Snackbar.LengthIndefinite)
                                .SetAction(Resource.String.ok, v => { })
                                .Show();
                            });

                            return;
                        }

                        if (task.Result != null)
                        {
                            Activity.RunOnUiThread(() =>
                            {
                                _textSetor.Text              = task.Result.Setor.ToString("00");
                                _textCongregacao.Text        = task.Result.NomeCongregacao;
                                _textOfertaMes.Text          = task.Result.OfertaMes.ToString("C2");
                                _textOfertaDepartamento.Text = task.Result.OfertaDepartamento.ToString("C2");

                                _adapter.LoadList(task.Result.Semanas.ToList());
                            });
                        }
                    }
                    finally
                    {
                        Activity.RunOnUiThread(dialog.Cancel);
                    }
                });
            });
        }
Esempio n. 3
0
        public override void OnStart()
        {
            ThreadPool.QueueUserWorkItem(async o =>
            {
                var aniversariantes = new List <AlunoDTO>();
                var itens           = await new AlunoRepositorio(App.Instancia.Token).ObterAniversariantes(App.Instancia.UsuarioId);
                if (itens.Any())
                {
                    aniversariantes.AddRange(itens);
                }

                if (aniversariantes.Any())
                {
                    Activity.RunOnUiThread(() =>
                    {
                        _adapterAniversariantes.LoadList(aniversariantes.OrderBy(x => x.DataNascimento).ThenBy(x => x.Nome).ToList());
                    });
                }
            });

            base.OnStart();
        }