forked from github/cordova-android
Fixing Geolocation so it grabs data from the network faster
This commit is contained in:
parent
3898130a30
commit
9276729be5
@ -15,6 +15,7 @@ public class GeoBroker {
|
||||
private WebView mAppView;
|
||||
private Context mCtx;
|
||||
private HashMap<String, GeoListener> geoListeners;
|
||||
private GeoListener listener;
|
||||
|
||||
public GeoBroker(WebView view, Context ctx)
|
||||
{
|
||||
@ -23,8 +24,9 @@ public class GeoBroker {
|
||||
}
|
||||
|
||||
public void getCurrentLocation()
|
||||
{
|
||||
GeoListener listener = new GeoListener("global", mCtx, 10000, mAppView);
|
||||
{
|
||||
if (listener == null)
|
||||
listener = new GeoListener("global", mCtx, 10000, mAppView);
|
||||
}
|
||||
|
||||
public String start(int freq, String key)
|
||||
|
@ -35,6 +35,7 @@ public class GpsListener implements LocationListener {
|
||||
private LocationManager mLocMan;
|
||||
private static final String LOG_TAG = "PhoneGap";
|
||||
private GeoListener owner;
|
||||
private boolean hasData = false;
|
||||
|
||||
public GpsListener(Context ctx, int interval, GeoListener m)
|
||||
{
|
||||
@ -48,6 +49,7 @@ public class GpsListener implements LocationListener {
|
||||
public Location getLocation()
|
||||
{
|
||||
cLoc = mLocMan.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||
hasData = true;
|
||||
return cLoc;
|
||||
}
|
||||
|
||||
@ -88,7 +90,7 @@ public class GpsListener implements LocationListener {
|
||||
}
|
||||
|
||||
public boolean hasLocation() {
|
||||
return (cLoc != null);
|
||||
return hasData;
|
||||
}
|
||||
|
||||
public void stop()
|
||||
|
@ -47,7 +47,7 @@ public class NetworkListener implements LocationListener {
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
cLoc = mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
|
||||
cLoc = mLocMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
|
||||
return cLoc;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user