--- android/TrainInfo/src/dk/thoerup/traininfo/StationLocator.java 2009/08/28 07:58:50 288 +++ android/TrainInfo/src/dk/thoerup/traininfo/LocationLookup.java 2009/09/11 12:24:53 319 @@ -10,29 +10,22 @@ import android.os.Bundle; import android.os.Handler; import android.util.Log; -import dk.thoerup.traininfo.provider.ProviderFactory; -import dk.thoerup.traininfo.provider.StationProvider; -public class StationLocator implements LocationListener{ + +public class LocationLookup implements LocationListener{ LocationManager locManager; Context cntx; Handler hndl; - StationProvider provider; Location savedLocation = null; boolean hasGps; - public StationLocator(Context c, Handler h) { + public LocationLookup(Context c, Handler h) { cntx = c; hndl = h; - provider = ProviderFactory.getStationProvider(); - } - - public List getStations() { - return provider.getStations(); } public void abortLocationListener() { @@ -42,6 +35,11 @@ public boolean hasLocation() { return savedLocation != null; } + + public Location getLocation() + { + return savedLocation; + } public void locateStations() { hasGps = false; @@ -80,11 +78,8 @@ locManager.removeUpdates(this); hndl.sendEmptyMessage(TrainInfoList.GOTLOCATION); } - - public void findNearestStations() { - findNearestStations(savedLocation); - } - + /* + public void findNearestStations(Location location) { provider.lookupStations(location); @@ -92,7 +87,7 @@ hndl.sendEmptyMessage(TrainInfoList.GOTSTATIONLIST); else hndl.sendEmptyMessage(TrainInfoList.LOOKUPSTATIONFAILED); - } + }*/ @Override @@ -129,11 +124,17 @@ hillerod.setLatitude(55.929177); hillerod.setLongitude(12.308095); + Location aarhus = new Location("gps"); //Aros + aarhus.setLatitude(56.153828); + aarhus.setLongitude(10.200369); + + + LocationManager lm = (LocationManager) cntx.getSystemService(Context.LOCATION_SERVICE); if (lm.getProvider("gps2") == null) lm.addTestProvider("gps2", false, true, true, false, false, false, false, 0, Criteria.ACCURACY_FINE ); lm.setTestProviderEnabled("gps2", true); - lm.setTestProviderLocation("gps2", hillerod); + lm.setTestProviderLocation("gps2", kbh); } public static void removeMockLocation(Context cntx) {