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 WebView mAppView;
|
||||||
private Context mCtx;
|
private Context mCtx;
|
||||||
private HashMap<String, GeoListener> geoListeners;
|
private HashMap<String, GeoListener> geoListeners;
|
||||||
|
private GeoListener listener;
|
||||||
|
|
||||||
public GeoBroker(WebView view, Context ctx)
|
public GeoBroker(WebView view, Context ctx)
|
||||||
{
|
{
|
||||||
@ -24,7 +25,8 @@ public class GeoBroker {
|
|||||||
|
|
||||||
public void getCurrentLocation()
|
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)
|
public String start(int freq, String key)
|
||||||
|
@ -35,6 +35,7 @@ public class GpsListener implements LocationListener {
|
|||||||
private LocationManager mLocMan;
|
private LocationManager mLocMan;
|
||||||
private static final String LOG_TAG = "PhoneGap";
|
private static final String LOG_TAG = "PhoneGap";
|
||||||
private GeoListener owner;
|
private GeoListener owner;
|
||||||
|
private boolean hasData = false;
|
||||||
|
|
||||||
public GpsListener(Context ctx, int interval, GeoListener m)
|
public GpsListener(Context ctx, int interval, GeoListener m)
|
||||||
{
|
{
|
||||||
@ -48,6 +49,7 @@ public class GpsListener implements LocationListener {
|
|||||||
public Location getLocation()
|
public Location getLocation()
|
||||||
{
|
{
|
||||||
cLoc = mLocMan.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
cLoc = mLocMan.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||||
|
hasData = true;
|
||||||
return cLoc;
|
return cLoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +90,7 @@ public class GpsListener implements LocationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasLocation() {
|
public boolean hasLocation() {
|
||||||
return (cLoc != null);
|
return hasData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop()
|
public void stop()
|
||||||
|
Loading…
Reference in New Issue
Block a user