You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/08/15 00:36:20 UTC

[8/8] git commit: [CB-4521] Fix geolocation not working after a page change.

[CB-4521] Fix geolocation not working after a page change.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/commit/894b96e6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/894b96e6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/894b96e6

Branch: refs/heads/dev
Commit: 894b96e679359c5aacacbe6e892cd2ea85163988
Parents: 2cc2a57
Author: Andrew Grieve <ag...@chromium.org>
Authored: Tue Aug 13 11:55:18 2013 -0400
Committer: Steven Gill <st...@gmail.com>
Committed: Wed Aug 14 15:36:09 2013 -0700

----------------------------------------------------------------------
 src/android/GeoBroker.java | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/894b96e6/src/android/GeoBroker.java
----------------------------------------------------------------------
diff --git a/src/android/GeoBroker.java b/src/android/GeoBroker.java
index 38603df..ea0ad1c 100755
--- a/src/android/GeoBroker.java
+++ b/src/android/GeoBroker.java
@@ -41,12 +41,6 @@ public class GeoBroker extends CordovaPlugin {
     private LocationManager locationManager;    
 
     /**
-     * Constructor.
-     */
-    public GeoBroker() {
-    }
-
-    /**
      * Executes the request and returns PluginResult.
      *
      * @param action 		The action to execute.
@@ -55,14 +49,18 @@ public class GeoBroker extends CordovaPlugin {
      * @return 			True if the action was valid, or false if not.
      */
     public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
-        if (this.locationManager == null) {
-            this.locationManager = (LocationManager) this.cordova.getActivity().getSystemService(Context.LOCATION_SERVICE);
-            this.networkListener = new NetworkListener(this.locationManager, this);
-            this.gpsListener = new GPSListener(this.locationManager, this);
+        if (locationManager == null) {
+            locationManager = (LocationManager) this.cordova.getActivity().getSystemService(Context.LOCATION_SERVICE);
         }
-
         if ( locationManager.isProviderEnabled( LocationManager.GPS_PROVIDER ) ||
                 locationManager.isProviderEnabled( LocationManager.NETWORK_PROVIDER )) {
+            if (networkListener == null) {
+                networkListener = new NetworkListener(locationManager, this);
+            }
+            if (gpsListener == null) {
+                gpsListener = new GPSListener(locationManager, this);
+            }
+
 
             if (action.equals("getLocation")) {
                 boolean enableHighAccuracy = args.getBoolean(0);