protected override void OnCreate(Bundle savedInstanceState) { SpeakerResolver = new SpeakerResolver(ApplicationContext); Speakers = new List <ISpeaker>(); base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); FindViewById <Button>(Resource.Id.switchButton).Click += SwitchButtonOnClick; FindViewById <Button>(Resource.Id.loadButton).Click += LoadButtonOnClick; FindViewById <ListView>(Resource.Id.sourceListView).ItemClick += SourceListViewOnItemClick; FindViewById <ListView>(Resource.Id.destinationListView).ItemClick += DestinationListViewOnItemClick; FindViewById <ProgressBar>(Resource.Id.progressBar1).Indeterminate = true; MakeControlInvisible(Resource.Id.sourceTextView); MakeControlInvisible(Resource.Id.destinationTextView); MakeControlInvisible(Resource.Id.switchButton); MakeControlInvisible(Resource.Id.progressBar1); LoadAsync(); }
private async Task LoadAsync() { ShowProgressBar(); Speakers = (await SpeakerResolver.ResolveSpeakersAsync()).ToList(); if (!Speakers.Any()) { HideProgressBar(); Toast.MakeText(ApplicationContext, "No Speakers have been found.", ToastLength.Long).Show(); return; } PlayingSpeakers = new List <ISpeaker>(); foreach (var speaker in Speakers) { if (await speaker.IsPlayingAsync()) { PlayingSpeakers.Add(speaker); } } if (!PlayingSpeakers.Any()) { HideProgressBar(); Toast.MakeText(ApplicationContext, $"None of the {Speakers.Count} Speakers is playing any content.", ToastLength.Long) .Show(); return; } SetListViewContent(Resource.Id.sourceListView, PlayingSpeakers); UnselectListView(Resource.Id.sourceListView); MakeControlVisible(Resource.Id.sourceTextView); MakeControlInvisible(Resource.Id.destinationTextView); MakeControlInvisible(Resource.Id.switchButton); SetListViewContent(Resource.Id.destinationListView, new List <ISpeaker>()); HideProgressBar(); }