Skip to content

Commit

Permalink
add press and release trigger feature to barcode manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Sachin Shankar committed Aug 12, 2019
1 parent 650f026 commit b962fa9
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/android/BarcodeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public boolean execute(String action, JSONArray data, CallbackContext context) t
// }
return true;

} else if (action.equals("pressTrigger")) {
return pressTrigger(context);

} else if (action.equals("releaseTrigger")) {
return releaseTrigger(context);
} else {

return false;
Expand Down Expand Up @@ -131,7 +136,38 @@ public void onPause(boolean multiTasking) {
}
}

private boolean pressTrigger(CallbackContext callbackContext){
if(decoder != null){
try{
if (decoder.pressTrigger() == DecodeException.SUCESS) {
PluginResult result = new PluginResult(PluginResult.Status.OK, "Successfully pressed the trigger");
callbackContext.sendPluginResult(result);
return true;
}
} catch(DecodeException e) {
Log.e(LOGTAG, "Error while pressing the trigger", e);
}
}
PluginResult result = new PluginResult(PluginResult.Status.ERROR, "Error while pressing the trigger " + e.getMessage() );
callbackContext.sendPluginResult(result);
return false;
}


private boolean releaseTrigger(CallbackContext callbackContext){
if(decoder != null){
try{
if (decoder.releaseTrigger() == DecodeException.SUCCESS) {
PluginResult result = new PluginResult(PluginResult.Status.OK, "Successfully released the trigger");
callbackContext.sendPluginResult(result);
return true;
}
} catch(DecodeException e) {
Log.e(LOGTAG, "Error while releasing the trigger", e);
}
}
PluginResult result = new PluginResult(PluginResult.Status.ERROR, "Error while releasing the trigger " + e.getMessage() );
callbackContext.sendPluginResult(result);
return false;
}

}
10 changes: 10 additions & 0 deletions www/barcodeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,14 @@ barcodeManager.addReadListner = function (successCallback, errorCallback) {

};

barcodeManager.pressTrigger = function (successCallback, errorCallback) {
exec(successCallback, errorCallback, "BarcodeManager", "pressTrigger", []);

};

barcodeManager.releaseTrigger = function (successCallback, errorCallback) {
exec(successCallback, errorCallback, "BarcodeManager", "releaseTrigger", []);

};

module.exports = barcodeManager;

0 comments on commit b962fa9

Please sign in to comment.