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

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

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months 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
« no previous file with comments | « samples/spirodraw/Spirodraw.dart ('k') | samples/swarm/UIState.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of swarmlib; 5 part of swarmlib;
6 6
7 /** The top-level collection of all sections for a user. */ 7 /** The top-level collection of all sections for a user. */
8 // TODO(jimhug): This is known as UserData in the server model. 8 // TODO(jimhug): This is known as UserData in the server model.
9 class Sections implements Collection<Section> { 9 class Sections extends Collection<Section> {
10 final List<Section> _sections; 10 final List<Section> _sections;
11 11
12 Sections(this._sections); 12 Sections(this._sections);
13 13
14 operator [](int i) => _sections[i]; 14 operator [](int i) => _sections[i];
15 15
16 int get length => _sections.length; 16 int get length => _sections.length;
17 17
18 List<String> get sectionTitles => 18 List<String> get sectionTitles =>
19 CollectionUtils.map(_sections, (s) => s.title); 19 _sections.mappedBy((s) => s.title).toList();
20 20
21 void refresh() { 21 void refresh() {
22 // TODO(jimhug): http://b/issue?id=5351067 22 // TODO(jimhug): http://b/issue?id=5351067
23 } 23 }
24 24
25 /** 25 /**
26 * Find the Section object that has a given title. 26 * Find the Section object that has a given title.
27 * This is used to integrate well with [ConveyorView]. 27 * This is used to integrate well with [ConveyorView].
28 */ 28 */
29 Section findSection(String name) { 29 Section findSection(String name) {
30 return CollectionUtils.find(_sections, (sect) => sect.title == name); 30 return CollectionUtils.find(_sections, (sect) => sect.title == name);
31 } 31 }
32 32
33 // TODO(jimhug): Track down callers! 33 // TODO(jimhug): Track down callers!
34 Iterator<Section> iterator() => _sections.iterator(); 34 Iterator<Section> get iterator => _sections.iterator;
35 35
36 // TODO(jimhug): Better support for switching between local dev and server. 36 // TODO(jimhug): Better support for switching between local dev and server.
37 static bool get runningFromFile { 37 static bool get runningFromFile {
38 return window.location.protocol.startsWith('file:'); 38 return window.location.protocol.startsWith('file:');
39 } 39 }
40 40
41 static String get home { 41 static String get home {
42 // TODO(jmesserly): window.location.origin not available on Safari 4. 42 // TODO(jmesserly): window.location.origin not available on Safari 4.
43 // Move this workaround to the DOM code. See bug 5389503. 43 // Move this workaround to the DOM code. See bug 5389503.
44 return '${window.location.protocol}//${window.location.host}'; 44 return '${window.location.protocol}//${window.location.host}';
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 if (name == _sections[i].title) { 82 if (name == _sections[i].title) {
83 return i; 83 return i;
84 } 84 }
85 } 85 }
86 return -1; 86 return -1;
87 } 87 }
88 88
89 List<Section> get sections => _sections; 89 List<Section> get sections => _sections;
90 90
91 // Collection<Section> methods: 91 // Collection<Section> methods:
92 List map(f(Section element)) {
93 return Collections.map(this, new List(), f);
94 }
95
96 List<Section> filter(bool f(Section element)) {
97 return Collections.filter(this, new List<Section>(), f);
98 }
99 bool every(bool f(Section element)) => Collections.every(this, f); 92 bool every(bool f(Section element)) => Collections.every(this, f);
100 bool some(bool f(Section element)) => Collections.some(this, f); 93 bool any(bool f(Section element)) => Collections.any(this, f);
101 void forEach(void f(Section element)) { Collections.forEach(this, f); } 94 void forEach(void f(Section element)) { Collections.forEach(this, f); }
102 95
103 // TODO(jmesserly): this should be a property 96 // TODO(jmesserly): this should be a property
104 bool get isEmpty => length == 0; 97 bool get isEmpty => length == 0;
105 } 98 }
106 99
107 100
108 /** A collection of data sources representing a page in the UI. */ 101 /** A collection of data sources representing a page in the UI. */
109 class Section { 102 class Section {
110 final String id; 103 final String id;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 final hasThumbnail = decoder.readBool(); 234 final hasThumbnail = decoder.readBool();
242 final author = decoder.readString(); 235 final author = decoder.readString();
243 final dateInSeconds = decoder.readInt(); 236 final dateInSeconds = decoder.readInt();
244 final snippet = decoder.readString(); 237 final snippet = decoder.readString();
245 final date = 238 final date =
246 new Date.fromMillisecondsSinceEpoch(dateInSeconds*1000, isUtc: true); 239 new Date.fromMillisecondsSinceEpoch(dateInSeconds*1000, isUtc: true);
247 return new Article(source, id, date, title, author, srcUrl, hasThumbnail, 240 return new Article(source, id, date, title, author, srcUrl, hasThumbnail,
248 snippet); 241 snippet);
249 } 242 }
250 } 243 }
OLDNEW
« no previous file with comments | « samples/spirodraw/Spirodraw.dart ('k') | samples/swarm/UIState.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698