mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-23 00:00:09 +08:00
Adding and optional call to cast Plugin Result
This commit is contained in:
@@ -242,7 +242,7 @@ var Contacts = function() {
|
||||
* @return array of Contacts matching search criteria
|
||||
*/
|
||||
Contacts.prototype.find = function(fields, successCB, errorCB, options) {
|
||||
PhoneGap.exec(successCB, errorCB, "Contacts", "search", [fields, options]);
|
||||
PhoneGap.exec(successCB, errorCB, "Contacts", "search", [fields, options], navigator.service.contacts.cast);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -262,6 +262,22 @@ Contacts.prototype.create = function(properties) {
|
||||
return contact;
|
||||
};
|
||||
|
||||
/**
|
||||
* This function returns and array of contacts. It is required as we need to convert raw
|
||||
* JSON objects into concrete Contact objects. Currently this method is called after
|
||||
* navigator.service.contacts.find but before the find methods success call back.
|
||||
*
|
||||
* @param jsonArray an array of JSON Objects that need to be converted to Contact objects.
|
||||
* @returns an array of Contact objects
|
||||
*/
|
||||
Contacts.prototype.cast = function(jsonArray) {
|
||||
var contacts = new Array();
|
||||
for (var i=0; i<jsonArray.length; i++) {
|
||||
contacts.push(navigator.service.contacts.create(jsonArray[i]));
|
||||
}
|
||||
return contacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* ContactFindOptions.
|
||||
* @param filter used to match contacts against
|
||||
|
||||
Reference in New Issue
Block a user