| 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 extends Collection<Section> { | 7 class Sections extends Collection<Section> { |
| 8 final List<Section> _sections; | 8 final List<Section> _sections; |
| 9 | 9 |
| 10 Sections(this._sections); | 10 Sections(this._sections); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 if (name == _sections[i].title) { | 80 if (name == _sections[i].title) { |
| 81 return i; | 81 return i; |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 return -1; | 84 return -1; |
| 85 } | 85 } |
| 86 | 86 |
| 87 List<Section> get sections => _sections; | 87 List<Section> get sections => _sections; |
| 88 | 88 |
| 89 // Collection<Section> methods: | 89 // Collection<Section> methods: |
| 90 List<Section> where(bool f(Section element)) { | |
| 91 return Collections.where(this, new List<Section>(), f); | |
| 92 } | |
| 93 bool every(bool f(Section element)) => Collections.every(this, f); | 90 bool every(bool f(Section element)) => Collections.every(this, f); |
| 94 bool some(bool f(Section element)) => Collections.some(this, f); | 91 bool some(bool f(Section element)) => Collections.some(this, f); |
| 95 void forEach(void f(Section element)) { Collections.forEach(this, f); } | 92 void forEach(void f(Section element)) { Collections.forEach(this, f); } |
| 96 | 93 |
| 97 // TODO(jmesserly): this should be a property | 94 // TODO(jmesserly): this should be a property |
| 98 bool get isEmpty => length == 0; | 95 bool get isEmpty => length == 0; |
| 99 } | 96 } |
| 100 | 97 |
| 101 | 98 |
| 102 /** A collection of data sources representing a page in the UI. */ | 99 /** A collection of data sources representing a page in the UI. */ |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 final hasThumbnail = decoder.readBool(); | 232 final hasThumbnail = decoder.readBool(); |
| 236 final author = decoder.readString(); | 233 final author = decoder.readString(); |
| 237 final dateInSeconds = decoder.readInt(); | 234 final dateInSeconds = decoder.readInt(); |
| 238 final snippet = decoder.readString(); | 235 final snippet = decoder.readString(); |
| 239 final date = | 236 final date = |
| 240 new Date.fromMillisecondsSinceEpoch(dateInSeconds*1000, isUtc: true); | 237 new Date.fromMillisecondsSinceEpoch(dateInSeconds*1000, isUtc: true); |
| 241 return new Article(source, id, date, title, author, srcUrl, hasThumbnail, | 238 return new Article(source, id, date, title, author, srcUrl, hasThumbnail, |
| 242 snippet); | 239 snippet); |
| 243 } | 240 } |
| 244 } | 241 } |
| OLD | NEW |