Search in sources :

Example 1 with KrollFunction

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");
}
Also used : TiActivitySupport(org.appcelerator.titanium.util.TiActivitySupport) TiIntentWrapper(org.appcelerator.titanium.util.TiIntentWrapper) Activity(android.app.Activity) Intent(android.content.Intent) KrollFunction(org.appcelerator.kroll.KrollFunction)

Aggregations

Activity (android.app.Activity)1 Intent (android.content.Intent)1 KrollFunction (org.appcelerator.kroll.KrollFunction)1 TiActivitySupport (org.appcelerator.titanium.util.TiActivitySupport)1 TiIntentWrapper (org.appcelerator.titanium.util.TiIntentWrapper)1