protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.SimpleList); coursesViewModel = new CoursesViewModel(); FindViewById<TextView>(Resource.Id.screen_title).Text = "Cursos Disponíveis"; ListView list = FindViewById<ListView>(Resource.Id.list); adapter = new SimpleListAdapter<Course>(this, coursesViewModel.listContent); list.Adapter = adapter; list.ItemClick += new EventHandler<Android.Widget.AdapterView.ItemClickEventArgs>(list_ItemClick); actionBar = SupportActionBar; actionBar.SetHomeButtonEnabled(false); actionBar.SetDisplayHomeAsUpEnabled(false); actionBar.SetDisplayUseLogoEnabled(false); actionBar.SetDisplayShowHomeEnabled(false); actionBar.Title = "Cursos"; 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.CLASS_CONNECTION_OK: ServiceLocator.Dispatcher.invoke(() => { ServiceLocator.Dispatcher.invoke(() => { intent = new Intent(this, typeof(ClassActivity)); StartActivity(intent); }); }); break; case BaseViewMessage.MessageTypes.COURSE_CONNECTION_OK: ServiceLocator.Dispatcher.invoke(() => { //TODO refresh. }); break; default: break; } }); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.SimpleList); discussionViewModel = new DiscussionsViewModel(); FindViewById<TextView>(Resource.Id.screen_title).Text = "Fóruns Disponíveis"; ListView list = FindViewById<ListView>(Resource.Id.list); adapter = new SimpleListAdapter<Discussion>(this, discussionViewModel.discussions); 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 = "Fóruns"; 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.FUTURE_POSTS_LOADED: ServiceLocator.Dispatcher.invoke(() => { intent = new Intent(this, typeof(PostActivity)); StartActivity(intent); }); break; case BaseViewMessage.MessageTypes.NO_NEW_POSTS: ServiceLocator.Dispatcher.invoke(() => { Toast.MakeText(this, "Não há novos posts", ToastLength.Short).Show(); dialog.Dismiss(); }); break; default: break; } }); }