Permalink
Browse files

fleshed out the FileScheduleRetriever class so that it uses the new

interface
  • Loading branch information...
1 parent a6e7671 commit 675fdeedd2245414aeee61533b250169060a5bc1 @taesup taesup committed Dec 9, 2011
Showing with 33 additions and 20 deletions.
  1. +33 −20 src/org/hicapacity/techhui/FileScheduleRetriever.java
@@ -13,25 +13,38 @@
*
*/
public class FileScheduleRetriever implements ScheduleRetriever {
- AssetManager mManager;
-
- public FileScheduleRetriever(AssetManager manager) {
- mManager = manager;
- }
-
- /** {@inheritDoc} */
- public List<ScheduleElement> getElements() throws IOException {
- ArrayList<ScheduleElement> scheduleListToReturn = new ArrayList<ScheduleElement>();
-
- BufferedReader br = new BufferedReader(new InputStreamReader(mManager.open("data.txt")));
-
- String line;
- while ((line = br.readLine()) != null) {
- System.out.println(line);
- ScheduleElement scheduleElement = ScheduleElement.parseFromString(line);
- scheduleListToReturn.add(scheduleElement);
- }
- return scheduleListToReturn;
- }
+ AssetManager mManager;
+ private List<ScheduleElement> track1 = new ArrayList<ScheduleElement>();
+ private List<ScheduleElement> track2 = new ArrayList<ScheduleElement>();
+
+ public FileScheduleRetriever(AssetManager manager) throws IOException {
+ // some manager?
+ mManager = manager;
+
+ // read in file on class instantiation
+ BufferedReader br = new BufferedReader(new InputStreamReader(mManager.open("data.txt")));
+
+ String line;
+ while ((line = br.readLine()) != null) {
+ System.out.println(line);
+ ScheduleElement scheduleElement = ScheduleElement.parseFromString(line);
+
+ if (scheduleElement.getmTrack().equalsIgnoreCase("one")) {
+ this.track1.add(scheduleElement);
+ }
+
+ if (scheduleElement.getmTrack().equalsIgnoreCase("two")) {
+ this.track2.add(scheduleElement);
+ }
+ }
+ }
+
+ public List<ScheduleElement> getTrack1Elements() throws IOException {
+ return this.track1;
+ }
+
+ public List<ScheduleElement> getTrack2Elements() throws IOException {
+ return this.track2;
+ }
}

0 comments on commit 675fdee

Please sign in to comment.