Search in sources :

Example 6 with CordovaPlugin

use of org.apache.cordova.CordovaPlugin in project phonegap-facebook-plugin by Wizcorp.

the class PluginManager method execHelper.

private void execHelper(final String service, final String action, final String callbackId, final String rawArgs) {
    CordovaPlugin plugin = getPlugin(service);
    if (plugin == null) {
        Log.d(TAG, "exec() call to unknown plugin: " + service);
        PluginResult cr = new PluginResult(PluginResult.Status.CLASS_NOT_FOUND_EXCEPTION);
        app.sendPluginResult(cr, callbackId);
        return;
    }
    try {
        CallbackContext callbackContext = new CallbackContext(callbackId, app);
        long pluginStartTime = System.currentTimeMillis();
        boolean wasValidAction = plugin.execute(action, rawArgs, callbackContext);
        long duration = System.currentTimeMillis() - pluginStartTime;
        if (duration > SLOW_EXEC_WARNING_THRESHOLD) {
            Log.w(TAG, "THREAD WARNING: exec() call to " + service + "." + action + " blocked the main thread for " + duration + "ms. Plugin should use CordovaInterface.getThreadPool().");
        }
        if (!wasValidAction) {
            PluginResult cr = new PluginResult(PluginResult.Status.INVALID_ACTION);
            app.sendPluginResult(cr, callbackId);
        }
    } catch (JSONException e) {
        PluginResult cr = new PluginResult(PluginResult.Status.JSON_EXCEPTION);
        app.sendPluginResult(cr, callbackId);
    }
}
Also used : PluginResult(org.apache.cordova.PluginResult) CordovaPlugin(org.apache.cordova.CordovaPlugin) CallbackContext(org.apache.cordova.CallbackContext) JSONException(org.json.JSONException)

Aggregations

CordovaPlugin (org.apache.cordova.CordovaPlugin)6 Intent (android.content.Intent)2 Uri (android.net.Uri)2 CallbackContext (org.apache.cordova.CallbackContext)1 PluginEntry (org.apache.cordova.PluginEntry)1 PluginResult (org.apache.cordova.PluginResult)1 JSONException (org.json.JSONException)1