Java Code Examples for com.facebook.react.bridge.ReadableArray#toArrayList()

The following examples show how to use com.facebook.react.bridge.ReadableArray#toArrayList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GoogleFitModule.java    From react-native-google-fit with MIT License 6 votes vote down vote up
@ReactMethod
public void authorize(ReadableMap options) {
    final Activity activity = getCurrentActivity();

    if (mGoogleFitManager == null) {
        mGoogleFitManager = new GoogleFitManager(mReactContext, activity);
    }

    if (mGoogleFitManager.isAuthorized()) {
        return;
    }

    ReadableArray scopes = options.getArray("scopes");
    ArrayList<String> scopesList = new ArrayList<String>();

    for (Object type : scopes.toArrayList()) {
        scopesList.add(type.toString());
    }

    mGoogleFitManager.authorize(scopesList);
}
 
Example 2
Source File: GPay.java    From react-native-GPay with MIT License 5 votes vote down vote up
/**
 * Card networks supported by your app and your gateway
 *
 * @return allowed card networks
 * @see <a
 * href="https://developers.google.com/pay/api/android/reference/object#CardParameters">CardParameters</a>
 */
private static JSONArray getAllowedCardNetworks(ReadableArray cardNetworks) {

    JSONArray jsonArray = new JSONArray();

    for (Object value : cardNetworks.toArrayList()) {
        jsonArray.put(value.toString());
    }

    return jsonArray;
}
 
Example 3
Source File: GPay.java    From react-native-GPay with MIT License 5 votes vote down vote up
/**
 * Card networks supported by your app and your gateway
 *
 * @return allowed card networks
 * @see <a
 * href="https://developers.google.com/pay/api/android/reference/object#CardParameters">CardParameters</a>
 */
private static JSONArray getAllowedCardNetworks(ReadableArray cardNetworks) {

    JSONArray jsonArray = new JSONArray();

    for (Object value : cardNetworks.toArrayList()) {
        jsonArray.put(value.toString());
    }

    return jsonArray;
}
 
Example 4
Source File: RecordingApi.java    From react-native-google-fit with MIT License 5 votes vote down vote up
public void subscribe(ReadableArray dataTypes) {
    ArrayList<String> dataTypesList = new ArrayList<String>();

    for (Object type : dataTypes.toArrayList()) {
        dataTypesList.add(type.toString());
    }


    for (String dataTypeName : dataTypesList) {
        DataType dataType = getDataType(dataTypeName);

        // Just skip unknown data types
        if (dataType == null) {
            continue;
        }

        final String eventName = getEventName(dataTypeName);

        Fitness.RecordingApi.subscribe(googleFitManager.getGoogleApiClient(), dataType)
                .setResultCallback(new ResultCallback<Status>() {
                    @Override
                    public void onResult(@NonNull Status status) {
                        WritableMap map = Arguments.createMap();

                        map.putString("type", eventName);

                        if (status.isSuccess()) {
                            map.putBoolean("recording", true);
                            Log.i(TAG, "RecordingAPI - Connected");
                            sendEvent(reactContext, eventName, map);
                        } else {
                            map.putBoolean("recording", false);
                            Log.i(TAG, "RecordingAPI - Error connecting");
                            sendEvent(reactContext, eventName, map);
                        }
                    }
                });
    }
}
 
Example 5
Source File: RNIconic.java    From react-native-iconic with Apache License 2.0 4 votes vote down vote up
@ReactProp(name = "shape")
public void setShape(FrameLayout iconicButtonFrame, ReadableArray shps) {
    shapes = shps.toArrayList();

    setState(iconicButtonFrame, selection);
}