Java 类org.apache.cordova.CordovaArgs 实例源码

项目:krakn    文件:ChromeStorage.java   
private void clear(final CordovaArgs args, final CallbackContext callbackContext) {
    cordova.getThreadPool().execute(new Runnable() {
        @Override
        public void run() {
            try {
                String namespace = args.getString(0);
                JSONObject oldValues = getStorage(namespace);
                setStorage(namespace, new JSONObject());
                callbackContext.success(oldValues);
            } catch (Exception e) {
                Log.e(LOG_TAG, "Could not clear storage", e);
                callbackContext.error("Could not update storage");
            }
        }
    });
}
项目:cordova-plugin-navigation    文件:NavigationPlugin.java   
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
    if (!action.equals("navigation")) {
        return false;
    }

    this.option = NavigationOption.parseArgs(args);
    this.callbackContext = callbackContext;

    if (!hasPermisssion()) {
        PermissionHelper.requestPermissions(this, 0, permissions);
    } else {
        this.showNavigationView();
    }

    PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
    pluginResult.setKeepCallback(true);
    callbackContext.sendPluginResult(pluginResult);
    return true;
}
项目:localcloud_fe    文件:HotCodePushPlugin.java   
@Override
public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException {
    boolean cmdProcessed = true;
    if (JSAction.INIT.equals(action)) {
        jsInit(callbackContext);
    } else if (JSAction.FETCH_UPDATE.equals(action)) {
        jsFetchUpdate(callbackContext, args);
    } else if (JSAction.INSTALL_UPDATE.equals(action)) {
        jsInstallUpdate(callbackContext);
    } else if (JSAction.CONFIGURE.equals(action)) {
        jsSetPluginOptions(args, callbackContext);
    } else if (JSAction.REQUEST_APP_UPDATE.equals(action)) {
        jsRequestAppUpdate(args, callbackContext);
    } else if (JSAction.IS_UPDATE_AVAILABLE_FOR_INSTALLATION.equals(action)) {
        jsIsUpdateAvailableForInstallation(callbackContext);
    } else if (JSAction.GET_VERSION_INFO.equals(action)) {
        jsGetVersionInfo(callbackContext);
    } else {
        cmdProcessed = false;
    }

    return cmdProcessed;
}
项目:localcloud_fe    文件:HotCodePushPlugin.java   
/**
 * Check for update.
 * Method is called from JS side.
 *
 * @param callback js callback
 */
private void jsFetchUpdate(CallbackContext callback, CordovaArgs args) {
    if (!isPluginReadyForWork) {
        sendPluginNotReadyToWork(UpdateDownloadErrorEvent.EVENT_NAME, callback);
        return;
    }

    FetchUpdateOptions fetchOptions = null;
    try {
        fetchOptions = new FetchUpdateOptions(args.optJSONObject(0));
    } catch (JSONException ignored) {
    }

    fetchUpdate(callback, fetchOptions);
}
项目:localcloud_fe    文件:HotCodePushPlugin.java   
/**
 * Set plugin options. Method is called from JavaScript.
 *
 * @param arguments arguments from JavaScript
 * @param callback  callback where to send result
 */
@Deprecated
private void jsSetPluginOptions(CordovaArgs arguments, CallbackContext callback) {
    if (!isPluginReadyForWork) {
        sendPluginNotReadyToWork("", callback);
        return;
    }

    try {
        JSONObject jsonObject = (JSONObject) arguments.get(0);
        chcpXmlConfig.mergeOptionsFromJs(jsonObject);
        // TODO: store them somewhere?
    } catch (JSONException e) {
        Log.d("CHCP", "Failed to process plugin options, received from JS.", e);
    }

    callback.success();
}
项目:localcloud_fe    文件:HotCodePushPlugin.java   
/**
 * Show dialog with request to update the application through the Google Play.
 *
 * @param arguments arguments from JavaScript
 * @param callback  callback where to send result
 */
private void jsRequestAppUpdate(final CordovaArgs arguments, final CallbackContext callback) {
    if (!isPluginReadyForWork) {
        sendPluginNotReadyToWork("", callback);
        return;
    }

    String msg = null;
    try {
        msg = (String) arguments.get(0);
    } catch (JSONException e) {
        Log.d("CHCP", "Dialog message is not set", e);
    }

    if (TextUtils.isEmpty(msg)) {
        return;
    }

    final String storeURL = appConfigStorage.loadFromFolder(fileStructure.getWwwFolder()).getStoreUrl();

    new AppUpdateRequestDialog(cordova.getActivity(), msg, storeURL, callback).show();
}
项目:localcloud_fe    文件:HotCodePushPlugin.java   
@Override
public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException {
    boolean cmdProcessed = true;
    if (JSAction.INIT.equals(action)) {
        jsInit(callbackContext);
    } else if (JSAction.FETCH_UPDATE.equals(action)) {
        jsFetchUpdate(callbackContext, args);
    } else if (JSAction.INSTALL_UPDATE.equals(action)) {
        jsInstallUpdate(callbackContext);
    } else if (JSAction.CONFIGURE.equals(action)) {
        jsSetPluginOptions(args, callbackContext);
    } else if (JSAction.REQUEST_APP_UPDATE.equals(action)) {
        jsRequestAppUpdate(args, callbackContext);
    } else if (JSAction.IS_UPDATE_AVAILABLE_FOR_INSTALLATION.equals(action)) {
        jsIsUpdateAvailableForInstallation(callbackContext);
    } else if (JSAction.GET_VERSION_INFO.equals(action)) {
        jsGetVersionInfo(callbackContext);
    } else {
        cmdProcessed = false;
    }

    return cmdProcessed;
}
项目:localcloud_fe    文件:HotCodePushPlugin.java   
/**
 * Set plugin options. Method is called from JavaScript.
 *
 * @param arguments arguments from JavaScript
 * @param callback  callback where to send result
 */
@Deprecated
private void jsSetPluginOptions(CordovaArgs arguments, CallbackContext callback) {
    if (!isPluginReadyForWork) {
        sendPluginNotReadyToWork("", callback);
        return;
    }

    try {
        JSONObject jsonObject = (JSONObject) arguments.get(0);
        chcpXmlConfig.mergeOptionsFromJs(jsonObject);
        // TODO: store them somewhere?
    } catch (JSONException e) {
        Log.d("CHCP", "Failed to process plugin options, received from JS.", e);
    }

    callback.success();
}
项目:localcloud_fe    文件:HotCodePushPlugin.java   
/**
 * Show dialog with request to update the application through the Google Play.
 *
 * @param arguments arguments from JavaScript
 * @param callback  callback where to send result
 */
private void jsRequestAppUpdate(final CordovaArgs arguments, final CallbackContext callback) {
    if (!isPluginReadyForWork) {
        sendPluginNotReadyToWork("", callback);
        return;
    }

    String msg = null;
    try {
        msg = (String) arguments.get(0);
    } catch (JSONException e) {
        Log.d("CHCP", "Dialog message is not set", e);
    }

    if (TextUtils.isEmpty(msg)) {
        return;
    }

    final String storeURL = appConfigStorage.loadFromFolder(fileStructure.getWwwFolder()).getStoreUrl();

    new AppUpdateRequestDialog(cordova.getActivity(), msg, storeURL, callback).show();
}
项目:localcloud_fe    文件:HotCodePushPlugin.java   
@Override
public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException {
    boolean cmdProcessed = true;
    if (JSAction.INIT.equals(action)) {
        jsInit(callbackContext);
    } else if (JSAction.FETCH_UPDATE.equals(action)) {
        jsFetchUpdate(callbackContext, args);
    } else if (JSAction.INSTALL_UPDATE.equals(action)) {
        jsInstallUpdate(callbackContext);
    } else if (JSAction.CONFIGURE.equals(action)) {
        jsSetPluginOptions(args, callbackContext);
    } else if (JSAction.REQUEST_APP_UPDATE.equals(action)) {
        jsRequestAppUpdate(args, callbackContext);
    } else if (JSAction.IS_UPDATE_AVAILABLE_FOR_INSTALLATION.equals(action)) {
        jsIsUpdateAvailableForInstallation(callbackContext);
    } else if (JSAction.GET_VERSION_INFO.equals(action)) {
        jsGetVersionInfo(callbackContext);
    } else {
        cmdProcessed = false;
    }

    return cmdProcessed;
}
项目:localcloud_fe    文件:HotCodePushPlugin.java   
/**
 * Check for update.
 * Method is called from JS side.
 *
 * @param callback js callback
 */
private void jsFetchUpdate(CallbackContext callback, CordovaArgs args) {
    if (!isPluginReadyForWork) {
        sendPluginNotReadyToWork(UpdateDownloadErrorEvent.EVENT_NAME, callback);
        return;
    }

    FetchUpdateOptions fetchOptions = null;
    try {
        fetchOptions = new FetchUpdateOptions(args.optJSONObject(0));
    } catch (JSONException ignored) {
    }

    fetchUpdate(callback, fetchOptions);
}
项目:localcloud_fe    文件:HotCodePushPlugin.java   
/**
 * Set plugin options. Method is called from JavaScript.
 *
 * @param arguments arguments from JavaScript
 * @param callback  callback where to send result
 */
@Deprecated
private void jsSetPluginOptions(CordovaArgs arguments, CallbackContext callback) {
    if (!isPluginReadyForWork) {
        sendPluginNotReadyToWork("", callback);
        return;
    }

    try {
        JSONObject jsonObject = (JSONObject) arguments.get(0);
        chcpXmlConfig.mergeOptionsFromJs(jsonObject);
        // TODO: store them somewhere?
    } catch (JSONException e) {
        Log.d("CHCP", "Failed to process plugin options, received from JS.", e);
    }

    callback.success();
}
项目:localcloud_fe    文件:HotCodePushPlugin.java   
/**
 * Show dialog with request to update the application through the Google Play.
 *
 * @param arguments arguments from JavaScript
 * @param callback  callback where to send result
 */
private void jsRequestAppUpdate(final CordovaArgs arguments, final CallbackContext callback) {
    if (!isPluginReadyForWork) {
        sendPluginNotReadyToWork("", callback);
        return;
    }

    String msg = null;
    try {
        msg = (String) arguments.get(0);
    } catch (JSONException e) {
        Log.d("CHCP", "Dialog message is not set", e);
    }

    if (TextUtils.isEmpty(msg)) {
        return;
    }

    final String storeURL = appConfigStorage.loadFromFolder(fileStructure.getWwwFolder()).getStoreUrl();

    new AppUpdateRequestDialog(cordova.getActivity(), msg, storeURL, callback).show();
}
项目:cordova-plugin-background-app    文件:BackgroundPlugin.java   
@Override
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
    if ("messageChannel".equals(action)) {
        messageChannel = callbackContext;
        sendEventMessage("startup", BackgroundActivity.topInstance != null);
        return true;
    } else if ("show".equals(action)) {
        cordova.getThreadPool().execute(new Runnable() {
            @Override
            public void run() {
                show(callbackContext);
            }
        });
        return true;
    }
    return false;
}
项目:cordova-plugin-chrome-apps-bluetoothSocket    文件:ChromeBluetoothSocket.java   
private void listenUsingRfcomm(CordovaArgs args, final CallbackContext callbackContext)
    throws JSONException {

  int socketId = args.getInt(0);
  String uuid = args.getString(1);
  JSONObject options = args.getJSONObject(2);

  ChromeBluetoothSocketSocket socket = sockets.get(socketId);

  if (socket == null) {
    callbackContext.error("Invalid Argument");
    return;
  }

  socket.listenUsingRfcomm(uuid, options, callbackContext);
}
项目:reacteu-app    文件:CodePush.java   
private boolean execRestartApplication(CordovaArgs args, CallbackContext callbackContext) {
    try {
        /* check if we have a deployed package already */
        CodePushPackageMetadata deployedPackageMetadata = this.codePushPackageManager.getCurrentPackageMetadata();
        if (deployedPackageMetadata != null) {
            callbackContext.success();
            didStartApp = false;
            onStart();
        } else {
            final String configLaunchUrl = this.getConfigLaunchUrl();
            if (!this.pluginDestroyed) {
                callbackContext.success();
                this.cordova.getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        navigateToURL(configLaunchUrl);
                    }
                });
            }
        }
    } catch (Exception e) {
        callbackContext.error("An error occurred while restarting the application." + e.getMessage());
    }
    return true;
}
项目:DemoArduinoAndroidCordovaBT    文件:BluetoothSerial.java   
private void connect(CordovaArgs args, boolean secure, CallbackContext callbackContext) throws JSONException {
    String macAddress = args.getString(0);
    BluetoothDevice device = bluetoothAdapter.getRemoteDevice(macAddress);

    if (device != null) {
        connectCallback = callbackContext;
        bluetoothSerialService.connect(device, secure);

        PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
        result.setKeepCallback(true);
        callbackContext.sendPluginResult(result);

    } else {
        callbackContext.error("Could not connect to " + macAddress);
    }
}
项目:atomic-plugins-inapps    文件:InAppServicePlugin.java   
public void consume(CordovaArgs args, final CallbackContext ctx) {
    String productId = args.optString(0);
    if (productId == null) {
        ctx.sendPluginResult(new PluginResult(Status.ERROR, "Invalid argument"));
        return;
    }
    int quantity = args.optInt(1);
    if (quantity < 1) {
        quantity = 1;
    }
    service.consume(productId, quantity, new InAppService.ConsumeCallback() {
        @Override
        public void onComplete(int consumed, Error error) {
            if (error != null) {
                ctx.sendPluginResult(new PluginResult(Status.ERROR, errorToJSON(error)));
            }
            else {
                ctx.sendPluginResult(new PluginResult(Status.OK, consumed));
            }
        }
    });         
}
项目:cordova-plugin-chrome-apps-bluetoothSocket    文件:ChromeBluetoothSocket.java   
private void setPaused(CordovaArgs args, final CallbackContext callbackContext)
    throws JSONException {

  int socketId = args.getInt(0);
  boolean paused = args.getBoolean(1);

  ChromeBluetoothSocketSocket socket = sockets.get(socketId);

  if (socket == null) {
    callbackContext.error("Invalid Argument");
    return;
  }

  socket.setPaused(paused);
  callbackContext.success();
}
项目:atomic-plugins-inapps    文件:InAppServicePlugin.java   
public void setValidationHandler(CordovaArgs args, final CallbackContext ctx) {
    boolean noValidation = args.optBoolean(0);
    if (noValidation) {
        service.setValidationHandler(null);
        return;
    }
    service.setValidationHandler(new InAppService.ValidationHandler() {

        @Override
        public void onValidate(String receipt, String productId, ValidationCompletion completion) {

            int completionId = validationIndex++;
            validationCompletions.put(completionId, completion);
            JSONArray array = new JSONArray();
            array.put(receipt);
            array.put(productId);
            array.put(completionId);
            PluginResult result = new PluginResult(Status.OK, array);       
            result.setKeepCallback(true);
            ctx.sendPluginResult(result);
        }
    });
}
项目:cordova-plugin-chrome-apps-bluetoothLowEnergy    文件:ChromeBluetoothLowEnergy.java   
private void writeCharacteristicValue(CordovaArgs args, final CallbackContext callbackContext)
    throws JSONException {

  final String characteristicId = args.getString(0);
  String deviceAddress = getDeviceAddressFromInstanceId(characteristicId);
  final byte[] value = args.getArrayBuffer(1);

  final ChromeBluetoothLowEnergyPeripheral peripheral = getPeripheralByDeviceAddress(deviceAddress);

  if (peripheral == null) {
    callbackContext.error("Invalid Argument");
    return;
  }

  cordova.getThreadPool().execute(new Runnable() {
      public void run() {
        peripheral.writeCharacteristicValue(characteristicId, value, callbackContext);
      }
    });
}
项目:cordova-plugin-chrome-apps-bluetoothLowEnergy    文件:ChromeBluetoothLowEnergy.java   
private void stopCharacteristicNotifications(CordovaArgs args, final CallbackContext callbackContext)
    throws JSONException {

  final String characteristicId = args.getString(0);
  String deviceAddress = getDeviceAddressFromInstanceId(characteristicId);

  final ChromeBluetoothLowEnergyPeripheral peripheral = getPeripheralByDeviceAddress(deviceAddress);

  if (peripheral == null) {
    callbackContext.error("Invalid Argument");
    return;
  }

  cordova.getThreadPool().execute(new Runnable() {
      public void run() {
        peripheral.setCharacteristicNotification(characteristicId, false, callbackContext);
      }
    });
}
项目:cordova-plugin-chrome-apps-bluetoothLowEnergy    文件:ChromeBluetoothLowEnergy.java   
private void readDescriptorValue(CordovaArgs args, final CallbackContext callbackContext)
    throws JSONException {
  final String descriptorId = args.getString(0);
  String deviceAddress = getDeviceAddressFromInstanceId(descriptorId);

  final ChromeBluetoothLowEnergyPeripheral peripheral = getPeripheralByDeviceAddress(deviceAddress);

  if (peripheral == null) {
    callbackContext.error("Invalid Argument");
    return;
  }

  cordova.getThreadPool().execute(new Runnable() {
      public void run() {
        peripheral.readDescriptorValue(descriptorId, callbackContext);
      }
    });
}
项目:cordova-plugin-chrome-apps-bluetoothLowEnergy    文件:ChromeBluetoothLowEnergy.java   
private void writeDescriptorValue(CordovaArgs args, final CallbackContext callbackContext)
    throws JSONException {

  final String descriptorId = args.getString(0);
  String deviceAddress = getDeviceAddressFromInstanceId(descriptorId);
  final byte[] value = args.getArrayBuffer(1);

  final ChromeBluetoothLowEnergyPeripheral peripheral = getPeripheralByDeviceAddress(deviceAddress);

  if (peripheral == null) {
    callbackContext.error("Invalid Argument");
    return;
  }

  cordova.getThreadPool().execute(new Runnable() {
      public void run() {
        peripheral.writeDescriptorValue(descriptorId, value, callbackContext);
      }
    });
}
项目:DemoArduinoAndroidCordovaBT    文件:BluetoothSerial.java   
private void connect(CordovaArgs args, boolean secure, CallbackContext callbackContext) throws JSONException {
    String macAddress = args.getString(0);
    BluetoothDevice device = bluetoothAdapter.getRemoteDevice(macAddress);

    if (device != null) {
        connectCallback = callbackContext;
        bluetoothSerialService.connect(device, secure);

        PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
        result.setKeepCallback(true);
        callbackContext.sendPluginResult(result);

    } else {
        callbackContext.error("Could not connect to " + macAddress);
    }
}
项目:cordova-plugin-chrome-apps-usb    文件:ChromeUsb.java   
private void controlTransfer(CordovaArgs args, JSONObject params,
        final CallbackContext callbackContext) throws JSONException, UsbError {
    ConnectedDevice dev = getDevice(params);

    int direction = directionFromName(params.getString("direction"));
    int requestType = controlRequestTypeFromName(params.getString("requestType"));
    int recipient = recipientFromName(params.getString("recipient"));

    byte[] transferBuffer = getByteBufferForTransfer(args, params, UsbConstants.USB_DIR_OUT);
    byte[] receiveBuffer = getByteBufferForTransfer(args, params, UsbConstants.USB_DIR_IN);

    int ret = dev.controlTransfer(
            direction | requestType | recipient,
            params.getInt("request"),
            params.getInt("value"),
            params.getInt("index"),
            transferBuffer,
            receiveBuffer,
            params.getInt("timeout"));
    if (ret < 0) {
        throw new UsbError("Control transfer returned " + ret);
    }

    /* control transfer is bidirectional, buffer should alway be passed */
    callbackContext.success(Arrays.copyOf(receiveBuffer, receiveBuffer.length));
}
项目:krakn    文件:PluginManager.java   
@Override
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
    if ("startup".equals(action)) {
        // The onPageStarted event of CordovaWebViewClient resets the queue of messages to be returned to javascript in response
        // to exec calls. Since this event occurs on the UI thread and exec calls happen on the WebCore thread it is possible
        // that onPageStarted occurs after exec calls have started happening on a new page, which can cause the message queue
        // to be reset between the queuing of a new message and its retrieval by javascript. To avoid this from happening,
        // javascript always sends a "startup" exec upon loading a new page which causes all future exec calls to happen on the UI
        // thread (and hence after onPageStarted) until there are no more pending exec calls remaining.
        numPendingUiExecs.getAndIncrement();
        ctx.getActivity().runOnUiThread(new Runnable() {
            public void run() {
                numPendingUiExecs.getAndDecrement();
            }
        });
        return true;
    }
    return false;
}
项目:cordova-plugin-chrome-apps-sockets-tcpServer    文件:ChromeSocketsTcpServer.java   
private void setPaused(CordovaArgs args, final CallbackContext callbackContext)
    throws JSONException {
  int socketId = args.getInt(0);
  boolean paused = args.getBoolean(1);

  TcpServerSocket socket = sockets.get(Integer.valueOf(socketId));

  if (socket == null) {
    Log.e(LOG_TAG, "No socket with socketId " + socketId);
    return;
  }

  socket.setPaused(paused);

  if (paused) {
    // Accept interest will be removed when socket is acceptable on selector thread.
    callbackContext.success();
  } else {
    // All interests need to be modified in selector thread.
    addSelectorMessage(socket, SelectorMessageType.SO_ADD_ACCEPT_INTEREST, callbackContext);
  }
}
项目:krakn    文件:ChromeStorage.java   
private void clear(final CordovaArgs args, final CallbackContext callbackContext) {
    cordova.getThreadPool().execute(new Runnable() {
        @Override
        public void run() {
            try {
                String namespace = args.getString(0);
                JSONObject oldValues = getStorage(namespace);
                setStorage(namespace, new JSONObject());
                callbackContext.success(oldValues);
            } catch (Exception e) {
                Log.e(LOG_TAG, "Could not clear storage", e);
                callbackContext.error("Could not update storage");
            }
        }
    });
}
项目:posjs2    文件:PluginManager.java   
@Override
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
    if ("startup".equals(action)) {
        // The onPageStarted event of CordovaWebViewClient resets the queue of messages to be returned to javascript in response
        // to exec calls. Since this event occurs on the UI thread and exec calls happen on the WebCore thread it is possible
        // that onPageStarted occurs after exec calls have started happening on a new page, which can cause the message queue
        // to be reset between the queuing of a new message and its retrieval by javascript. To avoid this from happening,
        // javascript always sends a "startup" exec upon loading a new page which causes all future exec calls to happen on the UI
        // thread (and hence after onPageStarted) until there are no more pending exec calls remaining.
        numPendingUiExecs.getAndIncrement();
        ctx.getActivity().runOnUiThread(new Runnable() {
            public void run() {
                numPendingUiExecs.getAndDecrement();
            }
        });
        return true;
    }
    return false;
}
项目:krakn    文件:ChromeStorage.java   
@Override
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
    if ("get".equals(action)) {
        get(args, callbackContext);
        return true;
    } else if ("getBytesInUse".equals(action)) {
        getBytesInUse(args, callbackContext);
        return true;
    } else if ("set".equals(action)) {
        set(args, callbackContext);
        return true;
    } else if ("remove".equals(action)) {
        remove(args, callbackContext);
        return true;
    } else if ("clear".equals(action)) {
        clear(args, callbackContext);
        return true;
    }

    return false;
}
项目:CrossWalkAndroidStudio    文件:PluginManager.java   
@Override
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
    if ("startup".equals(action)) {
        // The onPageStarted event of CordovaWebViewClient resets the queue of messages to be returned to javascript in response
        // to exec calls. Since this event occurs on the UI thread and exec calls happen on the WebCore thread it is possible
        // that onPageStarted occurs after exec calls have started happening on a new page, which can cause the message queue
        // to be reset between the queuing of a new message and its retrieval by javascript. To avoid this from happening,
        // javascript always sends a "startup" exec upon loading a new page which causes all future exec calls to happen on the UI
        // thread (and hence after onPageStarted) until there are no more pending exec calls remaining.
        numPendingUiExecs.getAndIncrement();
        ctx.getActivity().runOnUiThread(new Runnable() {
            public void run() {
                numPendingUiExecs.getAndDecrement();
            }
        });
        return true;
    }
    return false;
}
项目:cordova-plugin-chrome-apps-sockets-tcpServer    文件:ChromeSocketsTcpServer.java   
@Override
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext)
    throws JSONException {
  if ("create".equals(action)) {
    create(args, callbackContext);
  } else if ("update".equals(action)) {
    update(args, callbackContext);
  } else if ("setPaused".equals(action)) {
    setPaused(args, callbackContext);
  } else if ("listen".equals(action)) {
    listen(args, callbackContext);
  } else if ("disconnect".equals(action)) {
    disconnect(args, callbackContext);
  } else if ("close".equals(action)) {
    close(args, callbackContext);
  } else if ("getInfo".equals(action)) {
    getInfo(args, callbackContext);
  } else if ("getSockets".equals(action)) {
    getSockets(args, callbackContext);
  } else if ("registerAcceptEvents".equals(action)) {
    registerAcceptEvents(args, callbackContext);
  } else {
    return false;
  }
  return true;
}
项目:cordova-custom-filechooser    文件:CustomFileChooser.java   
@Override
public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException {

    if (action.equals(ACTION_OPEN)) {
        chooseFile(callbackContext, args.getString(0));
        return true;
    }

    return false;
}
项目:cordova-plugin-navigation    文件:NavigationOption.java   
public static NavigationOption parseArgs(CordovaArgs args) {
    try {
        double[] startPosition = parsePosition(args.getJSONObject(0));
        double[] endPosition = parsePosition(args.getJSONObject(1));
        int type = args.getInt(2);
        return new NavigationOption(startPosition, endPosition, type);
    } catch (JSONException ignored) {
    }
    return null;
}
项目:localcloud_fe    文件:HotCodePushLocalDevPlugin.java   
@Override
public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException {
    if (!JS_INIT_COMMAND.equals(action)) {
        return false;
    }

    defaultCallback = callbackContext;
    if (updateRequested) {
        fetchUpdate();
    }

    return true;
}
项目:localcloud_fe    文件:HotCodePushLocalDevPlugin.java   
@Override
public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException {
    if (!JS_INIT_COMMAND.equals(action)) {
        return false;
    }

    defaultCallback = callbackContext;
    if (updateRequested) {
        fetchUpdate();
    }

    return true;
}
项目:localcloud_fe    文件:HotCodePushPlugin.java   
/**
 * Check for update.
 * Method is called from JS side.
 *
 * @param callback js callback
 */
private void jsFetchUpdate(CallbackContext callback, CordovaArgs args) {
    if (!isPluginReadyForWork) {
        sendPluginNotReadyToWork(UpdateDownloadErrorEvent.EVENT_NAME, callback);
        return;
    }

    FetchUpdateOptions fetchOptions = null;
    try {
        fetchOptions = new FetchUpdateOptions(args.optJSONObject(0));
    } catch (JSONException ignored) {
    }

    fetchUpdate(callback, fetchOptions);
}
项目:localcloud_fe    文件:HotCodePushLocalDevPlugin.java   
@Override
public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException {
    if (!JS_INIT_COMMAND.equals(action)) {
        return false;
    }

    defaultCallback = callbackContext;
    if (updateRequested) {
        fetchUpdate();
    }

    return true;
}
项目:Clickers    文件:StatusBar.java   
/**
 * Executes the request and returns PluginResult.
 *
 * @param action            The action to execute.
 * @param args              JSONArry of arguments for the plugin.
 * @param callbackContext   The callback id used when calling back into JavaScript.
 * @return                  True if the action was valid, false otherwise.
 */
@Override
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
    Log.v(TAG, "Executing action: " + action);
    final Activity activity = this.cordova.getActivity();
    final Window window = activity.getWindow();
    if ("_ready".equals(action)) {
        boolean statusBarVisible = (window.getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0;
        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible));
    }

    if ("show".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
        });
        return true;
    }

    if ("hide".equals(action)) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
        });
        return true;
    }

    return false;
}