author | Eugene Ostroukhov <eugeneo@symbian.org> |
Tue, 30 Mar 2010 15:20:42 -0700 | |
changeset 292 | d1d1c556b0d1 |
parent 230 | 7848c135d915 |
permissions | -rw-r--r-- |
230
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
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"> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
2 |
<html lang="en" xml:lang="en"> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
3 |
<head> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
4 |
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
5 |
<meta name="copyright" content="(C) Copyright 2005" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
6 |
<meta name="DC.rights.owner" content="(C) Copyright 2005" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
7 |
<meta content="concept" name="DC.Type" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
8 |
<meta name="DC.Title" content="Feed updates" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
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" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
10 |
<meta content="XHTML" name="DC.Format" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
11 |
<meta content="GUID-25CD0E54-0516-4469-965E-C5781CF44DC9" name="DC.Identifier" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
12 |
<meta content="en" name="DC.Language" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
13 |
<link href="commonltr.css" type="text/css" rel="stylesheet" /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
14 |
<title> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
15 |
Feed updates</title> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
16 |
</head> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
17 |
<body id="GUID-25CD0E54-0516-4469-965E-C5781CF44DC9"><a name="GUID-25CD0E54-0516-4469-965E-C5781CF44DC9"><!-- --></a> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
18 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
19 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
20 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
21 |
<h1 class="topictitle1"> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
22 |
Feed updates</h1> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
23 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
24 |
<div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
25 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
26 |
<div class="section"><h2 class="sectiontitle"> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
27 |
Fetching news items</h2> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
28 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
29 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
30 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
31 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
32 |
Before we can show any news items we have to fetch them. So let's take |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
33 |
a break in implementing the user interface and write the code that fetches |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
34 |
the news items. The majority of that code is in the FeedUpdateBroker.js file |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
35 |
in a JavaScript class called FeedUpdateBroker. We'll only be using one single |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
36 |
method from that class: fetchFeed(). But how do we hook that up to our widget? |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
37 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
38 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
39 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
40 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
41 |
The actual call to fetchFeed() will be done from the timer function updateFeedTimerFunc() |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
42 |
that runs once a second. There we'll need an if-clause that checks if it's time |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
43 |
to update the feeds, if another update is already going on, if we have a valid URL |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
44 |
that we can fetch and if we're in the main view. If all of these tests tell us |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
45 |
that it's time to update the feed, we'll check if the feed update was manually |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
46 |
commanded or automatically triggered because it was time to update the feed in |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
47 |
the background. If this is a manual update then we'll popup a progress notification |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
48 |
dialog. Next we'll create a new instance of the FeedUpdateBroker class and call |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
49 |
the fetchFeed() method to start the AJAX-based RSS feed update. We need to pass |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
50 |
two arguments to this method: the feed URL that we have in the feedURL variable |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
51 |
and a callback function that should be called when the update is completed. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
52 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
53 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
54 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
55 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
56 |
We don't have that function yet so that's the first thing we need to implement. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
57 |
We'll leave it empty for now but return to it in a bit: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
58 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
59 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
60 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
61 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
62 |
// Callback function that gets called when a feed update has completed. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
63 |
function feedUpdateCompleted(event) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
64 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
65 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
66 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
67 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
68 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
69 |
After we call the fetchFeed() function we'll schedule the next feed update. In |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
70 |
theory we shouldn't do this until the feed update completes since there is a risk |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
71 |
that we do two updates at the same time. But because we're adding a check to |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
72 |
only do feed updates if another update isn't on-going this risk isn't actually |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
73 |
real. Now that we have a plan for how to update the feed, let's write the code. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
74 |
First we need to declare a variable for the feed update broker instance that |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
75 |
we'll create: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
76 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
77 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
78 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
79 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
80 |
// Feed update broker. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
81 |
var feedUpdateBroker = null; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
82 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
83 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
84 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
85 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
86 |
Then the actual implementation for the updateFeedTimerFunc() timer function: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
87 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
88 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
89 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
90 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
91 |
// Timer function for feed updates - called once every second. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
92 |
function updateFeedTimerFunc() { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
93 |
var now = new Date().getTime(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
94 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
95 |
// check if a feed update has been scheduled, if it's time to update now, |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
96 |
// and if there's no update currently in progress and if we're in the main view |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
97 |
if ((feedURL != null) && |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
98 |
(feedUpdateTime != -1) && |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
99 |
(now > feedUpdateTime) && |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
100 |
(feedUpdateBroker == null) && |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
101 |
(uiManager.getView() == mainView)) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
102 |
// show progress dialog if this is a commanded feed update |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
103 |
if (feedUpdateCommanded) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
104 |
// no auto hiding, wait-type notification, unknown progress |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
105 |
uiManager.showNotification(-1, "wait", "Loading feed...", -1); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
106 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
107 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
108 |
// fetch the feed from the specified URL |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
109 |
feedUpdateBroker = new FeedUpdateBroker(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
110 |
feedUpdateBroker.fetchFeed(feedURL, feedUpdateCompleted); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
111 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
112 |
if (feedUpdateFrequency != -1) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
113 |
// schedule next update |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
114 |
feedUpdateTime = now + feedUpdateFrequency; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
115 |
} else { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
116 |
// feed update frequency is "never" |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
117 |
feedUpdateTime = -1; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
118 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
119 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
120 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
121 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
122 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
123 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
124 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
125 |
The progress dialog is created so that it has a display time of -1 so that |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
126 |
it doesn't automatically hide but rather has to be commanded to go away. The |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
127 |
notification dialog type is "wait" and we'll give a progress of -1 since we |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
128 |
don't know how far along in the feed updating process we are. A negative |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
129 |
progress value like -1 means "unknown progress" and will result in an animated |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
130 |
progress indicator that shows that something is going on but the exact time |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
131 |
that it will take is unknown. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
132 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
133 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
134 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
135 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
136 |
Our feed updating should now be working and whenever a feed update is completed |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
137 |
there should be a call to the empty feedUpdateCompleted() function. Let's |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
138 |
continue the implementation there. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
139 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
140 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
141 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
142 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
143 |
When the feedUpdateCompleted() function is called it receives an event object |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
144 |
from the FeedUpdateBroker. This object contains a status that is either "ok" |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
145 |
or "error", a "lastModifiedTime" string that contains the time when the RSS |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
146 |
feed was last modified to help us decide if there are any new news items to |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
147 |
display, as well as an array of news item objects in a property called "items". |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
148 |
If the status is "error" then we'll show an error notification dialog. Keep in |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
149 |
mind that there might or might not be a progress dialog already showing at this |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
150 |
time. Either way we can just call the showNotification() function in the user |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
151 |
interface manager because if another dialog is already visible then it will simply |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
152 |
replace it with the one that we asked it to show. If the status is "ok" then we'll |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
153 |
call hideNotification() in the user interface manager. This will hide the progress |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
154 |
dialog if it's showing and if the dialog wasn't showing then the call will just |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
155 |
be ignored. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
156 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
157 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
158 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
159 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
160 |
We'll then need to compare the lastModifiedTime against the last news feed that |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
161 |
we have. That means we'll need to track the lastModifiedTime of whatever news |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
162 |
feed that we are showing, and that means we need a new global variable: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
163 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
164 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
165 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
166 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
167 |
// Time when the feed was last modified. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
168 |
var feedLastModified = null; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
169 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
170 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
171 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
172 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
173 |
If the lastModifiedTime is different from the one that we are storing in the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
174 |
feedLastModified variable then we know that there's new news items to show. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
175 |
If this is the case then we'll update the feedLastModified time and set the news |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
176 |
items to the main view. We could do something fancy and only update the news items |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
177 |
that have been modified but to keep the tutorial simple we'll just simply remove |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
178 |
all the current items and replace them with the new items and then focus the first |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
179 |
of the items. But before we move on to that we'll write as much as we can of the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
180 |
feedUpdateCompleted() function: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
181 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
182 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
183 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
184 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
185 |
// Callback function that gets called when a feed update has completed. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
186 |
function feedUpdateCompleted(event) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
187 |
if (event.status == "ok") { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
188 |
// if there aren't any feed items yet, we'll hide the progress dialog |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
189 |
if (feedUpdateCommanded) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
190 |
uiManager.hideNotification(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
191 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
192 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
193 |
// check if the feed has updated |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
194 |
if (event.lastModified != feedLastModified) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
195 |
// remember the last modified timestamp |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
196 |
feedLastModified = event.lastModified; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
197 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
198 |
// update news item controls here |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
199 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
200 |
} else { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
201 |
// show error message |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
202 |
uiManager.showNotification(3000, "warning", "Error while updating feed!<br/>(check network settings)"); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
203 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
204 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
205 |
// null the broker reference to indicate that there's no current |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
206 |
// update in progress |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
207 |
feedUpdateBroker = null; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
208 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
209 |
// reset commanded feed update flag |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
210 |
feedUpdateCommanded = false; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
211 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
212 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
213 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
214 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
215 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
216 |
We wrote a comment "update news item controls here" at the spot where we will |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
217 |
actually create and add news feed items to the main view. We'll replace that in |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
218 |
a bit with the actual code to do the job, but first we need to write some code |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
219 |
that we'll need to do that. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
220 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
221 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
222 |
</div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
223 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
224 |
<div class="section"><h2 class="sectiontitle"> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
225 |
Showing news items</h2> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
226 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
227 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
228 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
229 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
230 |
The news feed items will be shown using ContentPanel controls. We'll need a way |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
231 |
to keep track of the ones we're showing so that we can easily remove them when |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
232 |
there is new news items to show. Let's create an array to track them: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
233 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
234 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
235 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
236 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
237 |
// Reference to current feed items controls. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
238 |
var feedItemControls = []; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
239 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
240 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
241 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
242 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
243 |
Now we can implement a function that will remove all controls that are tracked |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
244 |
by this array from the main view. We'll use this as the first step when we want |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
245 |
to display news items. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
246 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
247 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
248 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
249 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
250 |
// Removes feed items. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
251 |
function removeFeedItems() { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
252 |
// remove all current feed items from the main view |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
253 |
for (var i = 0; i < feedItemControls.length; i++) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
254 |
mainView.removeControl(feedItemControls[i]); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
255 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
256 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
257 |
// reset feed item control array |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
258 |
feedItemControls = []; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
259 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
260 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
261 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
262 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
263 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
264 |
The function simply loops through the array and calls the removeControl() method |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
265 |
in the main view to remove each of the feed item controls from the view, one at a time. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
266 |
Finally we'll reset the feedItemControls array so that it reflects the fact that |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
267 |
there are no more controls in the main view. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
268 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
269 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
270 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
271 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
272 |
What about adding news items? We'll do that in a function that we'll call from the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
273 |
feedUpdateCompleted() function. Let's call the function setFeedItems(). The function |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
274 |
will start by calling the removeFeedItems() function we just created to empty the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
275 |
main view from news items before we start adding new ones to it. After this we'll |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
276 |
loop through the news feed items that were handed to us from the FeedUpdateBroker. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
277 |
For each one we need a ContentPanel control. We'll be recycling the controls instead |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
278 |
of constantly creating new ones over and over again as new news items come in. To |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
279 |
this end we'll need a way to track ContentPanel controls that we have already |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
280 |
created. We'll do this by creating an array called feedItemControlPool, which will |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
281 |
be a global variable: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
282 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
283 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
284 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
285 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
286 |
// Feed item control pool. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
287 |
var feedItemControlPool = []; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
288 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
289 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
290 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
291 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
292 |
If we have enough controls in the pool we'll just take them from there. Otherwise |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
293 |
we'll create a new ContentPanel and add it to the pool. Either way we'll end up with |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
294 |
a ContentPanel control that is ready to be used. We'll need to reset its state since we |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
295 |
recycled it, so we make sure it's collapsed rather than expanded, we'll set its caption |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
296 |
to the title of the news item and we'll generate some HTML from the news item summary |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
297 |
that we'll set as the content for the ContentPanel. And then finally we'll add the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
298 |
ContentPanel to the main view. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
299 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
300 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
301 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
302 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
303 |
Lets create the code but skip the HTML for the news item summary for now: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
304 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
305 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
306 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
307 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
308 |
// Sets feed items. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
309 |
function setFeedItems(items) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
310 |
// start by removing all current feed items |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
311 |
removeFeedItems(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
312 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
313 |
// create new feed items and add them to the main view |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
314 |
// use feed item pool to recycle controls |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
315 |
for (var i = 0; i < items.length; i++) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
316 |
// get a feed item control from the pool or create one and |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
317 |
// place it in the pool if there aren't enough feed item controls |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
318 |
var feedItemControl; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
319 |
if (i == feedItemControlPool.length) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
320 |
feedItemControl = new ContentPanel(null, null, null, true); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
321 |
feedItemControlPool.push(feedItemControl); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
322 |
} else { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
323 |
feedItemControl = feedItemControlPool[i]; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
324 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
325 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
326 |
// initialize feed item control |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
327 |
var item = items[i]; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
328 |
feedItemControl.setCaption(item.title); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
329 |
feedItemControl.setContent("placeholder"); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
330 |
feedItemControl.setExpanded(false); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
331 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
332 |
// add the feed item control to the main view |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
333 |
feedItemControls.push(feedItemControl); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
334 |
mainView.addControl(feedItemControl); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
335 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
336 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
337 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
338 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
339 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
340 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
341 |
The items argument contains the array of news items that we received in the event |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
342 |
object argument to the feedUpdateCompleted() callback function. The items are in |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
343 |
the "items" property of the event object. Note how the feedItemControl is either |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
344 |
created or taken from the feedItemControlPool. If it's created it is given four |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
345 |
arguments: a null unique identifier because we don't need one, a null caption and |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
346 |
a null content because we will set both every time before we show it, and finally |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
347 |
a value of true to the "foldable" argument in the ContentPanel constructor. This |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
348 |
flag determines whether the ContentPanel can be folded (expanded and collapsed) or |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
349 |
not. We want a foldable one so we pass true to this argument. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
350 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
351 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
352 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
353 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
354 |
Once we have the ContentPanel (either from the pool or newly created) we set its |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
355 |
state: caption, content and expanded state. Note that for now we'll just set a |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
356 |
placeholder string as the content. Also note that we set the expanded state to false |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
357 |
to collapse the news items by default. Finally we add the content panels to the main |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
358 |
view and to the feedItemControls array that tracks all the ContentPanels that we use |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
359 |
for the news items. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
360 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
361 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
362 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
363 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
364 |
Now that we have written the code to create and add news items to the main view |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
365 |
we have to hook that up to the feedUpdateCompleted() function. Remember we added |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
366 |
a comment in the spot where we should return to do this? Let's replace that comment |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
367 |
with the following: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
368 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
369 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
370 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
371 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
372 |
// set feed items to the main view |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
373 |
setFeedItems(event.items); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
374 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
375 |
// focus the first feed item control |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
376 |
// (but only if we are in the main view) |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
377 |
if (uiManager.getView() == mainView && feedItemControls.length > 0) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
378 |
feedItemControls[0].setFocused(true); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
379 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
380 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
381 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
382 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
383 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
384 |
We just call the setFeedItems() function we just wrote, passing it the feed items |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
385 |
that the FeedUpdateBroker fetched and parsed for us, and then if we're in the main |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
386 |
view we'll focus the first of the news feed item controls. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
387 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
388 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
389 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
390 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
391 |
Now that we have all the code needed to fetch and update news feed items we'll go |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
392 |
back and add some more functionality to a function we wrote a little bit earlier: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
393 |
the saveSettingsClicked() function. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
394 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
395 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
396 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
397 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
398 |
The functionality that we're adding will handle updates of the feed items in the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
399 |
main view after the user has modified the settings. We didn't write this earlier |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
400 |
because we didn't have all the necessary support code in place but we can add it now. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
401 |
First we add some code to the end of the saveSettingsClicked() function to force an |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
402 |
update of the news items after the users saves the settings: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
403 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
404 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
405 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
406 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
407 |
// update the feed |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
408 |
feedLastModified = null; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
409 |
updateFeed(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
410 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
411 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
412 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
413 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
414 |
We update the feed by setting the feedLastModified variable to null to force an update |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
415 |
and then calling updateFeed(). This causes an immediate feed update and we also get the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
416 |
progress notification dialog, which is what we want because this was a manual |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
417 |
update that was caused by the user clicking "save". |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
418 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
419 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
420 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
421 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
422 |
Let's also add some code that checks if a new feed was selected and removes all the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
423 |
news items from the main view if the user selected a new feed. To do this we'll first |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
424 |
copy the old feedURL to a variable that we'll call oldFeedURL at the very beginning |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
425 |
of the function: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
426 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
427 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
428 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
429 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
430 |
// remember the old feed URL |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
431 |
var oldFeedURL = feedURL; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
432 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
433 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
434 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
435 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
436 |
Then we'll add the following just before we show the main view: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
437 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
438 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
439 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
440 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
441 |
// remove all feed items if the user selected a new feed |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
442 |
if (feedURL != oldFeedURL) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
443 |
removeFeedItems(); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
444 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
445 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
446 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
447 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
448 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
449 |
We can now test this in a PC browser, handset or emulator. Everything should work |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
450 |
except that there's still nothing but a placeholder for the actual content in each |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
451 |
ContentPanel. You can still expand and collapse the ContentPanels and the settings |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
452 |
and automatic and manual updates are working. We're almost done but we still need |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
453 |
to implement the code that will actually show news item summaries in the content |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
454 |
panels. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
455 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
456 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
457 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
458 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
459 |
Remember we said that we would implement news items so that there's a link from |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
460 |
each news item to the website where the full article is. When you open links |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
461 |
to external websites in the S60 Web Runtime you should use the widget.openURL() |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
462 |
function. But PC browsers don't have that function so we'll need to create a wrapper |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
463 |
function that either calls widget.openURL() if we're in the Web Runtime or just |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
464 |
opens a new window if we're in a PC browser. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
465 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
466 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
467 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
468 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
469 |
// Opens a URL. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
470 |
function openURL(url) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
471 |
if (window.widget) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
472 |
// in WRT |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
473 |
widget.openURL(url); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
474 |
} else { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
475 |
// outside WRT |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
476 |
window.open(url, "NewWindow"); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
477 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
478 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
479 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
480 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
481 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
482 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
483 |
Content in a ContentPanel control is a fragment of HTML. In other words it's a |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
484 |
piece of HTML that will be inserted into the control using code. That means that |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
485 |
in order to display the news item we will have to generate some HTML for it. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
486 |
We need a function that will take a news item object and return some HTML that |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
487 |
we can give to thet setContent() method in the ContentPanel control. Let's write |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
488 |
that function: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
489 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
490 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
491 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
492 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
493 |
// Returns the content HTML for a feed item. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
494 |
function getContentHTMLForFeedItem(item) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
495 |
var buf = ""; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
496 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
497 |
// item date |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
498 |
if (item.date != null) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
499 |
buf += "<div class=\"FeedItemDate\">" + item.date + "</div>"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
500 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
501 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
502 |
// item description |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
503 |
if (item.description != null) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
504 |
buf += "<div class=\"FeedItemDescription\">" + item.description + "</div>"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
505 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
506 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
507 |
// item URL |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
508 |
if (item.url != null) { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
509 |
buf += "<div class=\"FeedItemLink\">"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
510 |
buf += "<a href=\"JavaScript:openURL('" + item.url + "');\">"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
511 |
buf += "Read more..."; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
512 |
buf += "</a>"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
513 |
buf += "</div>"; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
514 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
515 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
516 |
return buf; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
517 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
518 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
519 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
520 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
521 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
522 |
The function uses the properties in the news item object that the FeedUpdateBroker |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
523 |
created for us. There's a date property that has the publish date of the news item. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
524 |
There's a description that contains the actual summary, and there's a URL that points |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
525 |
to the website where the full article is. Note that we're using the openURL() wrapper |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
526 |
function that we just wrote for the link to the full article. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
527 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
528 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
529 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
530 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
531 |
Our HTML is very simple: three div-tags that have the date, description and a link as |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
532 |
their content. And ech of them has a CSS class so that we can match them with some |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
533 |
style rules. Since we have three different pieces of data we need three CSS rules: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
534 |
FeedItemDate for the date, FeedItemDescription for the news item summary and finally |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
535 |
FeedItemLink for the link to the website. Let's create these in the RSSReader.css |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
536 |
stylesheet file: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
537 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
538 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
539 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
540 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
541 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
542 |
/* Feed item date */ |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
543 |
.FeedItemDate { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
544 |
font-style: italic; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
545 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
546 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
547 |
/* Feed item text */ |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
548 |
.FeedItemDescription { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
549 |
padding: 4px 0px; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
550 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
551 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
552 |
/* Feed item links */ |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
553 |
.FeedItemLink { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
554 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
555 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
556 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
557 |
/* Anchor tags in the context of a feed item link */ |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
558 |
.FeedItemLink a { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
559 |
text-decoration: underline; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
560 |
font-weight: bold; |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
561 |
color: rgb(0,0,255); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
562 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
563 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
564 |
/* Focused anchor tags */ |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
565 |
.FeedItemLink a:focus { |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
566 |
background: rgb(0,0,255); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
567 |
color: rgb(255,255,255); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
568 |
} |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
569 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
570 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
571 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
572 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
573 |
The rule for links can be left empty because we will just use default ContentPanel |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
574 |
content styling. However we'll change the way the link looks in the context of that |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
575 |
FeedItemLink div. We'll make links blue, bold and underlined in their normal state |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
576 |
and inverse with a blue background and white text color when focused. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
577 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
578 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
579 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
580 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
581 |
Now that we have a function that generates HTML for the ContentPanel we can remove |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
582 |
the placeholder content replace it with a call to our function: |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
583 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
584 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
585 |
<pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
586 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
587 |
feedItemControl.setContent(getContentHTMLForFeedItem(item)); |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
588 |
</pre> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
589 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
590 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
591 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
592 |
We're done! Now you can try the widget in a PC browser and then on the handset |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
593 |
or emulator. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
594 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
595 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
596 |
<div class="fignone" id="GUID-25CD0E54-0516-4469-965E-C5781CF44DC9__GUID-F7A5DBAA-7F9F-4C48-A25A-0DACE463CBF4"><a name="GUID-25CD0E54-0516-4469-965E-C5781CF44DC9__GUID-F7A5DBAA-7F9F-4C48-A25A-0DACE463CBF4"><!-- --></a><span class="figcap">Figure 1. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
597 |
RSS Reader main view</span> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
598 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
599 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
600 |
<br /><img src="RSS_Reader_Main_Screenshot_1.png" /><br /> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
601 |
</div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
602 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
603 |
</div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
604 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
605 |
<div class="section"><h2 class="sectiontitle"> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
606 |
What we have learned</h2> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
607 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
608 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
609 |
<p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
610 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
611 |
The RSS Reader tutorial has taught us several things. We have learned to create a widget |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
612 |
that has more than just one view. We have learned how to use several new WRTKit controls. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
613 |
We used the SelectionList, SelectionMenu and FormButton controls in our settings view, |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
614 |
and in the main view we used the ContentPanel control that allowed us to add our own |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
615 |
content as a seamless part of the rest of the user interface using HTML fragments that |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
616 |
we styled with CSS rules. We have learned to modify a view while the widget runs by adding |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
617 |
and removing controls. And we have learned how to separate our widget code so that the |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
618 |
user interface code doesn't contain any logic code and so that the logic code doesn't |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
619 |
contain any user interface code. |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
620 |
</p> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
621 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
622 |
</div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
623 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
624 |
</div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
625 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
626 |
<div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
627 |
<div class="familylinks"> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
628 |
<div class="parentlink"><strong>Parent topic:</strong> <a href="WRTKit_RSS_Reader_Tutorial-GUID-678d197f-c7b0-4e5e-85e2-f8549c75bbe8.html">RSS Reader</a></div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
629 |
</div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
630 |
</div> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
631 |
|
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
632 |
</body> |
7848c135d915
Fixed 2046 - WRTKit Help. Renamed package for consistency.
tasneems@symbian.org
parents:
diff
changeset
|
633 |
</html> |