2009-11-10 09:45:02 +08:00
|
|
|
package com.phonegap;
|
2009-04-02 07:56:43 +08:00
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import android.content.Context;
|
2009-12-17 03:09:32 +08:00
|
|
|
import android.location.Location;
|
2009-04-02 07:56:43 +08:00
|
|
|
import android.webkit.WebView;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This class is the interface to the Geolocation. It's bound to the geo object.
|
|
|
|
*
|
|
|
|
* This class only starts and stops various GeoListeners, which consist of a GPS and a Network Listener
|
|
|
|
*/
|
|
|
|
|
|
|
|
public class GeoBroker {
|
|
|
|
private WebView mAppView;
|
2010-08-20 03:37:49 +08:00
|
|
|
private DroidGap mCtx;
|
2009-04-02 07:56:43 +08:00
|
|
|
private HashMap<String, GeoListener> geoListeners;
|
2010-07-07 04:37:19 +08:00
|
|
|
private GeoListener global;
|
2009-04-02 07:56:43 +08:00
|
|
|
|
2010-08-20 03:37:49 +08:00
|
|
|
public GeoBroker(WebView view, DroidGap ctx)
|
2009-04-02 07:56:43 +08:00
|
|
|
{
|
|
|
|
mCtx = ctx;
|
|
|
|
mAppView = view;
|
2010-03-16 08:01:12 +08:00
|
|
|
geoListeners = new HashMap<String, GeoListener>();
|
2009-04-02 07:56:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void getCurrentLocation()
|
2010-07-07 04:37:19 +08:00
|
|
|
{
|
|
|
|
//It's supposed to run async!
|
|
|
|
if(global == null)
|
|
|
|
global = new GeoListener("global", mCtx, 10000, mAppView);
|
|
|
|
else
|
|
|
|
global.start(10000);
|
2009-04-02 07:56:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public String start(int freq, String key)
|
|
|
|
{
|
|
|
|
GeoListener listener = new GeoListener(key, mCtx, freq, mAppView);
|
|
|
|
geoListeners.put(key, listener);
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void stop(String key)
|
|
|
|
{
|
|
|
|
GeoListener geo = geoListeners.get(key);
|
|
|
|
}
|
|
|
|
}
|