Example usage for com.facebook.react.bridge Arguments createMap

List of usage examples for com.facebook.react.bridge Arguments createMap

Introduction

In this page you can find the example usage for com.facebook.react.bridge Arguments createMap.

Prototype

public static WritableMap createMap() 

Source Link

Document

This method should be used when you need to stub out creating NativeMaps in unit tests.

Usage

From source file:co.rewen.statex.AsyncStorageErrorUtil.java

License:Open Source License

/**
 * Create Error object to be passed back to the JS callback.
 *//*  w  w w. j a  va 2  s  .  com*/
/* package */ static WritableMap getError(@Nullable String key, String errorMessage) {
    WritableMap errorMap = Arguments.createMap();
    errorMap.putString("message", errorMessage);
    if (key != null) {
        errorMap.putString("key", key);
    }
    return errorMap;
}

From source file:com.adjust.nativemodule.AdjustUtil.java

License:Open Source License

public static WritableMap attributionToMap(AdjustAttribution attribution) {
    WritableMap map = Arguments.createMap();

    if (null == attribution) {
        return map;
    }/*from   w ww  . j av a2s  .c om*/

    map.putString(ATTRIBUTION_TRACKER_TOKEN, null != attribution.trackerToken ? attribution.trackerToken : "");
    map.putString(ATTRIBUTION_TRACKER_NAME, null != attribution.trackerName ? attribution.trackerName : "");
    map.putString(ATTRIBUTION_NETWORK, null != attribution.network ? attribution.network : "");
    map.putString(ATTRIBUTION_CAMPAIGN, null != attribution.campaign ? attribution.campaign : "");
    map.putString(ATTRIBUTION_ADGROUP, null != attribution.adgroup ? attribution.adgroup : "");
    map.putString(ATTRIBUTION_CREATIVE, null != attribution.creative ? attribution.creative : "");
    map.putString(ATTRIBUTION_CLICK_LABEL, null != attribution.clickLabel ? attribution.clickLabel : "");
    map.putString(ATTRIBUTION_ADID, null != attribution.adid ? attribution.adid : "");

    return map;
}

From source file:com.adjust.nativemodule.AdjustUtil.java

License:Open Source License

public static WritableMap eventSuccessToMap(AdjustEventSuccess eventSuccess) {
    WritableMap map = Arguments.createMap();

    if (null == eventSuccess) {
        return map;
    }/*from   w  w  w  .j ava2 s  .c  om*/

    map.putString(EVENT_SUCCESS_MESSAGE, null != eventSuccess.message ? eventSuccess.message : "");
    map.putString(EVENT_SUCCESS_TIMESTAMP, null != eventSuccess.timestamp ? eventSuccess.timestamp : "");
    map.putString(EVENT_SUCCESS_ADID, null != eventSuccess.adid ? eventSuccess.adid : "");
    map.putString(EVENT_SUCCESS_EVENT_TOKEN, null != eventSuccess.eventToken ? eventSuccess.eventToken : "");
    map.putString(EVENT_SUCCESS_JSON_RESPONSE,
            null != eventSuccess.jsonResponse ? eventSuccess.jsonResponse.toString() : "");

    return map;
}

From source file:com.adjust.nativemodule.AdjustUtil.java

License:Open Source License

public static WritableMap eventFailureToMap(AdjustEventFailure eventFailure) {
    WritableMap map = Arguments.createMap();

    if (null == eventFailure) {
        return map;
    }/*from   w  ww. j  a  v a2  s .c o m*/

    map.putString(EVENT_FAILED_MESSAGE, null != eventFailure.message ? eventFailure.message : "");
    map.putString(EVENT_FAILED_TIMESTAMP, null != eventFailure.timestamp ? eventFailure.timestamp : "");
    map.putString(EVENT_FAILED_ADID, null != eventFailure.adid ? eventFailure.adid : "");
    map.putString(EVENT_FAILED_EVENT_TOKEN, null != eventFailure.eventToken ? eventFailure.eventToken : "");
    map.putString(EVENT_FAILED_WILL_RETRY, eventFailure.willRetry ? "true" : "false");
    map.putString(EVENT_FAILED_JSON_RESPONSE,
            null != eventFailure.jsonResponse ? eventFailure.jsonResponse.toString() : "");

    return map;
}

From source file:com.adjust.nativemodule.AdjustUtil.java

License:Open Source License

public static WritableMap sessionSuccessToMap(AdjustSessionSuccess sessionSuccess) {
    WritableMap map = Arguments.createMap();

    if (null == sessionSuccess) {
        return map;
    }//from   www . j  a  va  2  s. c  om

    map.putString(SESSION_SUCCESS_MESSAGE, null != sessionSuccess.message ? sessionSuccess.message : "");
    map.putString(SESSION_SUCCESS_TIMESTAMP, null != sessionSuccess.timestamp ? sessionSuccess.timestamp : "");
    map.putString(SESSION_SUCCESS_ADID, null != sessionSuccess.adid ? sessionSuccess.adid : "");
    map.putString(SESSION_SUCCESS_JSON_RESPONSE,
            null != sessionSuccess.jsonResponse ? sessionSuccess.jsonResponse.toString() : "");

    return map;
}

From source file:com.adjust.nativemodule.AdjustUtil.java

License:Open Source License

public static WritableMap sessionFailureToMap(AdjustSessionFailure sessionFailure) {
    WritableMap map = Arguments.createMap();

    if (null == sessionFailure) {
        return map;
    }/*from   w  w w  . j  ava 2 s .c o m*/

    map.putString(SESSION_FAILED_MESSAGE, null != sessionFailure.message ? sessionFailure.message : "");
    map.putString(SESSION_FAILED_TIMESTAMP, null != sessionFailure.timestamp ? sessionFailure.timestamp : "");
    map.putString(SESSION_FAILED_ADID, null != sessionFailure.adid ? sessionFailure.adid : "");
    map.putString(SESSION_FAILED_WILL_RETRY, sessionFailure.willRetry ? "true" : "false");
    map.putString(SESSION_FAILED_JSON_RESPONSE,
            null != sessionFailure.jsonResponse ? sessionFailure.jsonResponse.toString() : "");

    return map;
}

From source file:com.adjust.nativemodule.AdjustUtil.java

License:Open Source License

public static WritableMap deferredDeeplinkToMap(Uri uri) {
    WritableMap map = Arguments.createMap();

    if (null == uri) {
        return map;
    }//from   w  w w . j av a 2 s.  c om

    map.putString("uri", uri.toString());

    return map;
}

From source file:com.amazonaws.reactnative.core.AWSRNClientMarshaller.java

License:Open Source License

public static WritableMap jsonToReact(final JSONObject jsonObject) throws JSONException {
    final WritableMap writableMap = Arguments.createMap();
    final Iterator iterator = jsonObject.keys();
    while (iterator.hasNext()) {
        final String key = (String) iterator.next();
        final Object value = jsonObject.get(key);
        if (value instanceof Float || value instanceof Double) {
            writableMap.putDouble(key, jsonObject.getDouble(key));
        } else if (value instanceof Number) {
            writableMap.putInt(key, jsonObject.getInt(key));
        } else if (value instanceof String) {
            writableMap.putString(key, jsonObject.getString(key));
        } else if (value instanceof JSONObject) {
            writableMap.putMap(key, jsonToReact(jsonObject.getJSONObject(key)));
        } else if (value instanceof JSONArray) {
            writableMap.putArray(key, jsonToReact(jsonObject.getJSONArray(key)));
        } else if (value instanceof Boolean) {
            writableMap.putBoolean(key, jsonObject.getBoolean(key));
        } else if (value == JSONObject.NULL) {
            writableMap.putNull(key);/*w w  w.java 2 s .  c o  m*/
        }
    }
    return writableMap;
}

From source file:com.amazonaws.reactnative.core.AWSRNCognitoCredentials.java

License:Open Source License

@ReactMethod
public void initWithOptions(final ReadableMap options) throws IllegalArgumentException {
    if (!options.hasKey(IDENTITY_POOL_ID) || !options.hasKey(REGION)) {
        throw new IllegalArgumentException("identity_pool_id and/or region not supplied");
    } else {//from  w  w  w . j  a va  2s. c  o m
        credentialsProvider = new CognitoCachingCredentialsProvider(getReactApplicationContext(),
                options.getString(IDENTITY_POOL_ID), Regions.fromName(options.getString(REGION)),
                new AWSRNClientConfiguration().withUserAgent(SERVICE_NAME));
        credentialsProvider.registerIdentityChangedListener(new IdentityChangedListener() {
            @Override
            public void identityChanged(final String oldidentityid, final String newidentityid) {
                final WritableMap params = Arguments.createMap();
                params.putString(CURRENT, newidentityid);
                params.putString(PREVIOUS, oldidentityid);
                sendEvent(getReactApplicationContext(), IDENTITYCHANGE, params);
            }
        });
    }
}

From source file:com.amazonaws.reactnative.core.AWSRNCognitoCredentials.java

License:Open Source License

@ReactMethod
public void getIdentityIDAsync(final Promise promise) {
    backgroundRunner.runInBackground(new BackgroundRunner.Supplier<WritableMap>() {
        @Override//from   ww w  .  j a v  a 2s .  co  m
        public WritableMap get() throws Exception {
            final String identityId = credentialsProvider.getIdentityId();
            if (identityId != null) {
                final WritableMap identityidMap = Arguments.createMap();
                identityidMap.putString(IDENTITYID, identityId);
                return identityidMap;
            } else {
                // TODO: throw exception instead?
                return null;
            }
        }
    }, PROMISE_REJECTOR, promise);
}