Search in sources :

Example 66 with PluginResult

use of org.apache.cordova.PluginResult in project barcodescanner-sdk-cordova by Scandit.

the class SubViewPickerController method didRecognizeText.

@Override
public int didRecognizeText(RecognizedText recognizedText) {
    if (mPendingClose.get()) {
        // return if there is a pending close. Otherwise we might deadlock
        return TextRecognitionListener.PICKER_STATE_STOPPED;
    }
    JSONArray eventArgs = Marshal.createEventArgs(ScanditSDK.DID_RECOGNIZE_TEXT_EVENT, ResultRelay.jsonForRecognizedText(recognizedText));
    PluginResult result = Marshal.createOkResult(eventArgs);
    int nextState = sendPluginResultBlocking(result);
    if (!mContinuousMode) {
        nextState = PickerStateMachine.PAUSED;
    }
    if (!mContinuousMode) {
        removeSubviewPicker();
    }
    PickerStateMachine stateMachine = mPickerStateMachine;
    if (stateMachine != null) {
        stateMachine.setState(nextState);
    }
    Marshal.rejectRecognizedTexts(recognizedText, mRejectedCodeIds);
    if (nextState == PickerStateMachine.STOPPED) {
        return TextRecognitionListener.PICKER_STATE_STOPPED;
    } else if (nextState == PickerStateMachine.PAUSED) {
        return TextRecognitionListener.PICKER_STATE_PAUSED;
    } else {
        return TextRecognitionListener.PICKER_STATE_ACTIVE;
    }
}
Also used : PluginResult(org.apache.cordova.PluginResult) JSONArray(org.json.JSONArray) Point(android.graphics.Point)

Example 67 with PluginResult

use of org.apache.cordova.PluginResult in project barcodescanner-sdk-cordova by Scandit.

the class FullscreenPickerController method onRelayedResult.

@Override
public int onRelayedResult(Bundle bundle) {
    PluginResult result = resultForBundle(bundle);
    if (bundle.getBoolean("waitForResult", true)) {
        return sendPluginResultBlocking(result);
    }
    mCallbackContext.sendPluginResult(resultForBundle(bundle));
    return 0;
}
Also used : PluginResult(org.apache.cordova.PluginResult)

Example 68 with PluginResult

use of org.apache.cordova.PluginResult in project barcodescanner-sdk-cordova by Scandit.

the class Marshal method createOkResult.

public static PluginResult createOkResult(JSONArray args) {
    PluginResult result = new PluginResult(PluginResult.Status.OK, args);
    result.setKeepCallback(true);
    return result;
}
Also used : PluginResult(org.apache.cordova.PluginResult)

Aggregations

PluginResult (org.apache.cordova.PluginResult)68 JSONException (org.json.JSONException)23 JSONObject (org.json.JSONObject)21 JSONArray (org.json.JSONArray)14 IOException (java.io.IOException)8 NativeToJsMessageQueue (org.apache.cordova.NativeToJsMessageQueue)6 Test (org.junit.Test)6 Uri (android.net.Uri)4 FileNotFoundException (java.io.FileNotFoundException)4 AlertDialog (android.app.AlertDialog)3 DialogInterface (android.content.DialogInterface)3 Intent (android.content.Intent)3 TextView (android.widget.TextView)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 File (java.io.File)3 OutputStream (java.io.OutputStream)3 ArrayList (java.util.ArrayList)3 CallbackContext (org.apache.cordova.CallbackContext)3 CordovaResourceApi (org.apache.cordova.CordovaResourceApi)3 SharedPreferences (android.content.SharedPreferences)2