Пример #1
0
        private async void ExecuteSearchForPodcastCommand()
        {
            m_View.BottomAppBar.IsOpen = false;
            // show input dialog
            InputMessageDialog dlg = new InputMessageDialog("Search term or RSS feed URL:");
            bool result            = await dlg.ShowAsync();

            // cancel pressed
            if (result == false)
            {
                return;
            }

            string searchTerm = dlg.TextBox.Text;
            IEnumerable <Podcast> searchResults;

            searchResults = await UIThread.RunInBackground <IEnumerable <Podcast> >(async() =>
            {
                return(await Data.Search(searchTerm));
            });

            await UIThread.Dispatch(async() =>
            {
                await Data.UpdateSearchResults(searchResults);
            });
        }
Пример #2
0
 protected void UpdateFields(NotifyCollectionChangedEventArgs e)
 {
     UIThread.Dispatch(() =>
     {
         if (e == null)
         {
             m_Groups.Clear();
             m_Groups.AddAll(Data.GetGroups().Select(PodcastGroupViewModelConstructor));
         }
         else if (e.Action == NotifyCollectionChangedAction.Add)
         {
             foreach (PodcastGroup group in e.NewItems)
             {
                 m_Groups.Add(new PodcastGroupViewModel(group, ServiceContext));
             }
         }
     });
 }
Пример #3
0
        private void UpdatePodcasts(NotifyCollectionChangedEventArgs e)
        {
            CoreDispatcher dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;

            UIThread.Dispatch(() =>
            {
                if (e == null)
                {
                    Podcasts.Clear();
                    Podcasts.AddAll(Data.Podcasts.Select((podcast) => new PodcastSummaryViewModel(podcast, ServiceContext)));
                    return;
                }

                if (e.Action == NotifyCollectionChangedAction.Add)
                {
                    foreach (var item in e.NewItems)
                    {
                        Podcast podcast = item as Podcast;
                        if (podcast != null)
                        {
                            Podcasts.Add(new PodcastSummaryViewModel(podcast, ServiceContext));
                        }
                        else
                        {
                            foreach (Podcast podcastItem in (IEnumerable <Podcast>)item)
                            {
                                Podcasts.Add(new PodcastSummaryViewModel(podcastItem, ServiceContext));
                            }
                        }
                    }
                    return;
                }
                if (e.Action == NotifyCollectionChangedAction.Remove)
                {
                    foreach (Podcast podcast in e.OldItems)
                    {
                        Podcasts.RemoveFirst((podcastViewModel) => podcastViewModel.Data.Id == podcast.Id);
                    }
                }
            });
        }
Пример #4
0
 private void UpdateVisibleEpisodes()
 {
     UIThread.Dispatch(() =>
     {
         m_Episodes.Clear();
         int i = 0;
         lock (m_AllEpisodes)
         {
             foreach (Episode episode in m_AllEpisodes)
             {
                 if (i >= m_NumEpisodesToShow)
                 {
                     break;
                 }
                 EpisodeViewModel viewModel = new EpisodeViewModel(episode, ServiceContext);
                 viewModel.Index            = i++;
                 viewModel.Data.UpdateDownloadStatus();
                 m_Episodes.Add(viewModel);
             }
         }
     });
 }