Java Code Examples for com.facebook.react.bridge.WritableNativeMap#putString()
The following examples show how to use
com.facebook.react.bridge.WritableNativeMap#putString() .
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: CatalystNativeJavaToJSArgumentsTestCase.java From react-native-GPay with MIT License | 6 votes |
public void testMapWithNullStringValue() { WritableNativeMap map = new WritableNativeMap(); map.putString("string", null); map.putArray("array", null); map.putMap("map", null); WritableNativeArray array = new WritableNativeArray(); array.pushString(null); array.pushArray(null); array.pushMap(null); mInstance.getJSModule(TestJavaToJSArgumentsModule.class) .receiveMapAndArrayWithNullValues(map, array); waitForBridgeAndUIIdle(); mAssertModule.verifyAssertsAndReset(); }
Example 2
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
@ReactMethod public void selectStarOrBlackContacts(String pkey, Callback callback) { List<Nick> list = IMDatabaseManager.getInstance().selectStarOrBlackContactsAsNick(pkey); WritableNativeArray array = new WritableNativeArray(); for (int i = 0; i < list.size(); i++) { Nick nick = list.get(i); WritableNativeMap map = new WritableNativeMap(); map.putString("Name", TextUtils.isEmpty(nick.getName()) ? nick.getXmppId() : nick.getName()); map.putString("XmppId", nick.getXmppId()); map.putString("HeaderUri", TextUtils.isEmpty(nick.getHeaderSrc()) ? defaultUserImage : nick.getHeaderSrc()); array.pushMap(map); } WritableNativeMap re = new WritableNativeMap(); re.putArray("data", array); callback.invoke(re); }
Example 3
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
@ReactMethod public void selectUserNotInStartContacts(String key, Callback callback) { List<Nick> list = IMDatabaseManager.getInstance().selectUserNotInStartContacts(key); WritableNativeArray array = new WritableNativeArray(); for (int i = 0; i < list.size(); i++) { Nick nick = list.get(i); WritableNativeMap map = new WritableNativeMap(); map.putString("Name", TextUtils.isEmpty(nick.getName()) ? nick.getXmppId() : nick.getName()); map.putString("XmppId", nick.getXmppId()); map.putString("HeaderUri", TextUtils.isEmpty(nick.getHeaderSrc()) ? defaultUserImage : nick.getHeaderSrc()); array.pushMap(map); } WritableNativeMap re = new WritableNativeMap(); re.putArray("users", array); callback.invoke(re); }
Example 4
Source File: NotificationListener.java From things-notification with Apache License 2.0 | 6 votes |
@Override public void onNotificationPosted(StatusBarNotification sbn) { Log.d(TAG, "Notification received: "+sbn.getPackageName()+":"+sbn.getNotification().tickerText); if (sbn.getNotification().tickerText == null) { return; } WritableNativeMap params = new WritableNativeMap(); params.putString("text", sbn.getNotification().tickerText.toString()); String app = sbn.getPackageName(); if (app.equals(NotificationModule.smsApp)) { params.putString("app", "sms"); } else { params.putString("app", app); } NotificationModule.sendEvent("notificationReceived", params); }
Example 5
Source File: CatalystNativeJavaToJSArgumentsTestCase.java From react-native-GPay with MIT License | 6 votes |
public void testStringWithMultibyteUTF8Characters() { TestJavaToJSArgumentsModule jsModule = mInstance.getJSModule(TestJavaToJSArgumentsModule.class); WritableNativeMap map = new WritableNativeMap(); map.putString("two-bytes", "\u00A2"); map.putString("three-bytes", "\u20AC"); map.putString("four-bytes", "\uD83D\uDE1C"); map.putString( "mixed", "\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107"); jsModule.receiveMapWithMultibyteUTF8CharacterString(map); waitForBridgeAndUIIdle(); mAssertModule.verifyAssertsAndReset(); WritableArray array = new WritableNativeArray(); array.pushString("\u00A2"); array.pushString("\u20AC"); array.pushString("\uD83D\uDE1C"); array.pushString( "\u017C\u00F3\u0142\u0107 g\u0119\u015Bl\u0105 \u6211 \uD83D\uDE0E ja\u017A\u0107"); jsModule.receiveArrayWithMultibyteUTF8CharacterString(array); waitForBridgeAndUIIdle(); mAssertModule.verifyAssertsAndReset(); }
Example 6
Source File: AccountManagerModule.java From react-native-account-manager with MIT License | 6 votes |
@ReactMethod public void getAccountsByType (String accountType, Promise promise) { manager = AccountManager.get(_reactContext); Account[] account_list = manager.getAccountsByType(accountType); WritableNativeArray result = new WritableNativeArray(); for(Account account: account_list) { Integer index = indexForAccount(account); WritableNativeMap account_object = new WritableNativeMap(); account_object.putInt("_index", (int)index); account_object.putString("name", account.name); account_object.putString("type", account.type); result.pushMap(account_object); } promise.resolve(result); }
Example 7
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
@ReactMethod public void searchFilesByXmppId(String xmppid, Callback callback) { WritableNativeArray writableNativeArray = new WritableNativeArray(); JSONArray jsonArray = ConnectionUtil.getInstance().searchFilesMsgByXmppid(xmppid); for (int i = 0; i < jsonArray.length(); i++) { try { JSONObject jsonObject = jsonArray.getJSONObject(i); WritableNativeMap writableNativeMap = new WritableNativeMap(); writableNativeMap.putString("from", jsonObject.optString("from")); writableNativeMap.putString("content", jsonObject.optString("content")); writableNativeMap.putString("time", jsonObject.optString("time")); writableNativeMap.putString("name", jsonObject.optString("name")); writableNativeMap.putString("headerSrc", jsonObject.optString("headerSrc")); writableNativeArray.pushMap(writableNativeMap); } catch (JSONException e) { e.printStackTrace(); } } if (callback != null) { WritableNativeMap map = new WritableNativeMap(); map.putArray("files", writableNativeArray); callback.invoke(map); } }
Example 8
Source File: RCTSodiumModule.java From react-native-sodium with ISC License | 6 votes |
@ReactMethod public void crypto_sign_keypair(final Promise p) { try { byte[] pk = new byte[Sodium.crypto_sign_publickeybytes()]; byte[] sk = new byte[Sodium.crypto_sign_secretkeybytes()]; int result = Sodium.crypto_sign_keypair(pk, sk); if (result != 0) p.reject(ESODIUM, ERR_FAILURE); else { WritableNativeMap map = new WritableNativeMap(); map.putString("pk",Base64.encodeToString(pk,Base64.NO_WRAP)); map.putString("sk",Base64.encodeToString(sk,Base64.NO_WRAP)); p.resolve(map); } } catch(Throwable t) { p.reject(ESODIUM, ERR_FAILURE, t); } }
Example 9
Source File: SmsReceiver.java From react-native-android-sms-listener with MIT License | 6 votes |
private void receiveMessage(SmsMessage message) { if (mContext == null) { return; } if (! mContext.hasActiveCatalystInstance()) { return; } Log.d( SmsListenerPackage.TAG, String.format("%s: %s", message.getOriginatingAddress(), message.getMessageBody()) ); WritableNativeMap receivedMessage = new WritableNativeMap(); receivedMessage.putString("originatingAddress", message.getOriginatingAddress()); receivedMessage.putString("body", message.getMessageBody()); mContext .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(EVENT, receivedMessage); }
Example 10
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
/** * 根据好友 * * @param params * @param callback */ @ReactMethod public void selectFriendsForGroupAdd(ReadableMap params, Callback callback) { String groupId = params.getString("groupId"); List<Nick> userList = ConnectionUtil.getInstance().selectFriendsForGroupAdd(groupId); WritableNativeArray array = new WritableNativeArray(); for (int i = 0; i < userList.size(); i++) { Nick nick = userList.get(i); WritableNativeMap map = new WritableNativeMap(); map.putString("name", TextUtils.isEmpty(nick.getName()) ? nick.getXmppId() : nick.getName()); map.putString("xmppId", nick.getXmppId()); map.putString("headerUri", TextUtils.isEmpty(nick.getHeaderSrc()) ? defaultUserImage : nick.getHeaderSrc()); map.putString("desc",nick.getDescInfo()); map.putBoolean("friend", true); array.pushMap(map); } WritableNativeMap re = new WritableNativeMap(); re.putArray("UserList", array); re.putBoolean("ok", true); callback.invoke(re); }
Example 11
Source File: CatalystNativeJavaToJSArgumentsTestCase.java From react-native-GPay with MIT License | 5 votes |
public void testArrayWithMaps() { WritableNativeMap m1 = new WritableNativeMap(); WritableNativeMap m2 = new WritableNativeMap(); m1.putString("m1k1", "m1v1"); m1.putString("m1k2", "m1v2"); m2.putString("m2k1", "m2v1"); WritableNativeArray array = new WritableNativeArray(); array.pushMap(m1); array.pushMap(m2); mInstance.getJSModule(TestJavaToJSArgumentsModule.class).receiveArrayWithMaps(array); waitForBridgeAndUIIdle(); mAssertModule.verifyAssertsAndReset(); }
Example 12
Source File: SmsBroadcastReceiver.java From react-native-sms-retriever with MIT License | 5 votes |
private void emitJSEvent(@NonNull final String key, final String message) { if (mContext == null) { return; } if (!mContext.hasActiveCatalystInstance()) { return; } WritableNativeMap map = new WritableNativeMap(); map.putString(key, message); mContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(SMS_EVENT, map); }
Example 13
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
public void getGroupMemberFromDB(String groupId, Callback callback) { List<GroupMember> groupMemberList = ConnectionUtil.getInstance().SelectGroupMemberByGroupId(groupId); if (ListUtil.isEmpty(groupMemberList)) { return; } WritableNativeArray array = new WritableNativeArray(); int per = 2; for (int i = 0; i < groupMemberList.size(); i++) { GroupMember gm = groupMemberList.get(i); WritableNativeMap map = new WritableNativeMap(); String affiliation = gm.getAffiliation(); map.putString("affiliation", affiliation); map.putString("headerUri", TextUtils.isEmpty(gm.getHeaderSrc()) ? defaultUserImage : gm.getHeaderSrc()); String xmppid = gm.getMemberId(); if (CurrentPreference.getInstance().getPreferenceUserId().equals(xmppid)) { if (!TextUtils.isEmpty(affiliation)) { per = Integer.parseInt(affiliation); } } map.putString("xmppjid", xmppid); map.putString("jid", gm.getGroupId()); map.putString("name", gm.getName()); array.pushMap(map); } WritableNativeMap re = new WritableNativeMap(); re.putArray("GroupMembers", array); re.putBoolean("ok", true); re.putString("GroupId", groupId); re.putInt("permissions", per); if (callback != null) { callback.invoke(re); } else { sendEvent("updateGroupMember", re); } }
Example 14
Source File: JSONEncoder.java From react-native-google-fitness with MIT License | 5 votes |
private static WritableMap convertDataSource(DataSource ds) { WritableNativeMap map = new WritableNativeMap(); map.putInt("type", ds.getType()); map.putString("name", ds.getName()); map.putString("appPackageName", ds.getAppPackageName()); map.putString("streamIdentifier", ds.getStreamIdentifier()); return map; }
Example 15
Source File: CatalystNativeJavaToJSArgumentsTestCase.java From react-native-GPay with MIT License | 5 votes |
public void testNestedMap() { WritableNativeMap map = new WritableNativeMap(); WritableNativeMap nestedMap = new WritableNativeMap(); nestedMap.putString("animals", "foxes"); map.putMap("nestedMap", nestedMap); mInstance.getJSModule(TestJavaToJSArgumentsModule.class).receiveNestedMap(map); waitForBridgeAndUIIdle(); mAssertModule.verifyAssertsAndReset(); }
Example 16
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
public WritableNativeArray parseUserMedalData(List<MedalsInfo> list) { WritableNativeArray array = new WritableNativeArray(); for (int i = 0; i < list.size(); i++) { MedalsInfo medalsInfo = list.get(i); WritableNativeMap item = new WritableNativeMap(); item.putString("UserId", medalsInfo.getXmppId()); item.putString("type", medalsInfo.getType()); item.putString("url", medalsInfo.getUrl()); item.putString("desc", medalsInfo.getDesc()); item.putString("LastUpdateTime", medalsInfo.getUpt()); array.pushMap(item); } return array; }
Example 17
Source File: TodoEventHandler.java From imsdk-android with MIT License | 5 votes |
@ReactMethod public void openWebPage( String page, boolean showNavBar, Callback callback) { NativeApi.openQtalkWebViewForUrl(page, showNavBar); WritableNativeMap map = new WritableNativeMap(); map.putBoolean("is_ok", true); map.putString("errorMsg", ""); callback.invoke(map); }
Example 18
Source File: ReactOrientationControllerModule.java From react-native-orientation-controller with MIT License | 5 votes |
public WritableNativeMap getDataMap(){ WritableNativeMap data = new WritableNativeMap(); data.putString("deviceOrientation",getDeviceOrientationAsString()); data.putString("applicationOrientation", getApplicationOrientation()); data.putString("device", getModel()); final int width = getDimension()[0]; final int height = getDimension()[1]; data.putMap("size",new WritableNativeMap(){{putInt("width",width);putInt("height",height);}}); return data; }
Example 19
Source File: ReactOrientationListenerModule.java From react-native-orientation-listener with MIT License | 5 votes |
public ReactOrientationListenerModule(ReactApplicationContext reactContext) { super(reactContext); this.reactContext = reactContext; final ReactApplicationContext thisContext = reactContext; mOrientationListener = new OrientationEventListener(reactContext, SensorManager.SENSOR_DELAY_NORMAL) { @Override public void onOrientationChanged(int orientation) { WritableNativeMap params = new WritableNativeMap(); String orientationValue = ""; if(orientation == 0) { orientationValue = "PORTRAIT"; } else { orientationValue = "LANDSCAPE"; } params.putString("orientation", orientationValue); params.putString("device", getDeviceName()); if (thisContext.hasActiveCatalystInstance()) { thisContext .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit("orientationDidChange", params); } } }; if (mOrientationListener.canDetectOrientation() == true) { mOrientationListener.enable(); } else { mOrientationListener.disable(); } }
Example 20
Source File: QimRNBModule.java From imsdk-android with MIT License | 4 votes |
@ReactMethod public void appConfig(Callback callback) { try { WritableNativeMap map = new WritableNativeMap(); map.putString("userId", CurrentPreference.getInstance().getUserid()); map.putString("clientIp", "192.168.0.1"); map.putString("domain", QtalkNavicationService.getInstance().getXmppdomain()); // map.putString("token", CurrentPreference.getInstance().getToken()); // map.putString("q_auth", CurrentPreference.getInstance().getVerifyKey() == null ? "404" : CurrentPreference.getInstance().getVerifyKey()); map.putString("ckey", getCKey()); map.putString("httpHost", QtalkNavicationService.getInstance().getJavaUrl()); map.putString("fileUrl", QtalkNavicationService.getInstance().getInnerFiltHttpHost()); map.putString("qcAdminHost", QtalkNavicationService.getInstance().getQcadminHost()); if (QtalkNavicationService.getInstance().isShowOrganizational()) { map.putInt("showOrganizational", 1); } else { map.putInt("showOrganizational", 0); } map.putBoolean("showServiceState", CurrentPreference.getInstance().isMerchants()); map.putBoolean("isQtalk", CommonConfig.isQtalk); map.putBoolean("isShowWorkWorld", GlobalConfigManager.isQtalkPlat() && IMDatabaseManager.getInstance().SelectWorkWorldPremissions()); Object metaData = getApplicationMetaData("EASY_TRIP"); boolean isEasyTrip = metaData == null ? true : (boolean) metaData; map.putBoolean("isEasyTrip", isEasyTrip); map.putBoolean("isShowRedPackage", !GlobalConfigManager.isStartalkPlat()); map.putBoolean("isShowGroupQRCode",true); map.putBoolean("isShowLocalQuickSearch",true); map.putBoolean("notNeedShowLeaderInfo",TextUtils.isEmpty(QtalkNavicationService.getInstance().getLeaderurl())); map.putBoolean("notNeedShowMobileInfo",TextUtils.isEmpty(QtalkNavicationService.getInstance().getMobileurl())); map.putBoolean("notNeedShowEmailInfo",TextUtils.isEmpty(QtalkNavicationService.getInstance().getEmail())); map.putBoolean("isToCManager",DataUtils.getInstance(CommonConfig.globalContext).getPreferences(Constants.Preferences.isAdminFlag + "_" + QtalkNavicationService.getInstance().getXmppdomain(),false)); if(GlobalConfigManager.isQtalkPlat()){ map.putInt("nativeAppType", 2); }else if(GlobalConfigManager.isQchatPlat()){ map.putInt("nativeAppType", 1); }else if(GlobalConfigManager.isStartalkPlat()){ map.putInt("nativeAppType", 0); } // map.putDouble("timestamp", System.currentTimeMillis()); callback.invoke(map); } catch (Exception e) { e.printStackTrace(); } }