| 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 |
| 93 // TODO(jmesserly): this should be a property | 98 // TODO(jmesserly): this should be a property |
| 94 bool get isEmpty => length == 0; | 99 bool get isEmpty => length == 0; |
| 95 } | 100 } |
| 96 | 101 |
| 97 | 102 |
| 98 /** A collection of data sources representing a page in the UI. */ | 103 /** A collection of data sources representing a page in the UI. */ |
| 99 class Section { | 104 class Section { |
| 100 final String id; | 105 final String id; |
| 101 final String title; | 106 final String title; |
| 102 ObservableList<Feed> feeds; | 107 ObservableList<Feed> feeds; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 final hasThumbnail = decoder.readBool(); | 236 final hasThumbnail = decoder.readBool(); |
| 232 final author = decoder.readString(); | 237 final author = decoder.readString(); |
| 233 final dateInSeconds = decoder.readInt(); | 238 final dateInSeconds = decoder.readInt(); |
| 234 final snippet = decoder.readString(); | 239 final snippet = decoder.readString(); |
| 235 final date = | 240 final date = |
| 236 new DateTime.fromMillisecondsSinceEpoch(dateInSeconds*1000, isUtc: true)
; | 241 new DateTime.fromMillisecondsSinceEpoch(dateInSeconds*1000, isUtc: true)
; |
| 237 return new Article(source, id, date, title, author, srcUrl, hasThumbnail, | 242 return new Article(source, id, date, title, author, srcUrl, hasThumbnail, |
| 238 snippet); | 243 snippet); |
| 239 } | 244 } |
| 240 } | 245 } |
| OLD | NEW |