/[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 1627 by torben, Fri Nov 25 10:20:40 2011 UTC revision 1638 by torben, Sun Nov 27 19:44:28 2011 UTC
# Line 36  public class OfflineStationProvider impl Line 36  public class OfflineStationProvider impl
36          public boolean loadStations(Context context) throws Exception {          public boolean loadStations(Context context) throws Exception {
37                  long start = System.currentTimeMillis();                  long start = System.currentTimeMillis();
38                                    
39                  stations.entries.clear(); //TODO: remove                  StationBean tmpStations = new StationBean();
40                                    
41                  File parent = context.getFilesDir();                  File parent = context.getFilesDir();
42                  File stationsFile = new File(parent, "stations.bin");                  File stationsFile = new File(parent, "stations.bin");
# Line 62  public class OfflineStationProvider impl Line 62  public class OfflineStationProvider impl
62                  for (int i=0; i<length; i++) {                                            for (int i=0; i<length; i++) {                          
63                          StationEntry entry = (StationEntry) in.readObject();                          StationEntry entry = (StationEntry) in.readObject();
64                          updateSearchStrings(entry);                          updateSearchStrings(entry);
65                          stations.entries.add( entry );                          tmpStations.entries.add( entry );
66                  }                  }
67                                    
68                  in.close();                  in.close();
69    
70                    stations = tmpStations; // når indlæsningen er ok skifter vi over
71                                    
72                  Log.e("OFFLINE", "loaded" + stations.entries.size());                  Log.e("OFFLINE", "loaded" + tmpStations.entries.size());
73                  logElapsedTime(start, "loadStations");                  logElapsedTime(start, "loadStations");
74                                    
75                  return true;                  return true;
# Line 83  public class OfflineStationProvider impl Line 84  public class OfflineStationProvider impl
84                  File parent = context.getFilesDir();                  File parent = context.getFilesDir();
85                  File stationsFile = new File(parent, "stations.bin");                  File stationsFile = new File(parent, "stations.bin");
86    
87                                    long start = System.currentTimeMillis();
88                  byte data[] = HttpUtil.getContent(XmlUtil.SERVICE_BASE + "/LocateStations?dump=1", 5000);                  byte data[] = HttpUtil.getContent(XmlUtil.SERVICE_BASE + "/LocateStations?dump=1", 5000);
89                  Serializer serializer = new Persister();                  logElapsedTime(start, "download XML");
90                    
91                    
92                    Serializer serializer = new Persister();                
93                    
94                    start = System.currentTimeMillis();
95                  StationBean tmpStations = serializer.read(StationBean.class,  new String(data, "ISO-8859-1") );                  StationBean tmpStations = serializer.read(StationBean.class,  new String(data, "ISO-8859-1") );
96                    logElapsedTime(start, "parse XML");
97                                    
98                                    
99                  ObjectOutputStream out = new ObjectOutputStream( new FileOutputStream(stationsFile) );                  ObjectOutputStream out = new ObjectOutputStream( new FileOutputStream(stationsFile) );

Legend:
Removed from v.1627  
changed lines
  Added in v.1638

  ViewVC Help
Powered by ViewVC 1.1.20