/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/provider/OfflineStationProvider.java
ViewVC logotype

Diff of /android/TrainInfo/src/dk/thoerup/traininfo/provider/OfflineStationProvider.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1567 by torben, Fri Jul 8 16:26:09 2011 UTC revision 1568 by torben, Sat Jul 9 07:26:15 2011 UTC
# Line 51  public class OfflineStationProvider impl Line 51  public class OfflineStationProvider impl
51                  stations = serializer.read(StationBean.class,  new String(data, "ISO-8859-1") );*/                  stations = serializer.read(StationBean.class,  new String(data, "ISO-8859-1") );*/
52                                    
53                                    
54                  try {  
55                          ObjectInputStream in = new ObjectInputStream( new FileInputStream(stationsFile) );                  ObjectInputStream in = new ObjectInputStream( new FileInputStream(stationsFile) );
56                          Object o;  
57                          StationEntry e = null;                  int length = in.readInt(); // first field is the length
58                          while ( (o=in.readObject()) != null ) {                  
59                                  e = (StationEntry) o;                  for (int i=0; i<length; i++) {                          
60                                  updateSearchStrings(e);                          StationEntry entry = (StationEntry) in.readObject();
61                                  stations.entries.add( e );                          updateSearchStrings(entry);
62                          }                          stations.entries.add( entry );
                         in.close();  
                 } catch (EOFException e) {  
                         //do nothing;  
63                  }                  }
64                                    
65                    in.close();
66    
67                    
68                  Log.e("OFFLINE", "loaded" + stations.entries.size());                  Log.e("OFFLINE", "loaded" + stations.entries.size());
69                  logElapsedTime(start, "loadStations");                  logElapsedTime(start, "loadStations");
70                                    
# Line 89  public class OfflineStationProvider impl Line 89  public class OfflineStationProvider impl
89                  ObjectOutputStream out = new ObjectOutputStream( new FileOutputStream(stationsFile) );                  ObjectOutputStream out = new ObjectOutputStream( new FileOutputStream(stationsFile) );
90                  Log.e("OFFLINE", "data size" + data.length);                  Log.e("OFFLINE", "data size" + data.length);
91                                    
92                    out.writeInt( stations.entries.size() ); //start with writing the length of the dataset
93                    
94                  for (StationEntry entry : stations.entries) {                  for (StationEntry entry : stations.entries) {
95                          updateSearchStrings( entry ); //prepare name fields for byName search                          updateSearchStrings( entry ); //prepare name fields for byName search
96                          out.writeObject(entry);                          out.writeObject(entry);

Legend:
Removed from v.1567  
changed lines
  Added in v.1568

  ViewVC Help
Powered by ViewVC 1.1.20