OLD | NEW |
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 92 } |
93 | 93 |
94 List<Section> filter(bool f(Section element)) { | 94 List<Section> filter(bool f(Section element)) { |
95 return Collections.filter(this, new List<Section>(), f); | 95 return Collections.filter(this, new List<Section>(), f); |
96 } | 96 } |
97 bool every(bool f(Section element)) => Collections.every(this, f); | 97 bool every(bool f(Section element)) => Collections.every(this, f); |
98 bool some(bool f(Section element)) => Collections.some(this, f); | 98 bool some(bool f(Section element)) => Collections.some(this, f); |
99 void forEach(void f(Section element)) { Collections.forEach(this, f); } | 99 void forEach(void f(Section element)) { Collections.forEach(this, f); } |
100 | 100 |
101 // TODO(jmesserly): this should be a property | 101 // TODO(jmesserly): this should be a property |
102 bool isEmpty() => length == 0; | 102 bool get isEmpty => length == 0; |
103 } | 103 } |
104 | 104 |
105 | 105 |
106 /** A collection of data sources representing a page in the UI. */ | 106 /** A collection of data sources representing a page in the UI. */ |
107 class Section { | 107 class Section { |
108 final String id; | 108 final String id; |
109 final String title; | 109 final String title; |
110 ObservableList<Feed> feeds; | 110 ObservableList<Feed> feeds; |
111 | 111 |
112 // Public for testing. TODO(jacobr): find a cleaner solution. | 112 // Public for testing. TODO(jacobr): find a cleaner solution. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 final hasThumbnail = decoder.readBool(); | 239 final hasThumbnail = decoder.readBool(); |
240 final author = decoder.readString(); | 240 final author = decoder.readString(); |
241 final dateInSeconds = decoder.readInt(); | 241 final dateInSeconds = decoder.readInt(); |
242 final snippet = decoder.readString(); | 242 final snippet = decoder.readString(); |
243 final date = | 243 final date = |
244 new Date.fromMillisecondsSinceEpoch(dateInSeconds*1000, isUtc: true); | 244 new Date.fromMillisecondsSinceEpoch(dateInSeconds*1000, isUtc: true); |
245 return new Article(source, id, date, title, author, srcUrl, hasThumbnail, | 245 return new Article(source, id, date, title, author, srcUrl, hasThumbnail, |
246 snippet); | 246 snippet); |
247 } | 247 } |
248 } | 248 } |
OLD | NEW |