incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [1/3] android commit: Remove use of PluginResult.Status.NO_RESULT in GeoBroker.
Date Mon, 15 Oct 2012 18:51:07 GMT
Updated Branches:
  refs/heads/master e562e4e7b -> 6a5cddd90


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.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/6a5cddd9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/6a5cddd9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/6a5cddd9

Branch: refs/heads/master
Commit: 6a5cddd9076f20eb526c88d0454525b217752ed8
Parents: dc50783
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Mon Oct 15 14:49:47 2012 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Mon Oct 15 14:49:47 2012 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/GeoBroker.java |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/6a5cddd9/framework/src/org/apache/cordova/GeoBroker.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/GeoBroker.java b/framework/src/org/apache/cordova/GeoBroker.java
index 5377e36..86aa628 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) {


Mime
View raw message