mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-23 00:00:09 +08:00
Change hasReturnValue to isSynch to be more accurate about purpose of method.
This commit is contained in:
@@ -24,12 +24,12 @@ public interface Plugin {
|
||||
PluginResult execute(String action, JSONArray args);
|
||||
|
||||
/**
|
||||
* Identifies if action to be executed returns a value.
|
||||
* Identifies if action to be executed returns a value and should be run synchronously.
|
||||
*
|
||||
* @param action The action to execute
|
||||
* @return T=returns value
|
||||
*/
|
||||
public boolean hasReturnValue(String action);
|
||||
public boolean isSynch(String action);
|
||||
|
||||
/**
|
||||
* Sets the context of the Plugin. This can then be used to do things like
|
||||
|
||||
@@ -60,7 +60,7 @@ public final class PluginManager {
|
||||
public String exec(final String service, final String action, final String callbackId, final String jsonArgs, final boolean async) {
|
||||
System.out.println("PluginManager.exec("+service+", "+action+", "+callbackId+", "+jsonArgs+", "+async+")");
|
||||
PluginResult cr = null;
|
||||
boolean noReturnValue = async;
|
||||
boolean runAsync = async;
|
||||
try {
|
||||
final JSONArray args = new JSONArray(jsonArgs);
|
||||
String clazz = this.services.get(service);
|
||||
@@ -71,8 +71,8 @@ public final class PluginManager {
|
||||
if ((c == null) || isPhoneGapPlugin(c)) {
|
||||
final Plugin plugin = this.addPlugin(clazz);
|
||||
final DroidGap ctx = this.ctx;
|
||||
noReturnValue = async && !plugin.hasReturnValue(action);
|
||||
if (async && !plugin.hasReturnValue(action)) {
|
||||
runAsync = async && !plugin.isSynch(action);
|
||||
if (async && !plugin.isSynch(action)) {
|
||||
// Run this on a different thread so that this one can return back to JS
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
@@ -100,7 +100,7 @@ public final class PluginManager {
|
||||
cr = new PluginResult(PluginResult.Status.JSON_EXCEPTION);
|
||||
}
|
||||
// if async we have already returned at this point unless there was an error...
|
||||
if (noReturnValue) {
|
||||
if (runAsync) {
|
||||
ctx.sendJavascript(cr.toErrorCallbackString(callbackId));
|
||||
}
|
||||
if (cr != null) {
|
||||
|
||||
Reference in New Issue
Block a user