public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			navController = this.NavigationController;
			classViewModel = new ClassViewModel();
			table = new UITableView(new RectangleF (
				0,50, this.View.Frame.Width,
				this.View.Frame.Height));
			table.AutoresizingMask = UIViewAutoresizing.All;
			table.Source = new TableViewSource2(classViewModel.classes);
			Add(table);

			ServiceLocator.Messenger.Subscribe<BaseViewMessage>(m =>
			{
				switch (m.Content.message)
				{
				case BaseViewMessage.MessageTypes.CONNECTION_ERROR:
					ServiceLocator.Dispatcher.invoke(() =>
					{
					});
					break;
					
				case BaseViewMessage.MessageTypes.DISCUSSION_CONNECTION_OK:
					ServiceLocator.Dispatcher.invoke(() =>
					{
						NavigationController.PushViewController(discussionViewController,true);
					});
					break;
				default:
					break;
				}
			});
		}
Пример #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.SimpleList);
            classViewModel = new ClassViewModel();
            FindViewById<TextView>(Resource.Id.screen_title).Text = "Turmas Disponíveis";
            ListView list = FindViewById<ListView>(Resource.Id.list);
            adapter = new SimpleListAdapter<Class>(this, classViewModel.classes);
            list.Adapter = adapter;
            list.ItemClick += new System.EventHandler<AdapterView.ItemClickEventArgs>(list_ItemClick);

            actionBar = SupportActionBar;
            actionBar.SetHomeButtonEnabled(false);
            actionBar.SetDisplayHomeAsUpEnabled(false);
            actionBar.SetDisplayUseLogoEnabled(false);
            actionBar.SetDisplayShowHomeEnabled(false);
            actionBar.Title = "Turmas";

            ServiceLocator.Messenger.Subscribe<BaseViewMessage>(m =>
            {
                switch (m.Content.message)
                {
                    case BaseViewMessage.MessageTypes.CONNECTION_ERROR:
                        ServiceLocator.Dispatcher.invoke(() =>
                        {
                            Toast.MakeText(this, "Erro de conexão", ToastLength.Short).Show();
                            dialog.Dismiss();
                        });
                        break;

                    case BaseViewMessage.MessageTypes.DISCUSSION_CONNECTION_OK:
                        ServiceLocator.Dispatcher.invoke(() =>
                        {
                            intent = new Intent(this, typeof(DiscussionActivity));
                            StartActivity(intent);
                        });
                        break;
                    default:
                        break;
                }
            });
        }
Пример #3
0
        void ClassPage_Loaded(object sender, RoutedEventArgs e)
        {
            progressBar = new PerformanceProgressBar();
            progressBar.IsIndeterminate = true;
            classViewModel = new ClassViewModel();
            ServiceLocator.Dispatcher = new DispatchAdapter();
            _classes.ItemsSource = classViewModel.classes;
            _classes.SelectionChanged -= _classes_SelectionChanged;
            _classes.SelectionChanged += new SelectionChangedEventHandler(_classes_SelectionChanged);

            ServiceLocator.Messenger.Subscribe<BaseViewMessage>(m =>
            {
                switch (m.Content.message)
                {
                    case BaseViewMessage.MessageTypes.CONNECTION_ERROR:
                        ServiceLocator.Dispatcher.invoke(() =>
                        {
                            ToastPrompt toast = new ToastPrompt();
                            toast.Message = "Erro de conexão";
                            toast.Show();
                            if (ContentPanel.Children.Contains(progressBar))
                                this.ContentPanel.Children.Remove(progressBar);
                            _classes.SelectedIndex = -1;
                        });
                        break;

                    case BaseViewMessage.MessageTypes.DISCUSSION_CONNECTION_OK:
                        ServiceLocator.Dispatcher.invoke(() =>
                        {
                            NavigationService.Navigate(new Uri("/Views/DiscussionPage.xaml", UriKind.Relative));
                        });
                        break;
                    default:
                        break;
                }
            });
        }