Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Side by Side Diff: client/samples/swarm/DataSource.dart

Issue 8966029: Report errors and warnings for hiding elements, issue 572. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** The top-level collection of all sections for a user. */ 5 /** The top-level collection of all sections for a user. */
6 // TODO(jimhug): This is known as UserData in the server model. 6 // TODO(jimhug): This is known as UserData in the server model.
7 class Sections implements Collection<Section> { 7 class Sections implements Collection<Section> {
8 final List<Section> _sections; 8 final List<Section> _sections;
9 9
10 Sections(this._sections); 10 Sections(this._sections);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 final sectionTitle = decoder.readString(); 119 final sectionTitle = decoder.readString();
120 120
121 final nSources = decoder.readInt(); 121 final nSources = decoder.readInt();
122 final feeds = new ObservableList<Feed>(); 122 final feeds = new ObservableList<Feed>();
123 for (int j=0; j < nSources; j++) { 123 for (int j=0; j < nSources; j++) {
124 feeds.add(Feed.decode(decoder)); 124 feeds.add(Feed.decode(decoder));
125 } 125 }
126 return new Section(sectionId, sectionTitle, feeds); 126 return new Section(sectionId, sectionTitle, feeds);
127 } 127 }
128 128
129 Feed findFeed(String id) { 129 Feed findFeed(String id_) {
130 return CollectionUtils.find(feeds, (feed) => feed.id == id); 130 return CollectionUtils.find(feeds, (feed) => feed.id == id_);
131 } 131 }
132 } 132 }
133 133
134 /** Provider of a news feed. */ 134 /** Provider of a news feed. */
135 class Feed { 135 class Feed {
136 String id; 136 String id;
137 final String title; 137 final String title;
138 final String iconUrl; 138 final String iconUrl;
139 final String description; 139 final String description;
140 ObservableList<Article> articles; 140 ObservableList<Article> articles;
141 ObservableValue<bool> error; // TODO(jimhug): Check if dead code. 141 ObservableValue<bool> error; // TODO(jimhug): Check if dead code.
142 142
143 Feed(this.id, this.title, this.iconUrl, [this.description = '']) 143 Feed(this.id, this.title, this.iconUrl, [this.description = ''])
144 : articles = new ObservableList<Article>(), 144 : articles = new ObservableList<Article>(),
145 error = new ObservableValue<bool>(false); 145 error = new ObservableValue<bool>(false);
146 146
147 static Feed decode(Decoder decoder) { 147 static Feed decode(Decoder decoder) {
148 final sourceId = decoder.readString(); 148 final sourceId = decoder.readString();
149 final sourceTitle = decoder.readString(); 149 final sourceTitle = decoder.readString();
150 final sourceIcon = decoder.readString(); 150 final sourceIcon = decoder.readString();
151 final feed = new Feed(sourceId, sourceTitle, sourceIcon); 151 final feed = new Feed(sourceId, sourceTitle, sourceIcon);
152 final nItems = decoder.readInt(); 152 final nItems = decoder.readInt();
153 153
154 for (int i=0; i < nItems; i++) { 154 for (int i=0; i < nItems; i++) {
155 feed.articles.add(Article.decodeHeader(feed, decoder)); 155 feed.articles.add(Article.decodeHeader(feed, decoder));
156 } 156 }
157 return feed; 157 return feed;
158 } 158 }
159 159
160 Article findArticle(String id) { 160 Article findArticle(String id_) {
161 return CollectionUtils.find(articles, (article) => article.id == id); 161 return CollectionUtils.find(articles, (article) => article.id == id_);
162 } 162 }
163 163
164 void refresh() {} 164 void refresh() {}
165 } 165 }
166 166
167 167
168 /** A single article or posting to display. */ 168 /** A single article or posting to display. */
169 class Article { 169 class Article {
170 final String id; 170 final String id;
171 Date date; 171 Date date;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 final srcUrl = decoder.readString(); 234 final srcUrl = decoder.readString();
235 final hasThumbnail = decoder.readBool(); 235 final hasThumbnail = decoder.readBool();
236 final author = decoder.readString(); 236 final author = decoder.readString();
237 final dateInSeconds = decoder.readInt(); 237 final dateInSeconds = decoder.readInt();
238 final snippet = decoder.readString(); 238 final snippet = decoder.readString();
239 final date = new Date.fromEpoch(dateInSeconds*1000, new TimeZone.utc()); 239 final date = new Date.fromEpoch(dateInSeconds*1000, new TimeZone.utc());
240 return new Article(source, id, date, title, author, srcUrl, hasThumbnail, 240 return new Article(source, id, date, title, author, srcUrl, hasThumbnail,
241 snippet); 241 snippet);
242 } 242 }
243 } 243 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698