mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 03:53:09 +08:00
Fixing bug found by tiny hippos
This commit is contained in:
parent
1b8ab156df
commit
726f1094d9
@ -106,20 +106,23 @@ public class ContactAccessorSdk3_4 extends ContactAccessor {
|
|||||||
String searchTerm = "";
|
String searchTerm = "";
|
||||||
int limit = 1;
|
int limit = 1;
|
||||||
boolean multiple = false;
|
boolean multiple = false;
|
||||||
try {
|
|
||||||
searchTerm = options.getString("filter");
|
if (options != null) {
|
||||||
|
searchTerm = options.optString("filter");
|
||||||
if (searchTerm.length()==0) {
|
if (searchTerm.length()==0) {
|
||||||
searchTerm = "%";
|
searchTerm = "%";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
searchTerm = "%" + searchTerm + "%";
|
searchTerm = "%" + searchTerm + "%";
|
||||||
}
|
}
|
||||||
multiple = options.getBoolean("multiple");
|
multiple = options.optBoolean("multiple");
|
||||||
if (multiple) {
|
if (multiple) {
|
||||||
limit = options.getInt("limit");
|
limit = options.optInt("limit");
|
||||||
|
limit = limit > 0 ? limit : 1;
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
}
|
||||||
Log.e(LOG_TAG, e.getMessage(), e);
|
else {
|
||||||
|
searchTerm = "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
ContentResolver cr = mApp.getContentResolver();
|
ContentResolver cr = mApp.getContentResolver();
|
||||||
|
@ -158,20 +158,23 @@ public class ContactAccessorSdk5 extends ContactAccessor {
|
|||||||
String searchTerm = "";
|
String searchTerm = "";
|
||||||
int limit = 1;
|
int limit = 1;
|
||||||
boolean multiple = false;
|
boolean multiple = false;
|
||||||
try {
|
|
||||||
searchTerm = options.getString("filter");
|
if (options != null) {
|
||||||
|
searchTerm = options.optString("filter");
|
||||||
if (searchTerm.length()==0) {
|
if (searchTerm.length()==0) {
|
||||||
searchTerm = "%";
|
searchTerm = "%";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
searchTerm = "%" + searchTerm + "%";
|
searchTerm = "%" + searchTerm + "%";
|
||||||
}
|
}
|
||||||
multiple = options.getBoolean("multiple");
|
multiple = options.optBoolean("multiple");
|
||||||
if (multiple) {
|
if (multiple) {
|
||||||
limit = options.getInt("limit");
|
limit = options.optInt("limit");
|
||||||
|
limit = limit > 0 ? limit : 1;
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
}
|
||||||
Log.e(LOG_TAG, e.getMessage(), e);
|
else {
|
||||||
|
searchTerm = "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
//Log.d(LOG_TAG, "Search Term = " + searchTerm);
|
//Log.d(LOG_TAG, "Search Term = " + searchTerm);
|
||||||
@ -339,9 +342,11 @@ public class ContactAccessorSdk5 extends ContactAccessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Push the last contact into the contacts array
|
// Push the last contact into the contacts array
|
||||||
|
if (contacts.length() < limit) {
|
||||||
contacts.put(populateContact(contact, organizations, addresses, phones,
|
contacts.put(populateContact(contact, organizations, addresses, phones,
|
||||||
emails, ims, websites, relationships, photos));
|
emails, ims, websites, relationships, photos));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
c.close();
|
c.close();
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public class ContactManager extends Plugin {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (action.equals("search")) {
|
if (action.equals("search")) {
|
||||||
JSONArray res = contactAccessor.search(args.getJSONArray(0), args.getJSONObject(1));
|
JSONArray res = contactAccessor.search(args.getJSONArray(0), args.optJSONObject(1));
|
||||||
return new PluginResult(status, res, "navigator.service.contacts.cast");
|
return new PluginResult(status, res, "navigator.service.contacts.cast");
|
||||||
}
|
}
|
||||||
else if (action.equals("save")) {
|
else if (action.equals("save")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user