Esempio n. 1
0
        private async void getPredictionsInfo()
        {
            string errorMessage = null;

            if (currentStopId < 0)
            {
                return;
            }

            PredictionProgressBar.Visibility = Visibility.Visible;
            try
            {
                string webresponse = await Network.PredictionsByStop(currentStopId);

                Prediction     predictions = JsonConvert.DeserializeObject <Prediction>(webresponse);
                List <Service> filtered    = new List <Service>();
                foreach (Service s in predictions.Services)
                {
                    if (s.Vehicles != null && s.Vehicles.Count > 0)
                    {
                        filtered.Add(s);
                    }
                }
                filtered.Sort();

                CurrentPredictionList.Clear();

                foreach (Service s in filtered)
                {
                    CurrentPredictionList.Add(s);
                }

                if (CurrentPredictionList.Count == 0)
                {
                    EmptyPredictionsList.Visibility = Visibility.Visible;
                }
                else
                {
                    EmptyPredictionsList.Visibility = Visibility.Collapsed;
                }

                LastUpdate.Text = "Ultima atualização: " + DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss");
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }

            if (errorMessage != null)
            {
                MessageDialog msg = new MessageDialog("Houve algum problema durante a requisição ao servidor. Por favor, verifique se o aparelho está conectado à internet e tente novamente.", "Você está conectado à internet?");
                await msg.ShowAsync();
            }

            PredictionProgressBar.Visibility = Visibility.Collapsed;
        }
Esempio n. 2
0
        private void favoriteStops_ItemClick(object sender, ItemClickEventArgs e)
        {
            int newStopId = (e.ClickedItem as FavoriteStop).Id;

            if (newStopId != currentStopId)
            {
                CurrentPredictionList.Clear();
                currentStopId = newStopId;
            }
            this.currentStopMnemonic = (e.ClickedItem as FavoriteStop).Mnemonic;
            SelectedStopName.Text    = currentStopMnemonic;
            getPredictionsInfo();
            MainPivot.SelectedItem = PredictionPivot;
        }
Esempio n. 3
0
        private void busIcon_Tapped(object sender, TappedRoutedEventArgs e)
        {
            int newStopId = int.Parse(((Image)sender).Tag.ToString());

            if (newStopId != currentStopId)
            {
                CurrentPredictionList.Clear();
                currentStopId = newStopId;
            }

            foreach (Stop s in CurrentStopList)
            {
                if (s.Id == currentStopId)
                {
                    SelectedStopName.Text    = s.Mnemonic;
                    this.currentStopMnemonic = s.Mnemonic;
                }
            }

            getPredictionsInfo();
            MainPivot.SelectedItem = PredictionPivot;
        }