List of usage examples for org.apache.cordova PluginResult PluginResult
public PluginResult(Status status)
From source file:com.sesamtv.cordova.chromecast.ChromeCast.java
License:MIT License
private void startListener(String type, CallbackContext callbackContext) { Log.d(TAG, "startListener for " + type); PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT); if (type.equals("session")) { onSessionCreatedCallback = callbackContext; pluginResult.setKeepCallback(true); callbackContext.sendPluginResult(pluginResult); } else if (type.equals("receivers")) { receiverCallback = callbackContext; onReceiverListChanged();/*from ww w.j a v a 2 s . c om*/ } else if (type.equals("sessionEnded")) { onEndedCallback = callbackContext; pluginResult.setKeepCallback(true); callbackContext.sendPluginResult(pluginResult); } else if (type.equals("status")) { mediaStatusCallback = callbackContext; mediaStatusCallback.sendPluginResult(getMediaStatus()); } else { callbackContext.error("LISTENER_TYPE_NOT_FOUND"); } }
From source file:com.squareup.plugin.square.Square.java
License:Apache License
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackContext The callback context from which we were invoked. *//* w ww .j a v a 2 s . c o m*/ @Override public boolean execute(String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException { PluginResult result; if (ACTION_SET_OPTIONS.equals(action)) { JSONObject options = args.optJSONObject(0); result = executeSetOptions(options, callbackContext); } else if (ACTION_REQUEST_CHARGE.equals(action)) { JSONObject options = args.optJSONObject(0); result = executeRequestCharge(options, callbackContext); } else { Log.d(LOGTAG, String.format("Invalid action passed: %s", action)); result = new PluginResult(PluginResult.Status.INVALID_ACTION); } if (result != null) callbackContext.sendPluginResult(result); return true; }
From source file:com.squareup.plugin.square.Square.java
License:Apache License
private PluginResult executeSetOptions(final JSONObject options, final CallbackContext callbackContext) { Log.w(LOGTAG, "executeSetOptions"); this.setOptions(options); return new PluginResult(PluginResult.Status.OK); }