List of usage examples for org.apache.cordova PluginResult setKeepCallback
public void setKeepCallback(boolean b)
From source file:com.plugin.gallery.ForegroundGalleryLauncher.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 id used when calling back into JavaScript. * @return A PluginResult object with a status and message. *//*from w w w .ja va2s .c om*/ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { this.callbackContext = callbackContext; this.targetHeight = 0; this.targetWidth = 0; this.mQuality = 80; System.out.println("IN"); JSONObject options = args.optJSONObject(0); try { if (options != null) { this.targetHeight = options.getInt("targetHeight"); this.targetWidth = options.getInt("targetWidth"); this.mQuality = options.getInt("quality"); } } catch (Exception e) { System.out.println("Exception"); e.printStackTrace(); } this.getImage(); PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT); r.setKeepCallback(true); callbackContext.sendPluginResult(r); return true; }
From source file:com.plugin.gcm.GameThrivePush.java
License:Apache License
private static void callbackSuccess(CallbackContext callbackContext, JSONObject jsonObject) { PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, jsonObject); pluginResult.setKeepCallback(true); callbackContext.sendPluginResult(pluginResult); }
From source file:com.plugin.gcm.GameThrivePush.java
License:Apache License
private static void callbackError(CallbackContext callbackContext, String str) { PluginResult pluginResult = new PluginResult(PluginResult.Status.ERROR, str); pluginResult.setKeepCallback(true); callbackContext.sendPluginResult(pluginResult); }
From source file:com.plugin.gcm.OneSignalPush.java
License:Open Source License
private static void callbackError(CallbackContext callbackContext, JSONObject jsonObject) { PluginResult pluginResult = new PluginResult(PluginResult.Status.ERROR, jsonObject); pluginResult.setKeepCallback(true); callbackContext.sendPluginResult(pluginResult); }
From source file:com.polyvi.xface.ams.XAppInstallListener.java
License:Open Source License
@Override public void onProgressUpdated(AMS_OPERATION_TYPE type, InstallStatus progressState) { JSONObject jsonObj = new JSONObject(); try {//from w w w .j a v a 2s .c o m jsonObj.put(TAG_INSTALL_PROGRESS, progressState.ordinal()); jsonObj.put(TAG_OPERATION_TYPE, type.ordinal()); jsonObj.put(TAG_CALLBACK, "progress"); } catch (JSONException e) { e.printStackTrace(); } PluginResult result = new PluginResult(PluginResult.Status.OK, jsonObj); // js???js result.setKeepCallback(true); mCallbackCtx.sendPluginResult(result); }
From source file:com.polyvi.xface.extension.advancedfiletransfer.FileDownloader.java
License:Open Source License
@Override public void onProgressUpdated(int completeSize, long totalSize) { mDownloadInfo.setCompleteSize(completeSize); JSONObject jsonObj = new JSONObject(); try {//from w ww . j a v a 2 s.com File file = new File(mLocalFilePath); FileUtils filePlugin = (FileUtils) mWebView.pluginManager.getPlugin("File"); if (filePlugin != null) { jsonObj = filePlugin.getEntryForFile(file); jsonObj.put("loaded", completeSize); jsonObj.put("total", totalSize); jsonObj.put("status", "unfinished"); } } catch (JSONException e) { XLog.e(CLASS_NAME, e.getMessage()); } PluginResult result = new PluginResult(PluginResult.Status.OK, jsonObj); result.setKeepCallback(true); mCallbackCtx.sendPluginResult(result); }
From source file:com.polyvi.xface.extension.advancedfiletransfer.FileUploader.java
License:Open Source License
@Override public void onProgressUpdated(int completeSize, long totalSize) { JSONObject jsonObj = new JSONObject(); try {/*from w ww. j a v a2s .c om*/ jsonObj.put("loaded", completeSize); jsonObj.put("total", totalSize); } catch (JSONException e) { XLog.e(CLASS_NAME, e.getMessage()); } PluginResult result = new PluginResult(PluginResult.Status.OK, jsonObj); result.setKeepCallback(true); mCallbackCtx.sendPluginResult(result); }
From source file:com.polyvi.xface.extension.bluetooth.XBluetoothExt.java
License:Open Source License
/** * ??/*w w w .j a v a2 s . c o m*/ * * @return */ private PluginResult discoverDevice() { if (mIsDiscovering == true) { return new PluginResult(PluginResult.Status.NO_RESULT); } mFoundDevices.clear(); mIsDiscovering = true; if (mBtadapter.isDiscovering()) { mBtadapter.cancelDiscovery(); } mBtadapter.startDiscovery(); PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT); result.setKeepCallback(true); return result; }
From source file:com.polyvi.xface.extension.calendar.XCalendarExt.java
License:Open Source License
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { Calendar calendar = Calendar.getInstance(); mCallbackContext = callbackContext;/* w w w. ja v a 2s .com*/ if (COMMAND_GET_TIME.equals(action)) { // ??? int hours = calendar.get(Calendar.HOUR_OF_DAY); int minutes = calendar.get(Calendar.MINUTE); if (2 == args.length()) { hours = args.getInt(0); minutes = args.getInt(1); } getTime(hours, minutes); } else if (COMMAND_GET_DATE.equals(action)) { // ??? int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH) + 1; int day = calendar.get(Calendar.DAY_OF_MONTH); if (3 == args.length()) { year = args.getInt(0); month = args.getInt(1); day = args.getInt(2); } getDate(year, month, day); } PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT); result.setKeepCallback(true); callbackContext.sendPluginResult(result); return true; }
From source file:com.polyvi.xface.extension.messaging.XMessagingExt.java
License:Open Source License
/** * ??//from w w w .j av a 2 s. c om * * @param app * app?app??????UI? * @param addr * ? * @param body * ? * @return ? */ private void sendSMS(String addr, String body) { String regularExpression = "[+*#\\d]+"; if (!addr.matches(regularExpression)) { throw new IllegalArgumentException("address must be digit,*,# or +"); } IntentFilter smsSendIntentFilter = new IntentFilter(SMS_SENT); genSendSMSBroadreceiver(); // ?? mContext.registerReceiver(mSendSMSBroadcastReceiver, smsSendIntentFilter); SmsManager manager = SmsManager.getDefault(); ArrayList<String> textList = manager.divideMessage(body); ArrayList<PendingIntent> smsSendPendingIntentList = genSMSPendingIntentList(textList); manager.sendMultipartTextMessage(addr, null, textList, smsSendPendingIntentList, null); PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT); result.setKeepCallback(true); mCallbackContext.sendPluginResult(result); }