use of org.appcelerator.kroll.KrollFunction in project titanium-barcode by mwaylabs.
the class TitaniumBarcodeModule method scan.
@Kroll.method
public void scan(KrollDict options) {
logDebug("scan() called");
final KrollFunction successCallback = getCallback(options, "success");
final KrollFunction cancelCallback = getCallback(options, "cancel");
final KrollFunction errorCallback = getCallback(options, "error");
logDebug("launchScanActivity() called");
final Activity activity = TiApplication.getAppCurrentActivity();
final TiActivitySupport activitySupport = (TiActivitySupport) activity;
final TiIntentWrapper barcodeIntent = new TiIntentWrapper(new Intent(activity, TitaniumBarcodeActivity.class));
barcodeIntent.setWindowId(TiIntentWrapper.createActivityName("SCANNER"));
BarcodeResultHandler resultHandler = new BarcodeResultHandler();
resultHandler.successCallback = successCallback;
resultHandler.cancelCallback = cancelCallback;
resultHandler.errorCallback = errorCallback;
resultHandler.activitySupport = activitySupport;
resultHandler.barcodeIntent = barcodeIntent.getIntent();
activity.runOnUiThread(resultHandler);
logDebug("scan() ended");
}
Aggregations