Ejemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.NewsDetailsScreen);

            var id = Intent.GetIntExtra("NewsID", -1);

            if (id >= 0)
            {
                newsItem = BL.Managers.NewsManager.Get(id);
                if (newsItem != null)
                {
                    FindViewById <TextView>(Resource.Id.TitleTextView).Visibility = global::Android.Views.ViewStates.Gone;

                    FindViewById <WebView>(Resource.Id.ContentWebView).LoadDataWithBaseURL(null,
                                                                                           "<html><body>" + newsItem.Content + "</body></html>", @"text/html", "utf-8", null);
                    // ugh - LoadData() method has problems when html contains a % SO USE LoadDataWithBaseURL instead even though we don't have a BaseURL
                    // http://code.google.com/p/android/issues/detail?id=1733
                    // http://code.google.com/p/android/issues/detail?id=4401
                }
                else       // shouldn't happen...
                {
                    var text = FindViewById <TextView>(Resource.Id.TitleTextView);
                    text.Text       = "NewsItem not found: " + id;
                    text.Visibility = global::Android.Views.ViewStates.Visible;
                }
            }
        }
 public void Update(RSSEntry item)
 {
     ID        = item.ID;
     Url       = item.Url;
     Title     = item.Title;
     Published = item.Published;
     Content   = item.Content;
 }
            /// <summary>
            /// If there are subsections in the hierarchy, navigate to those
            /// ASSUMES there are _never_ Categories hanging off the root in the hierarchy
            /// </summary>
            public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
            {
                Console.WriteLine("Blog Entry selected");
                RSSEntry fi = rssvc.BlogFeed[indexPath.Row];
                RssSessionsEntryViewController revc = new RssSessionsEntryViewController(fi.Title, fi.Content.ToString());

                revc.Title = fi.Title;
                rssvc.NavigationController.PushViewController(revc, true);
            }
Ejemplo n.º 4
0
		public void GrabRSS()
		{
			try
			{
				XmlNode nodeRss = null;
				XmlNode nodeChannel = null;
				XmlNode nodeItem = null;
				var wb = new WebClient();

				// Read the RSS XML into an XmlReader, then proceed to f**k bitches
				var rssReader = new XmlTextReader(RSSFeed.OriginalString);
				var rssDoc = new XmlDocument();
				rssDoc.Load(rssReader);

				// Get the rss tag
				for (int i = 0; i < rssDoc.ChildNodes.Count; i++)
					if (rssDoc.ChildNodes[i].Name == "rss")
						nodeRss = rssDoc.ChildNodes[i];

				// Get the chanel tag
				for (int i = 0; i < nodeRss.ChildNodes.Count; i++)
					if (nodeRss.ChildNodes[i].Name == "channel")
						nodeChannel = nodeRss.ChildNodes[i];

				// Get all the items
				for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)
					if (nodeChannel.ChildNodes[i].Name == "item")
					{
						nodeItem = nodeChannel.ChildNodes[i];

						var rssEntry = new RSSEntry();
						rssEntry.Title = nodeItem["title"].InnerText;
						rssEntry.Link = nodeItem["link"].InnerText;
						rssEntry.Description = nodeItem["description"].InnerText;
						rssEntry.PubDate = DateTime.Parse(nodeItem["pubDate"].InnerText);
						rssEntry.FriendlyPubDate = rssEntry.PubDate.ToString("dddd, dd MMMM yyyy");
						rssEntry.GUID = nodeItem["guid"].InnerText;

						Dispatcher.Invoke(new Action(delegate { RssItems.Add(rssEntry); }));
					}
			}
			catch (TaskCanceledException)
			{
			}
			catch
			{
				Dispatcher.Invoke(new Action(delegate
				{
					// No internet connection :(, tell the user they are a jewish bastard.
					tutorialRSSList.Visibility = Visibility.Collapsed;
					gridNoConnection.Visibility = Visibility.Visible;
				}));
			}
		}
Ejemplo n.º 5
0
        /// <summary>
        ///		Interpreta los nodos de un elemento
        /// </summary>
        private RSSEntry ParseEntry(MLNode objMLEntry, RSSChannel channel)
        {
            RSSEntry entry = new RSSEntry();

            // Interpreta los nodos
            foreach (MLNode node in objMLEntry.Nodes)
            {
                switch (node.Name)
                {
                case RSSConstTags.cnstStrItemTitle:
                    entry.Title = node.Value;
                    break;

                case RSSConstTags.cnstStrItemLink:
                    entry.Link = node.Value;
                    break;

                case RSSConstTags.cnstStrItemDescription:
                    entry.Content = node.Value;
                    break;

                case RSSConstTags.cnstStrItemCategory:
                    entry.Categories.Add(ParseCategory(node));
                    break;

                case RSSConstTags.cnstStrItemPubDate:
                    entry.DateCreated = node.Value.GetDateTime(DateTime.Now);
                    break;

                case RSSConstTags.cnstStrItemGuid:
                    entry.GUID = ParseGuid(node);
                    break;

                case RSSConstTags.cnstStrItemEnclosure:
                    entry.Enclosures.Add(ParseEnclosure(node));
                    break;

                case RSSConstTags.cnstStrItemAuthor:
                    entry.Authors.Add(ParseAuthor(node));
                    break;

                default:
                    entry.Extensions.Parse(node, entry, channel.Dictionary);
                    break;
                }
            }
            // Devuelve la entrada
            return(entry);
        }
Ejemplo n.º 6
0
        /// <summary>
        ///		Obtiene los datos de un feed
        /// </summary>
        private RSSChannel GetFeedData()
        {
            RSSChannel channel    = new RSSChannel();
            int        itemsWrite = 0;

            // Ordena por fecha
            Data.Files.SortByDate(false);
            // Añade las propiedades del canal
            channel.Link          = CombineUrl(Processor.Project.URLBase, Processor.Project.PageMain);
            channel.Logo          = new RSSImage(Processor.Project.URLBase, "Imagen", channel.Link);
            channel.Author        = new RSSAuthor(Processor.Project.WebMaster);
            channel.Copyright     = Processor.Project.Copyright;
            channel.Title         = Processor.Project.Name;
            channel.Description   = Processor.Project.Description;
            channel.Editor        = Processor.Project.Editor;
            channel.LastBuildDate = DateTime.Now;
            // Añade las entradas del canal
            foreach (Pages.FileTargetModel file in Data.Files)
            {
                if (file.File.FileType == Model.Solutions.FileModel.DocumentType.Document &&
                    file.ShowAtRss && file.ShowMode == Model.Documents.DocumentModel.ShowChildsMode.None &&
                    itemsWrite < ItemsRSS)
                {
                    RSSEntry rssEntry = new RSSEntry();
                    Model.Documents.DocumentModel document;

                    // Carga el documento compilado en corto
                    document = new Application.Bussiness.Documents.DocumentBussiness().Load(Processor.Project,
                                                                                            file.GetFullFileNameCompiledShort(Processor));
                    // Asigna los valores a la entrada
                    rssEntry.Authors.Add(new RSSAuthor(Processor.Project.WebMaster));
                    // entry.Categories.Add();
                    rssEntry.Content     = document.Content;
                    rssEntry.Link        = CombineUrl(Processor.Project.URLBase, file.RelativeFullFileNameTarget);
                    rssEntry.Title       = file.Title;
                    rssEntry.DateCreated = file.DateUpdate;
                    // Añade la entrada al canal
                    channel.Entries.Add(rssEntry);
                    // Incrementa el número de entradas escritas
                    itemsWrite++;
                }
            }
            // Devuelve los datos del canal
            return(channel);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///		Convierte las entradas Atom en entradas RSS
        /// </summary>
        private void ConvertEntries(AtomChannel channel, RSSChannel rss)
        {
            foreach (AtomEntry channelEntry in channel.Entries)
            {
                RSSEntry rssEntry = new RSSEntry();

                // Convierte los datos de la entrada
                rssEntry.GUID.ID     = channelEntry.ID;
                rssEntry.Title       = channelEntry.Title.Content;
                rssEntry.Content     = channelEntry.Content.Content;
                rssEntry.DateCreated = channelEntry.DatePublished;
                // Vínculos
                if (channelEntry.Links.Count > 0)
                {
                    rssEntry.Link = channelEntry.Links[0].Href;
                }
                foreach (AtomLink channelLink in channelEntry.Links)
                {
                    if (channelLink.LinkType.Equals("enclosure"))
                    {
                        rssEntry.Enclosures.Add(ConvertLink(channelLink));
                    }
                }
                // Autores
                foreach (AtomPeople channelAuthor in channelEntry.Authors)
                {
                    rssEntry.Authors.Add(new RSSAuthor(channelAuthor.Name));
                }
                // Categorías
                foreach (AtomCategory channelCategory in channelEntry.Categories)
                {
                    rssEntry.Categories.Add(new RSSCategory(channelCategory.Name));
                }
                // Convierte las extensiones
                ConvertExtension(channelEntry.Extensions, rssEntry.Extensions);
                // Añade la entrada al objeto Atom
                rss.Entries.Add(rssEntry);
            }
        }
Ejemplo n.º 8
0
        public void GrabRSS()
        {
            try
            {
                XmlNode nodeRss     = null;
                XmlNode nodeChannel = null;
                XmlNode nodeItem    = null;
                var     wb          = new WebClient();

                // Read the RSS XML into an XmlReader, then proceed to f**k bitches
                var rssReader = new XmlTextReader(RSSFeed.OriginalString);
                var rssDoc    = new XmlDocument();
                rssDoc.Load(rssReader);

                // Get the rss tag
                for (int i = 0; i < rssDoc.ChildNodes.Count; i++)
                {
                    if (rssDoc.ChildNodes[i].Name == "rss")
                    {
                        nodeRss = rssDoc.ChildNodes[i];
                    }
                }

                // Get the chanel tag
                for (int i = 0; i < nodeRss.ChildNodes.Count; i++)
                {
                    if (nodeRss.ChildNodes[i].Name == "channel")
                    {
                        nodeChannel = nodeRss.ChildNodes[i];
                    }
                }

                // Get all the items
                for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)
                {
                    if (nodeChannel.ChildNodes[i].Name == "item")
                    {
                        nodeItem = nodeChannel.ChildNodes[i];

                        var rssEntry = new RSSEntry();
                        rssEntry.Title           = nodeItem["title"].InnerText;
                        rssEntry.Link            = nodeItem["link"].InnerText;
                        rssEntry.Description     = nodeItem["description"].InnerText;
                        rssEntry.PubDate         = DateTime.Parse(nodeItem["pubDate"].InnerText);
                        rssEntry.FriendlyPubDate = rssEntry.PubDate.ToString("dddd, dd MMMM yyyy");
                        rssEntry.GUID            = nodeItem["guid"].InnerText;

                        Dispatcher.Invoke(new Action(delegate { RssItems.Add(rssEntry); }));
                    }
                }
            }
            catch (TaskCanceledException)
            {
            }
            catch
            {
                Dispatcher.Invoke(new Action(delegate
                {
                    // No internet connection :(, tell the user they are a jewish bastard.
                    tutorialRSSList.Visibility  = Visibility.Collapsed;
                    gridNoConnection.Visibility = Visibility.Visible;
                }));
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// for iPad (SplitViewController)
 /// </summary>
 public NewsElement(RSSEntry showEntry, UIImage showImage, MWC.iOS.Screens.iPad.News.NewsSplitView newsSplitView) : base(showEntry.Title)
 {
     entry     = showEntry;
     image     = showImage;
     splitView = newsSplitView;                  // could be null, in current implementation
 }
Ejemplo n.º 10
0
 public NewsElement(RSSEntry showEntry, UIImage showImage) : base(showEntry.Title)
 {
     entry = showEntry;
     image = showImage;
 }
 public NewsItemViewModel(RSSEntry item)
     : this()
 {
     Update(item);
 }
Ejemplo n.º 12
0
 public void Update(RSSEntry entry)
 {
     this.LoadHtmlString(FormatText());
 }
Ejemplo n.º 13
0
 public NewsDetailsScreen(RSSEntry entry) : base()
 {
     newsEntry               = entry;
     View.BackgroundColor    = UIColor.White;
     webView.BackgroundColor = UIColor.White;
 }