mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-23 00:00:09 +08:00
Refactor out the Java casting code
When we return JSON to the Java side it does not have the proper methods such as Contact.save() so we need to cast the JSON to the correct JS object. This used to be done from the Java layer calling the right method to cast the JSON. In this new approach the JavaScript layer will no what needs to be cast and call it's own internal function to do the cast.
This commit is contained in:
@@ -73,9 +73,17 @@ Compass.prototype.getCurrentHeading = function(successCallback, errorCallback, o
|
||||
console.log("Compass Error: errorCallback is not a function");
|
||||
return;
|
||||
}
|
||||
|
||||
var win = function(result) {
|
||||
if (result.timestamp) {
|
||||
var timestamp = new Date(result.timestamp);
|
||||
result.timestamp = timestamp;
|
||||
}
|
||||
successCallback(result);
|
||||
};
|
||||
|
||||
// Get heading
|
||||
Cordova.exec(successCallback, errorCallback, "Compass", "getHeading", []);
|
||||
Cordova.exec(win, errorCallback, "Compass", "getHeading", []);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -116,7 +124,14 @@ Compass.prototype.watchHeading= function(successCallback, errorCallback, options
|
||||
var id = Cordova.createUUID();
|
||||
navigator.compass.timers[id] = setInterval(
|
||||
function() {
|
||||
Cordova.exec(successCallback, errorCallback, "Compass", "getHeading", []);
|
||||
var win = function(result) {
|
||||
if (result.timestamp) {
|
||||
var timestamp = new Date(result.timestamp);
|
||||
result.timestamp = timestamp;
|
||||
}
|
||||
successCallback(result);
|
||||
};
|
||||
Cordova.exec(win, errorCallback, "Compass", "getHeading", []);
|
||||
}, (frequency ? frequency : 1));
|
||||
|
||||
return id;
|
||||
|
||||
Reference in New Issue
Block a user