diff -r 315255cd1aef -r 20be4dd42b12 mypackage_wrt/FeedPresentation.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mypackage_wrt/FeedPresentation.js Fri Apr 30 15:01:03 2010 +0100 @@ -0,0 +1,164 @@ +// //////////////////////////////////////////////////////////////////////////// +// Symbian Foundation Example Code +// +// This software is in the public domain. No copyright is claimed, and you +// may use it for any purpose without license from the Symbian Foundation. +// No warranty for any purpose is expressed or implied by the authors or +// the Symbian Foundation. +// //////////////////////////////////////////////////////////////////////////// + +// Feed presentation classes + +// Abstract class used to create controls to represent feed entries. +function FeedPresenter(rssreader){ + if (rssreader) { + this.init(rssreader); + } +} + +// FeedPresenter "Constructor" +FeedPresenter.prototype.init = function(rssreader){ + this.rssreader = rssreader; +} + +// Create a control that represents this item and add it to +// parent rss reader +FeedPresenter.prototype.show = function(item){ +} + +// Create and add controls to be shown before items list. +FeedPresenter.prototype.addPreambleItems = function(){ +} + +// Create and add controls to be shown before items list. +FeedPresenter.prototype.addFooterItems = function(){ +} + +// No items returned, show "No messages" +FeedPresenter.prototype.showNoItems = function(){ + var label = new Label(null, null, "No messages"); + this.rssreader.addControl(label); +} + +// Implementation of FeedPresenter that shows feed in a +// ContentPanel +function HtmlFeedPresenter(rssreader) { + if (rssreader) { + this.init(rssreader); + } + this.expanded = false; +} + +// HtmlFeedPresenter is a subclass of FeedPresenter +HtmlFeedPresenter.prototype = new FeedPresenter(null); + +// HtmlFeedPresenter "constructor" +HtmlFeedPresenter.prototype.init = function(rssreader) { + FeedPresenter.prototype.init.call(this, rssreader); +} + +// Create a control that represents this item and add it to +// parent rss reader +HtmlFeedPresenter.prototype.show = function(item) { + // get a feed item control from the pool or create one and + // place it in the pool if there aren't enough feed item controls + var feedItemControl = new ContentPanel(null, null, null, true); + + // initialize feed item control + feedItemControl.setCaption(item.title); + feedItemControl.setContent(this.getContentHTMLForFeedItem(item)); + feedItemControl.setExpanded(this.expanded); + + // add the feed item control to the main view + this.rssreader.feedItemControls.push(feedItemControl); + this.rssreader.addControl(feedItemControl); +} + +// Returns the content HTML for a feed item. +HtmlFeedPresenter.prototype.getContentHTMLForFeedItem = function (item){ + var buf = ""; + + // item date + if (item.date != null) { + buf += "