From 6a5cddd9076f20eb526c88d0454525b217752ed8 Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Mon, 15 Oct 2012 14:49:47 -0400 Subject: [PATCH] Remove use of PluginResult.Status.NO_RESULT in GeoBroker. It resolves to a no-op when KEEP_CALLBACK is set, and is therefore confusing to use it with the new CordovaPlugin setup. --- framework/src/org/apache/cordova/GeoBroker.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/framework/src/org/apache/cordova/GeoBroker.java b/framework/src/org/apache/cordova/GeoBroker.java index 5377e365..86aa6283 100755 --- a/framework/src/org/apache/cordova/GeoBroker.java +++ b/framework/src/org/apache/cordova/GeoBroker.java @@ -61,22 +61,17 @@ public class GeoBroker extends CordovaPlugin { this.gpsListener = new GPSListener(this.locationManager, this); } - PluginResult.Status status = PluginResult.Status.NO_RESULT; - String message = "Location API is not available for this device."; - PluginResult result = new PluginResult(status, message); - if ( locationManager.isProviderEnabled( LocationManager.GPS_PROVIDER ) || locationManager.isProviderEnabled( LocationManager.NETWORK_PROVIDER )) { - result.setKeepCallback(true); - if (action.equals("getLocation")) { boolean enableHighAccuracy = args.getBoolean(0); int maximumAge = args.getInt(1); Location last = this.locationManager.getLastKnownLocation((enableHighAccuracy ? LocationManager.GPS_PROVIDER : LocationManager.NETWORK_PROVIDER)); // Check if we can use lastKnownLocation to get a quick reading and use less battery if (last != null && (System.currentTimeMillis() - last.getTime()) <= maximumAge) { - result = new PluginResult(PluginResult.Status.OK, this.returnLocationJSON(last)); + PluginResult result = new PluginResult(PluginResult.Status.OK, this.returnLocationJSON(last)); + callbackContext.sendPluginResult(result); } else { this.getCurrentLocation(callbackContext, enableHighAccuracy); } @@ -93,10 +88,13 @@ public class GeoBroker extends CordovaPlugin { else { return false; } + } else { + PluginResult.Status status = PluginResult.Status.NO_RESULT; + String message = "Location API is not available for this device."; + PluginResult result = new PluginResult(status, message); + callbackContext.sendPluginResult(result); } - callbackContext.sendPluginResult(result); return true; - } private void clearWatch(String id) {