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