Example usage for org.apache.cordova PluginResult PluginResult

List of usage examples for org.apache.cordova PluginResult PluginResult

Introduction

In this page you can find the example usage for org.apache.cordova PluginResult PluginResult.

Prototype

public PluginResult(Status status, List<PluginResult> multipartMessages) 

Source Link

Usage

From source file:com.connectsdk.cordova.ConnectSDKCordova.java

License:Apache License

public void sendEvent(CallbackContext callbackContext, String event, Object... objs) {
    if (callbackContext != null) {
        PluginResult result;//from   w ww  .j av  a  2s.  co m

        JSONArray arr = new JSONArray();
        arr.put(event);

        for (Object obj : objs) {
            arr.put(obj);
        }

        result = new PluginResult(PluginResult.Status.OK, arr);
        result.setKeepCallback(true);
        callbackContext.sendPluginResult(result);
    }
}

From source file:com.connectsdk.cordova.ConnectSDKCordova.java

License:Apache License

public void sendErrorEvent(CallbackContext callbackContext, ServiceCommandError error) {
    if (callbackContext != null) {
        JSONObject errorObj = new JSONObject();

        try {// w w  w.  java 2  s.com
            errorObj.put("message", error.getMessage());
        } catch (JSONException e) {
            e.printStackTrace();
        }

        PluginResult result = new PluginResult(PluginResult.Status.ERROR, errorObj);
        result.setKeepCallback(true);
        callbackContext.sendPluginResult(result);
    }
}

From source file:com.connectsdk.cordova.JSCommand.java

License:Apache License

void sendSuccessEvent(Object... objs) {
    if (callbackContext == null)
        return;//from w w w  .j av  a  2  s . com

    JSONArray arr = new JSONArray();
    arr.put("success");

    for (Object o : objs) {
        arr.put(o);
    }

    if (subscription) {
        PluginResult pendingResult = new PluginResult(PluginResult.Status.OK, arr);
        pendingResult.setKeepCallback(true);
        callbackContext.sendPluginResult(pendingResult);
    } else {
        callbackContext.success(arr);
        checkDone();
    }
}

From source file:com.cordova.voicelayer.VoiceLayerIo.java

License:Apache License

public void onRequestPermissionResult(int requestCode, String[] permissions, int[] grantResults)
        throws JSONException {
    for (int r : grantResults) {
        if (r == PackageManager.PERMISSION_DENIED) {
            this.callbackContext
                    .sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR));
            return;
        }//from   www. j a  v a2 s .c  o m
    }
    switch (requestCode) {
    case RECORD_REQ_CODE:
        manageAudio(recordAudioChannel);
        break;
    }
}

From source file:com.cranberrygame.cordova.plugin.ad.admob.Util.java

License:Open Source License

public void onAdLoaded() {
    Log.d(LOG_TAG, "onAdLoaded");

    if (admob.bannerAdPreload) {
        PluginResult pr = new PluginResult(PluginResult.Status.OK, "onBannerAdPreloaded");
        pr.setKeepCallback(true);//from  www . ja v a2  s . c om
        admob.bannerViewCC.sendPluginResult(pr);
        //PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
        //pr.setKeepCallback(true);
        //admob.bannerViewCC.sendPluginResult(pr);
    }

    PluginResult pr = new PluginResult(PluginResult.Status.OK, "onBannerAdLoaded");
    //pr.setKeepCallback(true);
    admob.bannerViewCC.sendPluginResult(pr);
    //PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
    //pr.setKeepCallback(true);
    //admob.bannerViewCC.sendPluginResult(pr);
}

From source file:com.cranberrygame.cordova.plugin.ad.admob.Util.java

License:Open Source License

public void onAdLoaded() {
    Log.d(LOG_TAG, "onAdLoaded");

    if (admob.fullScreenAdPreload) {
        PluginResult pr = new PluginResult(PluginResult.Status.OK, "onFullScreenAdPreloaded");
        pr.setKeepCallback(true);/*from   w  ww. j ava2s .c  om*/
        admob.interstitialViewCC.sendPluginResult(pr);
        //PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
        //pr.setKeepCallback(true);
        //admob.interstitialViewCC.sendPluginResult(pr);
    }

    PluginResult pr = new PluginResult(PluginResult.Status.OK, "onFullScreenAdLoaded");
    pr.setKeepCallback(true);
    admob.interstitialViewCC.sendPluginResult(pr);
    //PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
    //pr.setKeepCallback(true);
    //admob.interstitialViewCC.sendPluginResult(pr);      

    if (!admob.fullScreenAdPreload) {
        interstitialView.show();
    }
}

From source file:com.cranberrygame.cordova.plugin.ad.admob.Util.java

License:Open Source License

public void onAdOpened() {
    Log.d(LOG_TAG, "onAdOpened");

    PluginResult pr = new PluginResult(PluginResult.Status.OK, "onFullScreenAdShown");
    pr.setKeepCallback(true);/*from  w w w. j  av  a 2 s .com*/
    admob.interstitialViewCC.sendPluginResult(pr);
    //PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
    //pr.setKeepCallback(true);
    //admob.interstitialViewCC.sendPluginResult(pr);      
}

From source file:com.cranberrygame.cordova.plugin.ad.admob.Util.java

License:Open Source License

public void onAdClosed() {
    Log.d(LOG_TAG, "onAdClosed");

    PluginResult pr = new PluginResult(PluginResult.Status.OK, "onFullScreenAdHidden");
    //pr.setKeepCallback(true);
    admob.interstitialViewCC.sendPluginResult(pr);
    //PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
    //pr.setKeepCallback(true);
    //admob.interstitialViewCC.sendPluginResult(pr);      

}

From source file:com.cranberrygame.cordova.plugin.ad.admob.Util.java

License:Open Source License

public void _showBannerAd(String position, String size) {

    if (bannerIsShowingOverlap() && position.equals(bannerPreviousPosition)
            && size.equals(bannerPreviousSize)) {
        return;/*  w w  w. j  a  va  2  s .c  o  m*/
    }

    this.bannerPreviousPosition = position;
    this.bannerPreviousSize = size;

    if (bannerAdPreload) {
        bannerAdPreload = false;
    } else {
        _hideBannerAd();

        loadBannerAd();
    }

    addBannerViewOverlap(position, size);

    PluginResult pr = new PluginResult(PluginResult.Status.OK, "onBannerAdShown");
    pr.setKeepCallback(true);
    plugin.getCallbackContextKeepCallback().sendPluginResult(pr);
    //PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
    //pr.setKeepCallback(true);
    //plugin.getCallbackContextKeepCallback().sendPluginResult(pr);         
}

From source file:com.cranberrygame.cordova.plugin.ad.admob.Util.java

License:Open Source License

public void _hideBannerAd() {
    removeBannerViewOverlap();//  w  w w.j  a  v  a 2 s  .  c om

    PluginResult pr = new PluginResult(PluginResult.Status.OK, "onBannerAdHidden");
    pr.setKeepCallback(true);
    plugin.getCallbackContextKeepCallback().sendPluginResult(pr);
    //PluginResult pr = new PluginResult(PluginResult.Status.ERROR);
    //pr.setKeepCallback(true);
    //plugin.getCallbackContextKeepCallback().sendPluginResult(pr);      
}