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

Diff of /android/TrainInfo/src/dk/thoerup/traininfo/LocationLookup.java

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

revision 487 by torben, Tue Oct 27 13:40:15 2009 UTC revision 488 by torben, Thu Oct 29 13:42:57 2009 UTC
# Line 17  public class LocationLookup implements L Line 17  public class LocationLookup implements L
17          Context cntx;          Context cntx;
18          Handler hndl;          Handler hndl;
19    
20            Location lastKnownLocation = null;
21          Location savedLocation = null;          Location savedLocation = null;
22                    
23          boolean isSearching = false;          boolean isSearching = false;
# Line 36  public class LocationLookup implements L Line 37  public class LocationLookup implements L
37          {          {
38                  return savedLocation;                  return savedLocation;
39          }          }
40            
41            public Location getLastKnownLocation() {
42                    return lastKnownLocation;
43            }
44    
45          public void locateStations() {          public void locateStations() {
46                                    
# Line 52  public class LocationLookup implements L Line 57  public class LocationLookup implements L
57                                  if (provider.equalsIgnoreCase("gps"))                                  if (provider.equalsIgnoreCase("gps"))
58                                          hasGps = true;                                          hasGps = true;
59                                  locManager.requestLocationUpdates(provider, 0, 0, this);                                  locManager.requestLocationUpdates(provider, 0, 0, this);
60                                    
61                                    saveLastKnownLocation(locManager.getLastKnownLocation(provider));
62                          }                          }
63                  } else {                  } else {
64                          // message that no suitable provider was found                          // message that no suitable provider was found
# Line 81  public class LocationLookup implements L Line 88  public class LocationLookup implements L
88                  hndl.sendEmptyMessage(StationList.GOTLOCATION);                  hndl.sendEmptyMessage(StationList.GOTLOCATION);
89          }          }
90                    
91            private void saveLastKnownLocation(Location loc) {
92                    if (lastKnownLocation == null) {
93                            lastKnownLocation = loc;
94                    } else {
95                            if (loc.getTime() > lastKnownLocation.getTime()) {//if loc is more recent than saved
96                                    lastKnownLocation = loc;
97                            }
98                    }
99            }
100            
101          public void stopSearch()          public void stopSearch()
102          {          {
103                  if (isSearching) {                  if (isSearching) {

Legend:
Removed from v.487  
changed lines
  Added in v.488

  ViewVC Help
Powered by ViewVC 1.1.20