use of com.facebook.react.bridge.WritableMap in project react-native-navigation by wix.
the class BottomTabsLayout method sendTabSelectedEventToJs.
private void sendTabSelectedEventToJs(int selectedTabIndex, int unselectedTabIndex) {
String navigatorEventId = screenStacks[selectedTabIndex].peek().getNavigatorEventId();
WritableMap data = createTabSelectedEventData(selectedTabIndex, unselectedTabIndex);
NavigationApplication.instance.getEventEmitter().sendNavigatorEvent("bottomTabSelected", navigatorEventId, data);
data = createTabSelectedEventData(selectedTabIndex, unselectedTabIndex);
NavigationApplication.instance.getEventEmitter().sendNavigatorEvent("bottomTabSelected", data);
}
use of com.facebook.react.bridge.WritableMap in project react-native-fcm by evollu.
the class FIRMessagingModule method parseIntent.
private WritableMap parseIntent(Intent intent) {
WritableMap params;
Bundle extras = intent.getExtras();
if (extras != null) {
try {
params = Arguments.fromBundle(extras);
} catch (Exception e) {
Log.e(TAG, e.getMessage());
params = Arguments.createMap();
}
} else {
params = Arguments.createMap();
}
WritableMap fcm = Arguments.createMap();
fcm.putString("action", intent.getAction());
params.putMap("fcm", fcm);
params.putInt("opened_from_tray", 1);
return params;
}
use of com.facebook.react.bridge.WritableMap in project react-native-fcm by evollu.
the class ReactNativeJson method convertJsonToMap.
public static WritableMap convertJsonToMap(JSONObject jsonObject) throws JSONException {
WritableMap map = new WritableNativeMap();
Iterator<String> iterator = jsonObject.keys();
while (iterator.hasNext()) {
String key = iterator.next();
Object value = jsonObject.get(key);
if (value instanceof JSONObject) {
map.putMap(key, convertJsonToMap((JSONObject) value));
} else if (value instanceof JSONArray) {
map.putArray(key, convertJsonToArray((JSONArray) value));
} else if (value instanceof Boolean) {
map.putBoolean(key, (Boolean) value);
} else if (value instanceof Integer) {
map.putInt(key, (Integer) value);
} else if (value instanceof Double) {
map.putDouble(key, (Double) value);
} else if (value instanceof String) {
map.putString(key, (String) value);
} else {
map.putString(key, value.toString());
}
}
return map;
}
use of com.facebook.react.bridge.WritableMap in project react-native-fbsdk by facebook.
the class RCTLoginButton method init.
public void init() {
mAccessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken) {
if (currentAccessToken == null) {
WritableMap event = Arguments.createMap();
event.putString("type", "logoutFinished");
ReactContext context = (ReactContext) getContext();
context.getJSModule(RCTEventEmitter.class).receiveEvent(getId(), "topChange", event);
}
}
};
this.registerCallback(mCallbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
WritableMap event = Arguments.createMap();
event.putString("type", "loginFinished");
event.putString("error", null);
WritableMap result = Arguments.createMap();
result.putBoolean("isCancelled", false);
result.putArray("grantedPermissions", Arguments.fromJavaArgs(setToStringArray(loginResult.getRecentlyGrantedPermissions())));
result.putArray("declinedPermissions", Arguments.fromJavaArgs(setToStringArray(loginResult.getRecentlyDeniedPermissions())));
event.putMap("result", result);
ReactContext context = (ReactContext) getContext();
context.getJSModule(RCTEventEmitter.class).receiveEvent(getId(), "topChange", event);
}
@Override
public void onError(FacebookException error) {
WritableMap event = Arguments.createMap();
event.putString("type", "loginFinished");
event.putString("error", error.toString());
WritableMap result = Arguments.createMap();
result.putBoolean("isCancelled", false);
event.putMap("result", result);
ReactContext context = (ReactContext) getContext();
context.getJSModule(RCTEventEmitter.class).receiveEvent(getId(), "topChange", event);
}
@Override
public void onCancel() {
WritableMap event = Arguments.createMap();
event.putString("type", "loginFinished");
event.putString("error", null);
WritableMap result = Arguments.createMap();
result.putBoolean("isCancelled", true);
event.putMap("result", result);
ReactContext context = (ReactContext) getContext();
context.getJSModule(RCTEventEmitter.class).receiveEvent(getId(), "topChange", event);
}
});
}
use of com.facebook.react.bridge.WritableMap in project react-native-fbsdk by facebook.
the class FBGraphRequestModule method convertJSONObject.
private WritableMap convertJSONObject(JSONObject object) {
WritableMap result = Arguments.createMap();
Iterator<String> keyIterator = object.keys();
while (keyIterator.hasNext()) {
String key = keyIterator.next();
Object value;
try {
value = object.get(key);
} catch (JSONException e) {
return result;
}
if (value instanceof JSONObject) {
result.putMap(key, convertJSONObject((JSONObject) value));
} else if (value instanceof JSONArray) {
result.putArray(key, convertJSONArray((JSONArray) value));
} else if (value instanceof String) {
result.putString(key, (String) value);
} else if (value instanceof Integer) {
result.putInt(key, (int) value);
} else if (value instanceof Boolean) {
result.putBoolean(key, (Boolean) value);
} else if (value instanceof Double) {
result.putDouble(key, (Double) value);
}
}
return result;
}
Aggregations