List of usage examples for org.apache.cordova PluginResult setKeepCallback
public void setKeepCallback(boolean b)
From source file:com.acuant.plugin.AcuantMobileSDK.java
private void sendCardData(final PluginResult.Status statusCallback, final JSONObject objCallback, Handler handler) {/*from w w w .j a va 2s .c o m*/ handler.post(new Runnable() { @Override public void run() { PluginResult resultCallback = new PluginResult(statusCallback, objCallback); resultCallback.setKeepCallback(true); callbackId.sendPluginResult(resultCallback); } }); }
From source file:com.acuant.plugin.AcuantMobileSDK.java
@Override public void validateLicenseKeyCompleted(LicenseDetails details) { JSONObject obj = new JSONObject(); try {//from ww w .j av a 2s . co m if (details != null && details.isLicenseKeyActivated()) { sdkValidated = true; obj.put("id", "mobileSDKWasValidated"); obj.put("data", true); obj.put("message", details.getWebResponseDescription()); obj.put("isAssureIDAllowed", details.isAssureIDAllowed()); obj.put("isFacialAllowed", details.isFacialAllowed()); PluginResult result = new PluginResult(PluginResult.Status.OK, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } else { sdkValidated = false; obj.put("id", "didFailWithError"); obj.put("data", false); obj.put("errorType", ErrorType.AcuantErrorInvalidLicenseKey); obj.put("errorMessage", details.getResponseMessageAuthorization()); PluginResult result = new PluginResult(PluginResult.Status.ERROR, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.acuant.plugin.AcuantMobileSDK.java
@Override public void onCardImageCaptured() { cordova.getThreadPool().execute(new Runnable() { @Override/*from w ww . ja va2 s.c om*/ public void run() { try { JSONObject obj = new JSONObject(); obj.put("id", "onCardImageCaptured"); PluginResult result = new PluginResult(PluginResult.Status.OK, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } } }); }
From source file:com.acuant.plugin.AcuantMobileSDK.java
@Override public void onCardCroppingStart(Activity activity) { cordova.getThreadPool().execute(new Runnable() { @Override/*from w w w . j a va 2 s.co m*/ public void run() { try { JSONObject obj = new JSONObject(); obj.put("id", "didCardCroppingStart"); PluginResult result = new PluginResult(PluginResult.Status.OK, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } } }); }
From source file:com.acuant.plugin.AcuantMobileSDK.java
@Override public void onCardCroppingFinish(final Bitmap bitmap, int detectedType, final HashMap<String, Object> imageMetrics) { if (bitmap != null) { cordova.getThreadPool().execute(new Runnable() { @Override//w w w. j av a2s. c o m public void run() { try { JSONObject obj = new JSONObject(); obj.put("id", "didCaptureCropImage"); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream.toByteArray(); String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT); obj.put("data", encoded); if (imageMetrics != null && imageMetrics.get("HAS_GLARE") != null) { boolean hasGlare = Boolean.parseBoolean(imageMetrics.get("HAS_GLARE").toString()); obj.put("HAS_GLARE", hasGlare); } if (imageMetrics != null && imageMetrics.get("GLARE_GRADE") != null) { float glareGrade = Float.parseFloat(imageMetrics.get("GLARE_GRADE").toString()); obj.put("GLARE_GRADE", glareGrade); } if (imageMetrics != null && imageMetrics.get("IS_SHARP") != null) { boolean isSHarp = Boolean.parseBoolean(imageMetrics.get("IS_SHARP").toString()); obj.put("IS_SHARP", isSHarp); } if (imageMetrics != null && imageMetrics.get("SHARPNESS_GRADE") != null) { float sharpnessGrade = Float.parseFloat(imageMetrics.get("SHARPNESS_GRADE").toString()); obj.put("SHARPNESS_GRADE", sharpnessGrade); } PluginResult result = new PluginResult(PluginResult.Status.OK, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } } }); } else { cordova.getThreadPool().execute(new Runnable() { @Override public void run() { try { JSONObject obj = new JSONObject(); obj.put("id", "didFailWithError"); obj.put("errorType", 8); obj.put("errorMessage", "Unable to detect the card. Please try again."); PluginResult result = new PluginResult(PluginResult.Status.ERROR, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } } }); } }
From source file:com.acuant.plugin.AcuantMobileSDK.java
@Override public void onCardCroppingFinish(final Bitmap bitmap, final boolean scanBackSide, int detectedType, final HashMap<String, Object> imageMetrics) { if (bitmap != null) { cordova.getThreadPool().execute(new Runnable() { @Override// w w w. ja v a 2 s. c o m public void run() { try { JSONObject obj = new JSONObject(); if ((cardRegion == 0 || cardRegion == 1) && isBarcodeSide) { obj.put("id", "cropBarcode"); } else { obj.put("id", "didCaptureCropImage"); } ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream.toByteArray(); String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT); obj.put("data", encoded); obj.put("scanBackSide", scanBackSide); if (imageMetrics != null && imageMetrics.get("HAS_GLARE") != null) { boolean hasGlare = Boolean.parseBoolean(imageMetrics.get("HAS_GLARE").toString()); obj.put("HAS_GLARE", hasGlare); } if (imageMetrics != null && imageMetrics.get("GLARE_GRADE") != null) { float glareGrade = Float.parseFloat(imageMetrics.get("GLARE_GRADE").toString()); obj.put("GLARE_GRADE", glareGrade); } if (imageMetrics != null && imageMetrics.get("IS_SHARP") != null) { boolean isSHarp = Boolean.parseBoolean(imageMetrics.get("IS_SHARP").toString()); obj.put("IS_SHARP", isSHarp); } if (imageMetrics != null && imageMetrics.get("SHARPNESS_GRADE") != null) { float sharpnessGrade = Float.parseFloat(imageMetrics.get("SHARPNESS_GRADE").toString()); obj.put("SHARPNESS_GRADE", sharpnessGrade); } PluginResult result = new PluginResult(PluginResult.Status.OK, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } } }); } else { cordova.getThreadPool().execute(new Runnable() { @Override public void run() { try { JSONObject obj = new JSONObject(); obj.put("id", "didFailWithError"); obj.put("errorType", 8); obj.put("errorMessage", "Unable to detect the card. Please try again."); PluginResult result = new PluginResult(PluginResult.Status.ERROR, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } } }); } }
From source file:com.acuant.plugin.AcuantMobileSDK.java
@Override public void onOriginalCapture(final Bitmap bitmap) { if (bitmap != null) { cordova.getThreadPool().execute(new Runnable() { @Override//from w ww .j a va2s .c om public void run() { try { JSONObject obj = new JSONObject(); obj.put("id", "didCaptureOriginalImage"); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream.toByteArray(); String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT); obj.put("data", encoded); PluginResult result = new PluginResult(PluginResult.Status.OK, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } } }); } else { cordova.getThreadPool().execute(new Runnable() { @Override public void run() { try { JSONObject obj = new JSONObject(); obj.put("id", "didFailWithError"); obj.put("errorType", 8); obj.put("errorMessage", "Unable to detect the card. Please try again."); obj.put("ErrorInMethod", "onOriginalCapture"); PluginResult result = new PluginResult(PluginResult.Status.ERROR, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } } }); } }
From source file:com.acuant.plugin.AcuantMobileSDK.java
@Override public void onPDF417Finish(String result) { JSONObject obj = new JSONObject(); try {/*from w w w .j a v a2 s .c o m*/ obj.put("id", "didCaptureData"); obj.put("data", result); PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, obj); pluginResult.setKeepCallback(true); callbackId.sendPluginResult(pluginResult); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.acuant.plugin.AcuantMobileSDK.java
@Override public void onBarcodeTimeOut(Bitmap croppedImage, HashMap<String, Object> imageMetrics, Bitmap originalImage) { JSONObject obj = new JSONObject(); try {//from w ww. j ava2 s. c o m obj.put("id", "barcodeScanTimeOut"); if (croppedImage != null) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); croppedImage.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream.toByteArray(); String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT); obj.put("croppedData", encoded); } if (originalImage != null) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); originalImage.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream); byte[] byteArray = byteArrayOutputStream.toByteArray(); String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT); obj.put("originalData", encoded); } if (imageMetrics != null && imageMetrics.get("HAS_GLARE") != null) { boolean hasGlare = Boolean.parseBoolean(imageMetrics.get("HAS_GLARE").toString()); obj.put("HAS_GLARE", hasGlare); } if (imageMetrics != null && imageMetrics.get("GLARE_GRADE") != null) { float glareGrade = Float.parseFloat(imageMetrics.get("GLARE_GRADE").toString()); obj.put("GLARE_GRADE", glareGrade); } if (imageMetrics != null && imageMetrics.get("IS_SHARP") != null) { boolean isSHarp = Boolean.parseBoolean(imageMetrics.get("IS_SHARP").toString()); obj.put("IS_SHARP", isSHarp); } if (imageMetrics != null && imageMetrics.get("SHARPNESS_GRADE") != null) { float sharpnessGrade = Float.parseFloat(imageMetrics.get("SHARPNESS_GRADE").toString()); obj.put("SHARPNESS_GRADE", sharpnessGrade); } PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, obj); pluginResult.setKeepCallback(true); callbackId.sendPluginResult(pluginResult); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.acuant.plugin.AcuantMobileSDK.java
@Override public void tagReadSucceeded(final AcuantNFCCardDetails cardDetails, final Bitmap face_image, final Bitmap sign_image) { cordova.getThreadPool().execute(new Runnable() { @Override/*ww w . j a v a 2 s . c om*/ public void run() { try { JSONObject obj = new JSONObject(); obj.put("id", "tagReadSucceeded"); if (face_image != null) { ByteArrayOutputStream faceImageByteArrayOutputStream = new ByteArrayOutputStream(); face_image.compress(Bitmap.CompressFormat.JPEG, 100, faceImageByteArrayOutputStream); byte[] faceImageByte = faceImageByteArrayOutputStream.toByteArray(); obj.put("faceImage", Base64.encodeToString(faceImageByte, Base64.DEFAULT)); } if (sign_image != null) { ByteArrayOutputStream faceImageByteArrayOutputStream = new ByteArrayOutputStream(); sign_image.compress(Bitmap.CompressFormat.JPEG, 100, faceImageByteArrayOutputStream); byte[] signImageByte = faceImageByteArrayOutputStream.toByteArray(); obj.put("signImage", Base64.encodeToString(signImageByte, Base64.DEFAULT)); } JSONObject dataObject = EChipDataWithCard(cardDetails); obj.put("EChipData", dataObject); PluginResult result = new PluginResult(PluginResult.Status.OK, obj); result.setKeepCallback(true); callbackId.sendPluginResult(result); } catch (JSONException e) { e.printStackTrace(); } } }); }