mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 00:32:55 +08:00
Added CallbackContext success message with an int parameter
Added a small utility function to convert JSONArray to List<String>
This commit is contained in:
parent
62421ee49d
commit
c668eeba0f
24
framework/src/org/apache/cordova/JSONUtils.java
Normal file
24
framework/src/org/apache/cordova/JSONUtils.java
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package org.apache.cordova;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
|
||||||
|
public class JSONUtils {
|
||||||
|
public static List<String> toStringList(JSONArray array) throws JSONException {
|
||||||
|
if(array == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
List<String> list = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (int i = 0; i < array.length(); i++) {
|
||||||
|
list.add(array.get(i).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -79,6 +79,15 @@ public class CallbackContext {
|
|||||||
public void success(byte[] message) {
|
public void success(byte[] message) {
|
||||||
sendPluginResult(new PluginResult(PluginResult.Status.OK, message));
|
sendPluginResult(new PluginResult(PluginResult.Status.OK, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper for success callbacks that just returns the Status.OK by default
|
||||||
|
*
|
||||||
|
* @param message The message to add to the success result.
|
||||||
|
*/
|
||||||
|
public void success(int message) {
|
||||||
|
sendPluginResult(new PluginResult(PluginResult.Status.OK, message));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper for success callbacks that just returns the Status.OK by default
|
* Helper for success callbacks that just returns the Status.OK by default
|
||||||
|
Loading…
Reference in New Issue
Block a user