Beispiel #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            GPodderResultModel searchResultModel = this.DataContext as GPodderResultModel;
            String             podcastUri        = null;

            // Hack.
            if (searchResultModel != null)
            {
                podcastUri = searchResultModel.PodcastUrl;
            }
            else
            {
                BrowsePodcastItemModel browseModel = this.DataContext as BrowsePodcastItemModel;
                podcastUri = browseModel.url;
            }

            m_subscriptionManager.addSubscriptionFromURL(podcastUri);
        }
Beispiel #2
0
        private void ResultTapped(object sender, System.Windows.Input.GestureEventArgs e)
        {
            GPodderResultModel searchResultModel = this.DataContext as GPodderResultModel;
            String             podcastUri        = null;

            // Hack.
            if (searchResultModel != null)
            {
                podcastUri = searchResultModel.PodcastUrl;
            }
            else
            {
                BrowsePodcastItemModel browseModel = this.DataContext as BrowsePodcastItemModel;
                podcastUri = browseModel.url;
            }

            (Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri(string.Format("/Views/PodcastSubscriptionIntroduction.xaml?podcastUrl={0}", podcastUri), UriKind.Relative));
        }
Beispiel #3
0
        private void populatePopularUI()
        {
            var query = from podcast in m_popularPodcastsXML.Descendants("podcast")
                        select podcast;

            List <GPodderResultModel> results = new List <GPodderResultModel>();

            foreach (var result in query)
            {
                GPodderResultModel resultModel = new GPodderResultModel();

                XElement logoElement = result.Element("logo_url");

                if (logoElement == null ||
                    String.IsNullOrEmpty(logoElement.Value))
                {
                    logoElement = result.Element("scaled_logo_url");
                }

                if (logoElement != null &&
                    String.IsNullOrEmpty(logoElement.Value) == false)
                {
                    resultModel.PodcastLogoUrl = new Uri(logoElement.Value);
                }

                resultModel.PodcastName = result.Element("title").Value;
                resultModel.PodcastUrl  = result.Element("url").Value;

                results.Add(resultModel);
            }

            Debug.WriteLine("Found {0} popular results.", results.Count);
            this.PopularResultList.ItemsSource = results;

            this.LoadingText.Visibility = Visibility.Collapsed;
        }
Beispiel #4
0
        async private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(this.searchTerm.Text))
            {
                Debug.WriteLine("Empty search word. Do nothing.");
                return;
            }

            progressOverlay.Show();

            string searchQueryString = String.Format("https://gpodder.net/search.xml?q=\"{0}\"", this.searchTerm.Text);

            Debug.WriteLine("Search string: " + searchQueryString);

            try
            {
                String    searchResult = await new HttpClient().GetStringAsync(searchQueryString);
                XDocument searchXml    = XDocument.Parse(searchResult);

                var query = from podcast in searchXml.Descendants("podcast")
                            select podcast;

                List <GPodderResultModel> results = new List <GPodderResultModel>();
                foreach (var result in query)
                {
                    GPodderResultModel resultModel = new GPodderResultModel();
                    XElement           logoElement = result.Element("logo_url");

                    if (logoElement == null ||
                        String.IsNullOrEmpty(logoElement.Value))
                    {
                        logoElement = result.Element("scaled_logo_url");
                    }

                    if (logoElement != null &&
                        String.IsNullOrEmpty(logoElement.Value) == false)
                    {
                        resultModel.PodcastLogoUrl = new Uri(logoElement.Value);
                    }

                    resultModel.PodcastName = result.Element("title").Value;
                    resultModel.PodcastUrl  = result.Element("url").Value;

                    results.Add(resultModel);
                }

                Debug.WriteLine("Found {0} results.", results.Count);
                this.SearchResultList.ItemsSource = results;
            }
            catch (HttpRequestException ex)
            {
                Debug.WriteLine("ERROR: Web error happened. Error: " + ex.Message);
                ToastPrompt toast = new ToastPrompt();
                toast.Title   = "Error";
                toast.Message = "Could not get search results.";

                toast.Show();
            }
            catch (XmlException ex)
            {
                Debug.WriteLine("ERROR: Cannot parse gPodder.net search result XML. Error: " + ex.Message);
                ToastPrompt toast = new ToastPrompt();
                toast.Title   = "Error";
                toast.Message = "Could not get search results.";

                toast.Show();
            }

            progressOverlay.Hide();
        }
        void wc_DownloadSearchResultsCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                Debug.WriteLine("ERROR: Web error happened. Error: " + e.Error.ToString());
                ToastPrompt toast = new ToastPrompt();
                toast.Title   = "Error";
                toast.Message = "Could not get search results.";

                toast.Show();
                return;
            }

            XDocument searchXml;

            try
            {
                searchXml = XDocument.Parse(e.Result);
            }
            catch (System.Xml.XmlException ex)
            {
                Debug.WriteLine("ERROR: Cannot parse gPodder.net search result XML. Error: " + ex.Message);
                ToastPrompt toast = new ToastPrompt();
                toast.Title   = "Error";
                toast.Message = "Could not get search results.";

                toast.Show();
                return;
            }

            var query = from podcast in searchXml.Descendants("podcast")
                        select podcast;

            List <GPodderResultModel> results = new List <GPodderResultModel>();

            foreach (var result in query)
            {
                GPodderResultModel resultModel = new GPodderResultModel();
                try
                {
                    XElement logoElement = result.Element("logo_url");

                    if (logoElement == null ||
                        String.IsNullOrEmpty(logoElement.Value))
                    {
                        logoElement = result.Element("scaled_logo_url");
                    }

                    if (logoElement != null &&
                        String.IsNullOrEmpty(logoElement.Value) == false)
                    {
                        resultModel.PodcastLogoUrl = new Uri(logoElement.Value);
                    }

                    resultModel.PodcastName = result.Element("title").Value;
                    resultModel.PodcastUrl  = result.Element("url").Value;
                }
                catch (UriFormatException)
                {
                    Debug.WriteLine("Could not parse logo from the feed.");
                }

                results.Add(resultModel);
            }

            Debug.WriteLine("Found {0} results.", results.Count);
            this.SearchResultList.ItemsSource = results;
            this.progressOverlay.Hide();
        }