From 7c776ddf092ea137095155f20de322d8f96e369d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Israel=20P=C3=A9rez=20Saucedo?= Date: Mon, 22 Apr 2019 21:00:32 -0500 Subject: [PATCH 1/5] Add files via upload --- CollectionViewChallenge/RssFeedItem.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 CollectionViewChallenge/RssFeedItem.cs diff --git a/CollectionViewChallenge/RssFeedItem.cs b/CollectionViewChallenge/RssFeedItem.cs new file mode 100644 index 0000000..7faa823 --- /dev/null +++ b/CollectionViewChallenge/RssFeedItem.cs @@ -0,0 +1,12 @@ +namespace CollectionViewChallenge +{ + public class RssFeedItem + { + public string Title { get; set; } + public string Description { get; set; } + public string Link { get; set; } + public string AuthorEmail { get; set; } + public int Id { get; set; } + public string PublishDate { get; set; } + } +} From 0d5163180bc653c0830333a34bcf1abe2f59767c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Israel=20P=C3=A9rez=20Saucedo?= Date: Mon, 22 Apr 2019 21:00:46 -0500 Subject: [PATCH 2/5] Delete RssFeedItem.cs --- CollectionViewChallenge/RssFeedItem.cs | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 CollectionViewChallenge/RssFeedItem.cs diff --git a/CollectionViewChallenge/RssFeedItem.cs b/CollectionViewChallenge/RssFeedItem.cs deleted file mode 100644 index 7faa823..0000000 --- a/CollectionViewChallenge/RssFeedItem.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CollectionViewChallenge -{ - public class RssFeedItem - { - public string Title { get; set; } - public string Description { get; set; } - public string Link { get; set; } - public string AuthorEmail { get; set; } - public int Id { get; set; } - public string PublishDate { get; set; } - } -} From ca79f1bebb38fe8fb1cf0ac6dae7732875cd46b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Israel=20P=C3=A9rez=20Saucedo?= Date: Mon, 22 Apr 2019 21:01:01 -0500 Subject: [PATCH 3/5] Add files via upload --- .../CollectionViewChallenge/RssFeedItem.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 CollectionViewChallenge/CollectionViewChallenge/RssFeedItem.cs diff --git a/CollectionViewChallenge/CollectionViewChallenge/RssFeedItem.cs b/CollectionViewChallenge/CollectionViewChallenge/RssFeedItem.cs new file mode 100644 index 0000000..7faa823 --- /dev/null +++ b/CollectionViewChallenge/CollectionViewChallenge/RssFeedItem.cs @@ -0,0 +1,12 @@ +namespace CollectionViewChallenge +{ + public class RssFeedItem + { + public string Title { get; set; } + public string Description { get; set; } + public string Link { get; set; } + public string AuthorEmail { get; set; } + public int Id { get; set; } + public string PublishDate { get; set; } + } +} From 1045bf011d4e0e6aece4cfda9162b213d40f46da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Israel=20P=C3=A9rez=20Saucedo?= Date: Mon, 22 Apr 2019 21:01:39 -0500 Subject: [PATCH 4/5] My own collection view --- .../Views/CollectionViewChallengePage.xaml | 55 +++++++++++-------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml b/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml index f2da7f7..370c6ad 100644 --- a/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml +++ b/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml @@ -1,32 +1,41 @@ - - + + - - - - - - This is a CollectionView! - Your feedback on the experience of converting a ListView to a CollectionView is incredibly appreciated. - Here are three general questions: - 1. How was the experience of converting your existing ListView to a CollectionView? - 2. How is the performance compared to the ListView? - 3. Is there a specific piece of functionality that you'd like to see? - - + + + - - + - \ No newline at end of file + From cc535d63f92fd4cde463222de978b7a6490c1354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Israel=20P=C3=A9rez=20Saucedo?= Date: Mon, 22 Apr 2019 21:02:16 -0500 Subject: [PATCH 5/5] My own file --- .../Views/CollectionViewChallengePage.xaml.cs | 53 +++++++++++++++++-- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml.cs b/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml.cs index 701124f..0f8c32c 100644 --- a/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml.cs +++ b/CollectionViewChallenge/CollectionViewChallenge/Views/CollectionViewChallengePage.xaml.cs @@ -1,9 +1,8 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using System.Text; +using System.Net.Http; using System.Threading.Tasks; - +using System.Xml.Linq; using Xamarin.Forms; using Xamarin.Forms.Xaml; @@ -16,5 +15,49 @@ public CollectionViewChallengePage() { InitializeComponent(); } + + protected override void OnAppearing() + { + base.OnAppearing(); + LoadItems(); + } + + private async void LoadItems() + { + // cargando la lista de elementos de rss + using (HttpClient client = new HttpClient()) + { + HttpResponseMessage response = await client.GetAsync("https://www.excelsior.com.mx/rss.xml"); + if (response.IsSuccessStatusCode) + { + string rssFeedList = await response.Content.ReadAsStringAsync(); + clvRssItems.ItemsSource = await ParseFeed(rssFeedList); + //lstRssItems.ItemsSource = await ParseFeed(rssFeedList); + } + else + { + await App.Current.MainPage.DisplayAlert("Rss Feed", "Algo falló", "Aceptar"); + } + } + } + + private async Task> ParseFeed(string rss) + { + return await Task.Run(() => + { + var xdoc = XDocument.Parse(rss); + var id = 0; + return (from item in xdoc.Descendants("item") + select new RssFeedItem + { + Title = (string)item.Element("title"), + Description = (string)item.Element("description"), + Link = (string)item.Element("link"), + PublishDate = (string)item.Element("pubDate"), + AuthorEmail = (string)item.Element("author"), + Id = id++ + }).ToList(); + }); + } } -} \ No newline at end of file +}