List of usage examples for com.facebook.react.bridge Callback invoke
public void invoke(Object... args);
From source file:com.dynamsoft.barcodescanner.BarcodeReaderManager.java
@ReactMethod public void readBarcode(String license, Callback resultCallback, Callback errorCallback) { mResultCallback = resultCallback;//ww w. jav a 2 s . c o m Activity currentActivity = getCurrentActivity(); if (currentActivity == null) { errorCallback.invoke("Activity doesn't exist"); return; } Intent cameraIntent = new Intent(currentActivity.getBaseContext(), DBR.class); cameraIntent.setAction("com.dynamsoft.dbr"); cameraIntent.putExtra("license", license); // avoid calling other phonegap apps cameraIntent.setPackage(currentActivity.getApplicationContext().getPackageName()); currentActivity.startActivityForResult(cameraIntent, REQUEST_CODE); }
From source file:com.horcrux.svg.SvgViewModule.java
License:Open Source License
@ReactMethod public void toDataURL(int tag, Callback successCallback) { SvgViewShadowNode svg = SvgViewManager.getShadowNodeByTag(tag); if (svg != null) { successCallback.invoke(svg.toDataURL()); }// www.j a v a 2s .c o m }
From source file:com.microsoft.aad.adal.ReactNativeAdalPlugin.java
License:Open Source License
@ReactMethod public void acquireTokenAsync(ReadableMap obj, Callback callback) { final AuthenticationContext authContext; String authority = obj.hasKey("authority") ? obj.getString("authority") : null; boolean validateAuthority = obj.hasKey("validateAuthority") ? obj.getBoolean("validateAuthority") : false; String resourceId = obj.hasKey("resourceId") ? obj.getString("resourceId") : null; String clientId = obj.hasKey("clientId") ? obj.getString("clientId") : null; String redirectUri = obj.hasKey("redirectUri") ? obj.getString("redirectUri") : null; String userId = obj.hasKey("userId") ? obj.getString("userId") : null; String extraQueryParams = obj.hasKey("extraQueryParams") ? obj.getString("extraQueryParams") : null; try {// w w w .j a v a 2 s . com authContext = getOrCreateContext(authority, validateAuthority); } catch (Exception e) { callback.invoke(e.getMessage()); return; } if (userId != null) { ITokenCacheStore cache = authContext.getCache(); if (cache instanceof ITokenStoreQuery) { List<TokenCacheItem> tokensForUserId = ((ITokenStoreQuery) cache).getTokensForUser(userId); if (tokensForUserId.size() > 0) { // Try to acquire alias for specified userId userId = tokensForUserId.get(0).getUserInfo().getDisplayableId(); } } } authContext.acquireToken(this.getCurrentActivity(), resourceId, clientId, redirectUri, userId, SHOW_PROMPT_ALWAYS, extraQueryParams, new DefaultAuthenticationCallback(callback)); }
From source file:com.microsoft.aad.adal.ReactNativeAdalPlugin.java
License:Open Source License
@ReactMethod public void acquireTokenSilentAsync(ReadableMap obj, Callback callback) { //String authority, boolean validateAuthority, String resourceUrl, String clientId, String userId) { final AuthenticationContext authContext; String authority = obj.hasKey("authority") ? obj.getString("authority") : null; boolean validateAuthority = obj.hasKey("validateAuthority") ? obj.getBoolean("validateAuthority") : false; String resourceId = obj.hasKey("resourceId") ? obj.getString("resourceId") : null; String clientId = obj.hasKey("clientId") ? obj.getString("clientId") : null; String userId = obj.hasKey("userId") ? obj.getString("userId") : null; try {//from w w w .j a va 2s .c o m authContext = getOrCreateContext(authority, validateAuthority); // We should retrieve userId from broker cache since local is always empty boolean useBroker = AuthenticationSettings.INSTANCE.getUseBroker(); if (useBroker) { if (TextUtils.isEmpty(userId)) { // Get first user from account list userId = authContext.getBrokerUser(); } for (UserInfo info : authContext.getBrokerUsers()) { if (info.getDisplayableId().equals(userId)) { userId = info.getUserId(); break; } } } } catch (Exception e) { callback.invoke(e.getMessage()); return; } authContext.acquireTokenSilentAsync(resourceId, clientId, userId, new DefaultAuthenticationCallback(callback)); }
From source file:com.microsoft.aad.adal.ReactNativeAdalPlugin.java
License:Open Source License
@ReactMethod public void tokenCacheReadItems(ReadableMap obj, Callback callback) throws JSONException { final AuthenticationContext authContext; String authority = obj.hasKey("authority") ? obj.getString("authority") : null; boolean validateAuthority = obj.hasKey("validateAuthority") ? obj.getBoolean("validateAuthority") : false; try {/* www.j av a 2s .c om*/ authContext = getOrCreateContext(authority, validateAuthority); } catch (Exception e) { callback.invoke(e.getMessage()); return; } WritableArray result = Arguments.createArray(); ITokenCacheStore cache = authContext.getCache(); if (cache instanceof ITokenStoreQuery) { Iterator<TokenCacheItem> cacheItems = ((ITokenStoreQuery) cache).getAll(); while (cacheItems.hasNext()) { TokenCacheItem item = cacheItems.next(); result.pushMap(tokenItemToJSON(item)); } } callback.invoke(null, result); }
From source file:com.microsoft.aad.adal.ReactNativeAdalPlugin.java
License:Open Source License
@ReactMethod public void tokenCacheDeleteItem(ReadableMap obj, Callback callback) { final AuthenticationContext authContext; String authority = obj.hasKey("authority") ? obj.getString("authority") : null; boolean validateAuthority = obj.hasKey("validateAuthority") ? obj.getBoolean("validateAuthority") : false; String resourceId = obj.hasKey("resourceId") ? obj.getString("resourceId") : null; String clientId = obj.hasKey("clientId") ? obj.getString("clientId") : null; String userId = obj.hasKey("userId") ? obj.getString("userId") : null; String itemAuthority = obj.hasKey("itemAuthority") ? obj.getString("itemAuthority") : null; boolean isMultipleResourceRefreshToken = obj.hasKey("isMultipleResourceRefreshToken") ? obj.getBoolean("isMultipleResourceRefreshToken") : false;//from ww w . j a v a 2 s.c o m try { authContext = getOrCreateContext(authority, validateAuthority); } catch (Exception e) { callback.invoke(e.getMessage()); return; } String key = CacheKey.createCacheKey(itemAuthority, resourceId, clientId, isMultipleResourceRefreshToken, userId, "1"); authContext.getCache().removeItem(key); callback.invoke(); }
From source file:com.microsoft.aad.adal.ReactNativeAdalPlugin.java
License:Open Source License
@ReactMethod public void tokenCacheClear(ReadableMap obj, Callback callback) { final AuthenticationContext authContext; String authority = obj.hasKey("authority") ? obj.getString("authority") : null; boolean validateAuthority = obj.hasKey("validateAuthority") ? obj.getBoolean("validateAuthority") : false; try {//from w w w . java2 s . com authContext = getOrCreateContext(authority, validateAuthority); } catch (Exception e) { callback.invoke(e.getMessage()); return; } authContext.getCache().removeAll(); callback.invoke(); }
From source file:com.microsoft.aad.adal.ReactNativeAdalPlugin.java
License:Open Source License
@ReactMethod public void setUseBroker(ReadableMap obj, Callback callback) { boolean useBroker = obj.hasKey("useBroker") ? obj.getBoolean("useBroker") : false; this.permissionCallback = callback; try {/*from w ww .j av a 2 s .c o m*/ AuthenticationSettings.INSTANCE.setUseBroker(useBroker); // Android 6.0 "Marshmallow" introduced a new permissions model where the user can turn on and off permissions as necessary. // This means that applications must handle these permission in run time. // http://cordova.apache.org/docs/en/latest/guide/platforms/android/plugin.html#android-permissions if (useBroker && Build.VERSION.SDK_INT >= 23 /* Build.VERSION_CODES.M */ ) { requestBrokerPermissions(); // Cordova callback will be handled by requestBrokerPermissions method } } catch (Exception e) { callback.invoke(e.getMessage()); } }
From source file:com.reactnative.googlefit.GoogleFitModule.java
License:Open Source License
@ReactMethod public void getDailyStepCountSamples(double startDate, double endDate, Callback errorCallback, Callback successCallback) { try {/*w w w .j a v a2 s. co m*/ successCallback.invoke( googleFitManager.getStepHistory().aggregateDataByDate((long) startDate, (long) endDate)); } catch (IllegalViewOperationException e) { errorCallback.invoke(e.getMessage()); } }
From source file:com.reactnative.googlefit.GoogleFitModule.java
License:Open Source License
@ReactMethod public void getWeightSamples(double startDate, double endDate, Callback errorCallback, Callback successCallback) { try {/* w w w. j a v a2s . c o m*/ successCallback.invoke( googleFitManager.getWeightsHistory().displayLastWeeksData((long) startDate, (long) endDate)); } catch (IllegalViewOperationException e) { errorCallback.invoke(e.getMessage()); } }