author | tasneems@symbian.org |
Thu, 04 Mar 2010 15:42:37 -0800 | |
changeset 220 | 41890dfa56f5 |
permissions | -rw-r--r-- |
220
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
1 |
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
2 |
<html lang="en" xml:lang="en"> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
3 |
<head> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
4 |
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
5 |
<meta name="copyright" content="(C) Copyright 2005" /> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
6 |
<meta name="DC.rights.owner" content="(C) Copyright 2005" /> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
7 |
<meta content="concept" name="DC.Type" /> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
8 |
<meta name="DC.Title" content="First steps" /> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
9 |
<meta scheme="URI" name="DC.Relation" content="WRTKit_RSS_Reader_Tutorial-GUID-678d197f-c7b0-4e5e-85e2-f8549c75bbe8.html" /> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
10 |
<meta content="XHTML" name="DC.Format" /> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
11 |
<meta content="GUID-DB42B227-1647-4020-BDB9-DACB26771779" name="DC.Identifier" /> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
12 |
<meta content="en" name="DC.Language" /> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
13 |
<link href="commonltr.css" type="text/css" rel="stylesheet" /> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
14 |
<title> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
15 |
First steps</title> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
16 |
</head> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
17 |
<body id="GUID-DB42B227-1647-4020-BDB9-DACB26771779"><a name="GUID-DB42B227-1647-4020-BDB9-DACB26771779"><!-- --></a> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
18 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
19 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
20 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
21 |
<h1 class="topictitle1"> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
22 |
First steps</h1> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
23 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
24 |
<div> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
25 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
26 |
<div class="section"><h2 class="sectiontitle"> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
27 |
Preparations</h2> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
28 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
29 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
30 |
<p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
31 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
32 |
You can find the ready made RSS Reader example in the Examples/RSSReader directory |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
33 |
in the WRTKit SDK. In there you can find the by-now familiar widget files: Info.plist |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
34 |
for the widget metadata, Icon.png for the S60 application grid icon, and the WRTKit |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
35 |
directory for the WRTKit user interface toolkit. You will also find the main HTML |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
36 |
file RSSReader.html, a CSS file called RSSReader.css and two JavaScript files |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
37 |
RSSReader.js and FeedUpdateBroker.js. As with all WRTKit -based widgets, we will |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
38 |
be focusing on the JavaScript files but before we get to those, let's see take a |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
39 |
look at the main HTML file: |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
40 |
</p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
41 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
42 |
<pre> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
43 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
44 |
<?xml version="1.0" encoding="UTF-8"?> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
45 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
46 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
47 |
<head> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
48 |
<title></title> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
49 |
<script type="text/javascript" src="WRTKit/WRTKit.js"></script> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
50 |
<script type="text/javascript" src="FeedUpdateBroker.js"></script> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
51 |
<script type="text/javascript" src="RSSReader.js"></script> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
52 |
<style type="text/css"> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
53 |
@import url("RSSReader.css"); |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
54 |
</style> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
55 |
</head> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
56 |
<body onload="init()"> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
57 |
</body> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
58 |
</html> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
59 |
</pre> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
60 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
61 |
<p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
62 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
63 |
You probably immediately noticed that the file is almost identical to the HTML file |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
64 |
for the Hello World widget. This is despite that the RSS Reader is much more complex. |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
65 |
In fact the only differences are that we are including the two JavaScript files |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
66 |
FeedUpdateBroker.js and RSSReader.js instead of HelloWorld.js as in the Hello World |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
67 |
widget. That, and the fact that we have a CSS stylesheet file that we also import here, |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
68 |
called RSSReader.css. Like for the Hello World widget we have an onload-event handler |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
69 |
that calls a function called init() in the JavaScript to allow us to initialize the |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
70 |
widget after everything is loaded. |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
71 |
</p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
72 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
73 |
<p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
74 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
75 |
You can either examine the ready made files or create your own files as you read the |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
76 |
tutorial. The tutorial assumes that you will create your own. If you're doing that then |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
77 |
now would be a good time to create a working directory for your own widget, call it |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
78 |
RSSReader and copy the WRTKit directory, Info.plist, Icon.png and the FeedUpdateBroker.js |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
79 |
file to the your own working directory. The FeedUpdateBroker.js is an AJAX-based RSS |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
80 |
fetcher and parser that we will be using in this example. It doesn't really have anything |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
81 |
to do with the WRTKit or the user interface for the RSS Reader but we need it in order |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
82 |
to be able to fetch and parse RSS feed news items. We will not create it in this tutorial |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
83 |
and thus you should just copy it to your own widget working directory. |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
84 |
</p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
85 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
86 |
<p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
87 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
88 |
At this point you can also create an empty placeholder for the CSS stylesheet file |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
89 |
(RSSReader.css) so that you have the file ready for when we'll create some CSS rules |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
90 |
for the widget. Also create an empty placeholder for the RSSReader.js file where the |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
91 |
majority of the widget's code will go. We'll return to this in a little bit! |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
92 |
</p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
93 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
94 |
</div> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
95 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
96 |
<div class="section"><h2 class="sectiontitle"> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
97 |
Architecture</h2> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
98 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
99 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
100 |
<p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
101 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
102 |
Before we write any code, let's talk about what the architecture of the RSS Reader |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
103 |
will be like. As we previously mentioned, the widget will have two views. A main |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
104 |
view for showing feed news items and a settings view to allow users to configure |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
105 |
what RSS feed to show and how often to update it. We also said that we'll have a |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
106 |
custom Options menu. |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
107 |
</p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
108 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
109 |
<p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
110 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
111 |
The entire code that implements fetching and parsing RSS feeds will be implemented |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
112 |
in the file FeedUpdateBroker.js. The widget code will use it through only one single |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
113 |
method: fetchFeed(). The way this works is that we will pass the URL of the RSS |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
114 |
feed to the method, as well as a function that will get called when the fetch has |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
115 |
been completed. Note that this call is asynchronous - it will immediately return |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
116 |
after it's called and the actual outcome of the fetch will not be known until the |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
117 |
callback method is called. As an argument to the callback we will receive an object |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
118 |
with three properties: status, lastModified and items. The status property will |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
119 |
contain a value of either "ok" or "error" depending on the outcome. The lastModified |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
120 |
will be present in case the fetch was successful and contains a timestamp that |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
121 |
indicates when the RSS feed was last updated. This will allow us to determine whether |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
122 |
there is any new news items or not so that we only update the user interface if there |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
123 |
really is something to update. Finally the third property "items" contains an array |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
124 |
of parsed RSS news items. Each of these is a JavaScript object that has four |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
125 |
properties: title for the news item headline, date to indicate when it was created, |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
126 |
description for the news item summary, and link with an URL to the full story. |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
127 |
</p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
128 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
129 |
<p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
130 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
131 |
We will setup a timer in the widget that will run a function once every second. In |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
132 |
this function we will compare the current time to a scheduled "next update" time. |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
133 |
If we have reached the next update time, we will use the feed update broker to fetch |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
134 |
the RSS news items of the feed that we're interested in. When the feed has been |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
135 |
fetched and parsed a callback method will be called and we will react to the callback |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
136 |
by either showing an error message (if the update failed), ignoring the callback (if |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
137 |
there was no new news items for us), or update the user interface (if there's new |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
138 |
news items to show). |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
139 |
</p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
140 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
141 |
<p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
142 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
143 |
We also want to be able to update the news items on request and for that we will |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
144 |
put an option in the Options menu that triggers a function that sets the next |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
145 |
scheduled update time to be immediately. That way the normal update timer will |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
146 |
immediately get triggered and cause an update. |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
147 |
</p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
148 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
149 |
<p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
150 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
151 |
We will also set the "next update" time whenever the feed update broker is used |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
152 |
to fetch new news items. That way we will get an automatic periodic update of the |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
153 |
news that will run in the background but can also be triggered to run immediately |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
154 |
if the user asks it to be. |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
155 |
</p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
156 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
157 |
<p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
158 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
159 |
In order to fetch and update news items with this mechanism we need two things: |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
160 |
the URL to the RSS feed and the interval between the automatic updates. These are |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
161 |
also the two properties that we will allow the user to configure in the settings |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
162 |
view. The properties will be stored in the widget preferences store and updated |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
163 |
there whenever the user saves the settings. The settings will be read when the |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
164 |
widget starts. |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
165 |
</p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
166 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
167 |
<p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
168 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
169 |
When the news items are fetched we will display a notification popup dialog to |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
170 |
indicate that the loading is in progress. The main reason why this is important |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
171 |
is because the loading takes some time and if we don't react immediately to the |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
172 |
user's action then the user will feel like the widget is not responsive. However |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
173 |
we don't want to popup a progress dialog every time the widget loads news in the |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
174 |
background. That would be really annoying when the user is reading news! This |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
175 |
means that we have to know whether the update was triggered manually or if it |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
176 |
was scheduled. We'll use a flag to track this and popup the dialog only if the |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
177 |
update was commanded by the user. |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
178 |
</p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
179 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
180 |
<p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
181 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
182 |
The settings view will contain four controls: a selection control to select the |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
183 |
feed URL, another selection control to select the feed update frequency, a save |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
184 |
button and a cancel button. |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
185 |
</p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
186 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
187 |
<p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
188 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
189 |
The main view in turn will contain a variable amount of controls: one for each |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
190 |
news item. The control that we will use is a ContentPanel control, which allows |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
191 |
us to collapse and expand the content so that we can display a compact list of |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
192 |
news headlines yet allow the user to open up a particular piece of news that |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
193 |
is interesting and read the summay or go to the website where the full news |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
194 |
story can be found. The news item controls will have the news headline as the |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
195 |
caption in the control. Unlike for other controls, ContentPanel captions are |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
196 |
interactive and can be clicked. When clicked they will toggle the content area |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
197 |
of the panel. We will put the actual news story summary in this content area. |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
198 |
The news story summary will be a fragment of HTML that we will construct from |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
199 |
each news story. The HTML will also include a link to the website where the |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
200 |
full story is located. The HTML will be styled by CSS rules that we will write |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
201 |
to the RSSReader.css file. |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
202 |
</p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
203 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
204 |
<p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
205 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
206 |
Because we don't know how many news stories we will have at any given time, we |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
207 |
will add and remove ContentPanel controls to the main view dynamically whenever |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
208 |
there's some update in the RSS feed. But we're environmentally conscious so |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
209 |
we'll recycle the ContentPanels. There's no need to throw them away even if they |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
210 |
are not needed. So once we have created them we will put them in a pool so that |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
211 |
we can recycle them. Later on if we need more ContentPanels will look for them |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
212 |
in the pool first and only if there are no ready ContentPanel controls for us |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
213 |
will we create more controls (and place them in the pool). Strictly speaking such |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
214 |
recycling is not necessary but it doesn't complicate the code much and it's a good |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
215 |
skill to know. |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
216 |
</p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
217 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
218 |
<p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
219 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
220 |
Finally, as we move between the main view and settings view we will need to |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
221 |
change the right softkey so that it's "Exit" in the main view and "Cancel" in |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
222 |
the settings view. |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
223 |
</p> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
224 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
225 |
</div> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
226 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
227 |
</div> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
228 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
229 |
<div> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
230 |
<div class="familylinks"> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
231 |
<div class="parentlink"><strong>Parent topic:</strong> <a href="WRTKit_RSS_Reader_Tutorial-GUID-678d197f-c7b0-4e5e-85e2-f8549c75bbe8.html">RSS Reader</a></div> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
232 |
</div> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
233 |
</div> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
234 |
|
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
235 |
</body> |
41890dfa56f5
Fixed 2046 - added support for WRTKit help
tasneems@symbian.org
parents:
diff
changeset
|
236 |
</html> |