当前位置: 首页>>代码示例>>Java>>正文


Java PluginResult类代码示例

本文整理汇总了Java中org.apache.cordova.api.PluginResult的典型用法代码示例。如果您正苦于以下问题:Java PluginResult类的具体用法?Java PluginResult怎么用?Java PluginResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PluginResult类属于org.apache.cordova.api包,在下文中一共展示了PluginResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerTagListener

import org.apache.cordova.api.PluginResult; //导入依赖的package包/类
private PluginResult registerTagListener() throws NFCException, JSONException {
    ReaderWriterManager nfc = ReaderWriterManager.getInstance();

    tagListener  = new DetectionListener() {

        public void onTargetDetected(Target target) {

            Hashtable props = Util.getTagProperties(target);

            NDEFMessage message = null;
            try {
                NDEFTagConnection tagConnection = (NDEFTagConnection) Connector.open(target.getUri(Target.NDEF_TAG));
                message = tagConnection.read();  // might want to handle NFCException different
            } catch (IOException e) {
                Logger.error("Failed reading tag " + e.toString());
            }

            fireNdefEvent(TAG_DEFAULT, message, props);

        }
    };
    nfc.addDetectionListener(tagListener);
    return new PluginResult(Status.OK);
}
 
开发者ID:theGreatWhiteShark,项目名称:mensacard-hack,代码行数:25,代码来源:NfcPlugin.java

示例2: execute

import org.apache.cordova.api.PluginResult; //导入依赖的package包/类
/**
   * 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.
   */
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

  	this.callbackContext = callbackContext;

this.targetHeight = 0;
this.targetWidth = 0;
this.mQuality = 80;

      JSONObject options = args.optJSONObject(0);
      if (options != null)
      {
          this.targetHeight = options.getInt("targetHeight");
          this.targetWidth = options.getInt("targetWidth");
          this.mQuality = options.getInt("quality");
      }

this.getImage();

PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
r.setKeepCallback(true);
callbackContext.sendPluginResult(r);
return true;
  }
 
开发者ID:AlunoTADS,项目名称:foreground-gallery-plugin,代码行数:32,代码来源:ForegroundGalleryLauncher.java

示例3: processPicture

import org.apache.cordova.api.PluginResult; //导入依赖的package包/类
public void processPicture(Bitmap bitmap)
{
    ByteArrayOutputStream jpeg_data = new ByteArrayOutputStream();
    try
    {
        if (bitmap.compress(CompressFormat.JPEG, mQuality, jpeg_data))
        {
            byte[] code = jpeg_data.toByteArray();
            byte[] output = Base64.encodeBase64(code);
            String js_out = new String(output);
            this.success(new PluginResult(PluginResult.Status.OK,
                    "data:image/jpeg;base64," + js_out), this.callbackId);
            js_out = null;
            output = null;
            code = null;
        }
    }
    catch (Exception e)
    {
        this.failPicture("Error compressing image.");
    }
    jpeg_data = null;
}
 
开发者ID:AlunoTADS,项目名称:foreground-gallery-plugin,代码行数:24,代码来源:ForegroundGalleryLauncher.java

示例4: fail

import org.apache.cordova.api.PluginResult; //导入依赖的package包/类
private void fail(int paramInt, String paramString)
{
  JSONObject localJSONObject = new JSONObject();
  try
  {
    localJSONObject.put("code", paramInt);
    localJSONObject.put("message", paramString);
    PluginResult localPluginResult = new PluginResult(PluginResult.Status.ERROR, localJSONObject);
    localPluginResult.setKeepCallback(true);
    this.callbackContext.sendPluginResult(localPluginResult);
    return;
  }
  catch (JSONException localJSONException)
  {
    while (true)
      localJSONException.printStackTrace();
  }
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:19,代码来源:AccelListener.java

示例5: execute

import org.apache.cordova.api.PluginResult; //导入依赖的package包/类
public boolean execute(String paramString, JSONArray paramJSONArray, CallbackContext paramCallbackContext)
{
  if (paramString.equals("start"))
  {
    this.callbackContext = paramCallbackContext;
    if (this.status != RUNNING)
      start();
  }
  while (true)
  {
    PluginResult localPluginResult = new PluginResult(PluginResult.Status.NO_RESULT, "");
    localPluginResult.setKeepCallback(true);
    paramCallbackContext.sendPluginResult(localPluginResult);
    return true;
    if (!paramString.equals("stop"))
      break;
    if (this.status != RUNNING)
      continue;
    stop();
  }
  return false;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:23,代码来源:AccelListener.java

示例6: addPluginResult

import org.apache.cordova.api.PluginResult; //导入依赖的package包/类
public void addPluginResult(PluginResult paramPluginResult, String paramString)
{
  if (paramString == null)
  {
    Log.e("JsMessageQueue", "Got plugin result with no callbackId", new Throwable());
    return;
  }
  if (paramPluginResult.getStatus() == PluginResult.Status.NO_RESULT.ordinal());
  for (int i = 1; ; i = 0)
  {
    boolean bool = paramPluginResult.getKeepCallback();
    if ((i != 0) && (bool))
      break;
    enqueueMessage(new JsMessage(paramPluginResult, paramString));
    return;
  }
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:18,代码来源:NativeToJsMessageQueue.java

示例7: onReceivedError

import org.apache.cordova.api.PluginResult; //导入依赖的package包/类
public void onReceivedError(WebView paramWebView, int paramInt, String paramString1, String paramString2)
{
  super.onReceivedError(paramWebView, paramInt, paramString1, paramString2);
  try
  {
    JSONObject localJSONObject = new JSONObject();
    localJSONObject.put("type", "loaderror");
    localJSONObject.put("url", paramString2);
    localJSONObject.put("code", paramInt);
    localJSONObject.put("message", paramString1);
    InAppBrowser.this.sendUpdate(localJSONObject, true, PluginResult.Status.ERROR);
    return;
  }
  catch (JSONException localJSONException)
  {
    Log.d("InAppBrowser", "Should never happen");
  }
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:19,代码来源:InAppBrowser.java

示例8: dispatch

import org.apache.cordova.api.PluginResult; //导入依赖的package包/类
public PluginResult dispatch(BaseActionDispatcher.Context paramContext)
  throws Throwable
{
  DatabaseManager localDatabaseManager = DatabaseManager.getInstance();
  try
  {
    localDatabaseManager.clearDbPath();
    localDatabaseManager.clearDatabaseKey();
    if (localDatabaseManager.isDatabaseOpen())
      localDatabaseManager.closeDatabase();
    PluginResult localPluginResult = new PluginResult(PluginResult.Status.OK, 0);
    return localPluginResult;
  }
  catch (Throwable localThrowable)
  {
  }
  return new PluginResult(PluginResult.Status.ERROR, 23);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:19,代码来源:CloseDatabaseActionDispatcher.java

示例9: dispatch

import org.apache.cordova.api.PluginResult; //导入依赖的package包/类
public PluginResult dispatch(DatabaseActionDispatcher.Context paramContext)
  throws Throwable
{
  JSONArray localJSONArray1 = getIds(paramContext);
  try
  {
    JSONArray localJSONArray2 = (JSONArray)paramContext.performReadableDatabaseAction(new FindByIdAction(localJSONArray1, null));
    if (localJSONArray2 == null)
      return new PluginResult(PluginResult.Status.ERROR, 22);
    JacksonSerializedPluginResult localJacksonSerializedPluginResult = new JacksonSerializedPluginResult(PluginResult.Status.OK, localJSONArray2);
    return localJacksonSerializedPluginResult;
  }
  catch (Throwable localThrowable)
  {
    if (this.logger.isLoggable(6))
      this.logger.logError("error while executing find by ID query on database \"" + paramContext.getDatabaseName() + "\"", localThrowable);
  }
  return new PluginResult(PluginResult.Status.ERROR, 22);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:20,代码来源:FindByIdActionDispatcher.java

示例10: dispatch

import org.apache.cordova.api.PluginResult; //导入依赖的package包/类
public PluginResult dispatch(BaseActionDispatcher.Context paramContext)
  throws Throwable
{
  if (!DatabaseManager.getInstance().isDatabaseOpen())
    return new PluginResult(PluginResult.Status.ERROR, -50);
  String str1 = getNewPW(paramContext);
  String str2 = getOldPW(paramContext);
  String str3 = getUserName(paramContext);
  SecurityManager localSecurityManager = SecurityManager.getInstance(paramContext.getCordovaContext().getActivity());
  try
  {
    String str4 = localSecurityManager.getDPK(str2, str3);
    String str5 = localSecurityManager.getSalt(str3);
    localSecurityManager.storeDPK(str1, str3, str4, str5, true, false);
    return new PluginResult(PluginResult.Status.OK, 0);
  }
  catch (Throwable localThrowable)
  {
  }
  return new PluginResult(PluginResult.Status.ERROR, 24);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:22,代码来源:ChangePasswordActionDispatcher.java

示例11: dispatch

import org.apache.cordova.api.PluginResult; //导入依赖的package包/类
public PluginResult dispatch(DatabaseActionDispatcher.Context paramContext)
  throws Throwable
{
  JSONArray localJSONArray = getDocs(paramContext);
  for (int i = 0; i < localJSONArray.length(); i++)
  {
    JSONObject localJSONObject = localJSONArray.getJSONObject(i);
    MarkCleanAction localMarkCleanAction = new MarkCleanAction(localJSONObject.getInt("_id"), localJSONObject.getString("_operation"), null);
    try
    {
      if (((Integer)paramContext.performWritableDatabaseAction(localMarkCleanAction)).intValue() > 0)
        continue;
      PluginResult localPluginResult = new PluginResult(PluginResult.Status.ERROR, 15);
      return localPluginResult;
    }
    catch (Throwable localThrowable)
    {
      Exception localException = new Exception("Failed trying to mark document clean");
      this.logger.logError("Failed trying to mark document clean", localException);
      return new PluginResult(PluginResult.Status.ERROR, 15);
    }
  }
  return new PluginResult(PluginResult.Status.OK, 0);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:25,代码来源:MarkCleanActionDispatcher.java

示例12: dispatch

import org.apache.cordova.api.PluginResult; //导入依赖的package包/类
public PluginResult dispatch(DatabaseActionDispatcher.Context paramContext)
  throws Throwable
{
  int i = -1;
  try
  {
    int k = ((Integer)paramContext.performReadableDatabaseAction(new SimpleQueryAction(paramContext, null))).intValue();
    i = k;
    int j = getModifiedResultValue(i);
    logResult(paramContext, j);
    return new PluginResult(PluginResult.Status.OK, j);
  }
  catch (Throwable localThrowable)
  {
    while (true)
    {
      if (!this.logger.isLoggable(6))
        continue;
      this.logger.logError("error occurred while performing query:");
      this.logger.logError("   " + getFormattedQuery(paramContext), localThrowable);
    }
  }
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:24,代码来源:SimpleQueryActionDispatcher.java

示例13: dispatch

import org.apache.cordova.api.PluginResult; //导入依赖的package包/类
public PluginResult dispatch(CordovaInterface paramCordovaInterface, JSONArray paramJSONArray)
  throws Throwable
{
  Context localContext = new Context(paramCordovaInterface);
  collectParameters(localContext, paramJSONArray);
  if (this.logger.isLoggable(3))
  {
    this.logger.logDebug("invoking action dispatcher \"" + this.name + "\" with parameters:");
    Iterator localIterator = this.parameters.iterator();
    while (localIterator.hasNext())
    {
      Parameter localParameter = (Parameter)localIterator.next();
      String str = localParameter.getName();
      if (localParameter.isLoggable())
      {
        this.logger.logDebug("   " + str + "=" + localContext.getUntypedParameter(str));
        continue;
      }
      this.logger.logDebug("   " + str + "=[value not logged]");
    }
  }
  return dispatch(localContext);
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:24,代码来源:BaseActionDispatcher.java

示例14: openFile

import org.apache.cordova.api.PluginResult; //导入依赖的package包/类
private PluginResult openFile(String fileUrl){
    Log.d("FileViewerPlugin", "View file"+fileUrl);
    Intent intent = new Intent();
    intent.setAction(android.content.Intent.ACTION_VIEW);
    File file = new File(fileUrl);

    String extension = fileUrl.substring(fileUrl.lastIndexOf(".")+1);
    String type = "";

    if (extension.toLowerCase().equals("pdf")) {
        type = "application/pdf";
    } else if (extension.toLowerCase().equals("flv")) {
        type = "video/flv";
    } else if (extension.toLowerCase().equals("mp4")) {
        type = "video/mp4";
    } else if (extension.toLowerCase().equals("jpg")) {
        type = "image/jpg";
    }

    intent.setDataAndType(Uri.fromFile(file), type);
    cordova.getActivity().startActivity(intent);

    Log.d("FileViewerPlugin", "View complete in" + fileUrl);

    return new PluginResult(PluginResult.Status.OK, fileUrl);
}
 
开发者ID:subodhtirkey,项目名称:phonegap-FileViewer,代码行数:27,代码来源:Echo.java

示例15: addPluginResult

import org.apache.cordova.api.PluginResult; //导入依赖的package包/类
/**
 * Add a JavaScript statement to the list.
 */
public void addPluginResult(PluginResult result, String callbackId) {
    if (callbackId == null) {
        Log.e(LOG_TAG, "Got plugin result with no callbackId", new Throwable());
        return;
    }
    // Don't send anything if there is no result and there is no need to
    // clear the callbacks.
    boolean noResult = result.getStatus() == PluginResult.Status.NO_RESULT.ordinal();
    boolean keepCallback = result.getKeepCallback();
    if (noResult && keepCallback) {
        return;
    }
    JsMessage message = new JsMessage(result, callbackId);
    if (FORCE_ENCODE_USING_EVAL) {
        StringBuilder sb = new StringBuilder(message.calculateEncodedLength() + 50);
        message.encodeAsJsMessage(sb);
        message = new JsMessage(sb.toString());
    }

    enqueueMessage(message);
}
 
开发者ID:thedracle,项目名称:cordova-android-chromeview,代码行数:25,代码来源:NativeToJsMessageQueue.java


注:本文中的org.apache.cordova.api.PluginResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。