當前位置: 首頁>>代碼示例>>Java>>正文


Java CordovaArgs類代碼示例

本文整理匯總了Java中org.apache.cordova.CordovaArgs的典型用法代碼示例。如果您正苦於以下問題:Java CordovaArgs類的具體用法?Java CordovaArgs怎麽用?Java CordovaArgs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CordovaArgs類屬於org.apache.cordova包,在下文中一共展示了CordovaArgs類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: clear

import org.apache.cordova.CordovaArgs; //導入依賴的package包/類
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");
            }
        }
    });
}
 
開發者ID:ZachMoreno,項目名稱:krakn,代碼行數:17,代碼來源:ChromeStorage.java

示例2: execute

import org.apache.cordova.CordovaArgs; //導入依賴的package包/類
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;
}
 
開發者ID:luocongqiu,項目名稱:cordova-plugin-navigation,代碼行數:20,代碼來源:NavigationPlugin.java

示例3: execute

import org.apache.cordova.CordovaArgs; //導入依賴的package包/類
@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;
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:24,代碼來源:HotCodePushPlugin.java

示例4: jsFetchUpdate

import org.apache.cordova.CordovaArgs; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:21,代碼來源:HotCodePushPlugin.java

示例5: jsSetPluginOptions

import org.apache.cordova.CordovaArgs; //導入依賴的package包/類
/**
 * 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();
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:24,代碼來源:HotCodePushPlugin.java

示例6: jsRequestAppUpdate

import org.apache.cordova.CordovaArgs; //導入依賴的package包/類
/**
 * 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();
}
 
開發者ID:SUTFutureCoder,項目名稱:localcloud_fe,代碼行數:28,代碼來源:HotCodePushPlugin.java

示例7: execute

import org.apache.cordova.CordovaArgs; //導入依賴的package包/類
@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;
}
 
開發者ID:MobileChromeApps,項目名稱:cordova-plugin-background-app,代碼行數:18,代碼來源:BackgroundPlugin.java

示例8: listenUsingRfcomm

import org.apache.cordova.CordovaArgs; //導入依賴的package包/類
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);
}
 
開發者ID:MobileChromeApps,項目名稱:cordova-plugin-chrome-apps-bluetoothSocket,代碼行數:17,代碼來源:ChromeBluetoothSocket.java

示例9: execRestartApplication

import org.apache.cordova.CordovaArgs; //導入依賴的package包/類
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;
}
 
開發者ID:Thinkmill,項目名稱:reacteu-app,代碼行數:26,代碼來源:CodePush.java

示例10: connect

import org.apache.cordova.CordovaArgs; //導入依賴的package包/類
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);
    }
}
 
開發者ID:GinoLlerena,項目名稱:DemoArduinoAndroidCordovaBT,代碼行數:17,代碼來源:BluetoothSerial.java

示例11: consume

import org.apache.cordova.CordovaArgs; //導入依賴的package包/類
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));
			}
		}
	});			
}
 
開發者ID:ludei,項目名稱:atomic-plugins-inapps,代碼行數:23,代碼來源:InAppServicePlugin.java

示例12: setPaused

import org.apache.cordova.CordovaArgs; //導入依賴的package包/類
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();
}
 
開發者ID:MobileChromeApps,項目名稱:cordova-plugin-chrome-apps-bluetoothSocket,代碼行數:17,代碼來源:ChromeBluetoothSocket.java

示例13: setValidationHandler

import org.apache.cordova.CordovaArgs; //導入依賴的package包/類
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);
		}
	});
}
 
開發者ID:ludei,項目名稱:atomic-plugins-inapps,代碼行數:24,代碼來源:InAppServicePlugin.java

示例14: writeCharacteristicValue

import org.apache.cordova.CordovaArgs; //導入依賴的package包/類
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);
      }
    });
}
 
開發者ID:MobileChromeApps,項目名稱:cordova-plugin-chrome-apps-bluetoothLowEnergy,代碼行數:21,代碼來源:ChromeBluetoothLowEnergy.java

示例15: stopCharacteristicNotifications

import org.apache.cordova.CordovaArgs; //導入依賴的package包/類
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);
      }
    });
}
 
開發者ID:MobileChromeApps,項目名稱:cordova-plugin-chrome-apps-bluetoothLowEnergy,代碼行數:20,代碼來源:ChromeBluetoothLowEnergy.java


注:本文中的org.apache.cordova.CordovaArgs類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。