com.facebook.react.bridge.WritableNativeMap Java Examples
The following examples show how to use
com.facebook.react.bridge.WritableNativeMap.
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: CameraRollModule.java From rn-camera-roll with MIT License | 7 votes |
@ReactMethod public void getCameraImages(ReadableMap data, Callback onSuccess) { WritableNativeArray result = new WritableNativeArray(); for(CameraImage imageData : CameraImagesManager.getCameraImages(this.context, data.getInt("first"), data.hasKey("after") ? data.getString("after") : "")) { WritableMap imageDataMap = new WritableNativeMap(); imageDataMap.putString("uri", imageData.getLocalPath()); imageDataMap.putInt("width", imageData.getWidth()); imageDataMap.putInt("height", imageData.getHeight()); imageDataMap.putInt("orientation", imageData.getOrientation()); imageDataMap.putString("timestamp", Long.toString(imageData.getTimestamp())); result.pushMap(imageDataMap); } onSuccess.invoke(result); }
Example #2
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
/** * 获取用户通知是否显示详情 * * @param callback */ @ReactMethod public void getNotifyPushDetailsState(Callback callback) { // CurrentPreference.ProFile proFile = CurrentPreference.getInstance().getProFile(); // WritableMap map = new WritableNativeMap(); //// WritableMap params = new WritableNativeMap(); //// params.putBoolean("getNotifySoundState",proFile.isTurnOnMsgSound()); // map.putBoolean("state", proFile.isShowContentPush()); // callback.invoke(map); WritableMap map = new WritableNativeMap(); boolean state = ConnectionUtil.getInstance().getPushStateBy(PushSettinsStatus.SHOW_CONTENT); map.putBoolean("state", state); callback.invoke(map); }
Example #3
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 #4
Source File: OtpBroadcastReceiver.java From react-native-otp-verify with MIT License | 6 votes |
private void receiveMessage(String message) { if (mContext == null) { return; } if (!mContext.hasActiveCatalystInstance()) { return; } WritableNativeMap receivedMessage = new WritableNativeMap(); receivedMessage.putString("message", message); mContext .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) .emit(EVENT, message); }
Example #5
Source File: QtalkPlugin.java From imsdk-android with MIT License | 6 votes |
/** * 获取用户信息回传 * * @param callback */ @ReactMethod public void getUserInfo(Callback callback) { 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 (!("ejabhost1".equals(QtalkNavicationService.getInstance().getXmppdomain()))) { // map.putInt("showOrganizational", 1); // } else { // map.putInt("showOrganizational", 0); // } map.putBoolean("showServiceState", CurrentPreference.getInstance().isMerchants()); map.putBoolean("isQtalk", CommonConfig.isQtalk); // map.putDouble("timestamp", System.currentTimeMillis()); callback.invoke(map); }
Example #6
Source File: RealtimeMessagingAndroid.java From RCTRealtimeMessagingAndroid with MIT License | 6 votes |
@ReactMethod public void subscribeWithOptions(ReadableMap options, Integer id){ Map newOptions = recursivelyDeconstructReadableMap(options); OrtcClient client = null; if (queue.containsKey(id)) { client = queue.get(id); client.subscribeWithOptions(newOptions, new OnMessageWithOptions() { @Override public void run(OrtcClient sender, Map msgOptions) { String thisId = "" + RealtimeMessagingAndroid.getKeyByValue(queue, sender); WritableMap params = new WritableNativeMap(); params.putString("channel", (String)msgOptions.get("channel")); params.putString("message", (String)msgOptions.get("message")); if (msgOptions.containsKey("filtered")) params.putBoolean("filtered", (Boolean) msgOptions.get("filtered")); if (msgOptions.containsKey("seqId")) params.putString("seqId", (String) msgOptions.get("seqId")); sendEvent(getReactApplicationContext(), thisId + "-onMessageWithOptions", params); } }); } }
Example #7
Source File: RNInstabugReactnativeModule.java From Instabug-React-Native with MIT License | 6 votes |
private 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; }
Example #8
Source File: CustomTwilioVideoView.java From react-native-twilio-video-webrtc with MIT License | 6 votes |
private void addParticipant(Room room, RemoteParticipant remoteParticipant) { WritableMap event = new WritableNativeMap(); event.putString("roomName", room.getName()); event.putString("roomSid", room.getSid()); event.putMap("participant", buildParticipant(remoteParticipant)); pushEvent(this, ON_PARTICIPANT_CONNECTED, event); /* * Start listening for participant media events */ remoteParticipant.setListener(mediaListener()); for (final RemoteDataTrackPublication remoteDataTrackPublication : remoteParticipant.getRemoteDataTracks()) { /* * Data track messages are received on the thread that calls setListener. Post the * invocation of setting the listener onto our dedicated data track message thread. */ if (remoteDataTrackPublication.isTrackSubscribed()) { dataTrackMessageThreadHandler.post(() -> addRemoteDataTrack(remoteParticipant, remoteDataTrackPublication.getRemoteDataTrack())); } } }
Example #9
Source File: RCTCameraModule.java From react-native-camera-face-detector with MIT License | 6 votes |
private void resolveImage(final File imageFile, final Promise promise, boolean addToMediaStore) { final WritableMap response = new WritableNativeMap(); response.putString("path", Uri.fromFile(imageFile).toString()); if(addToMediaStore) { // borrowed from react-native CameraRollManager, it finds and returns the 'internal' // representation of the image uri that was just saved. // e.g. content://media/external/images/media/123 MediaScannerConnection.scanFile( _reactContext, new String[]{imageFile.getAbsolutePath()}, null, new MediaScannerConnection.OnScanCompletedListener() { @Override public void onScanCompleted(String path, Uri uri) { if (uri != null) { response.putString("mediaUri", uri.toString()); } promise.resolve(response); } }); } else { promise.resolve(response); } }
Example #10
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 #11
Source File: NotificationModule.java From things-notification with Apache License 2.0 | 6 votes |
@ReactMethod public void getInstalledApps(Promise promise) { WritableNativeArray params = new WritableNativeArray(); PackageManager pm = reactContext.getPackageManager(); List<ApplicationInfo> apps = pm.getInstalledApplications(0); for(ApplicationInfo app : apps) { if ((pm.getLaunchIntentForPackage(app.packageName) != null) && !thisApp.equals(app.packageName)) { WritableNativeMap param = new WritableNativeMap(); String appName = app.loadLabel(pm).toString(); String appPackage = app.packageName; String appIcon = saveIcon(appPackage, app.loadIcon(pm)); //Log.d(TAG, "name: "+appName); //Log.d(TAG, "app: "+appPackage); //Log.d(TAG, "icon: "+appIcon); param.putString("name", appName); param.putString("app", appPackage); param.putString("icon", appIcon); //sendEvent("installedApps", param); params.pushMap(param); } } promise.resolve(params); }
Example #12
Source File: QtalkPlugin.java From imsdk-android with MIT License | 6 votes |
/** * 进行网络请求 */ @ReactMethod public void getSearchInfo(String url, ReadableMap params, ReadableMap cookie, Callback callback1, final Callback callback2) { final WritableNativeMap map = new WritableNativeMap(); HttpUtil.PostUrl(url, params.toHashMap(), cookie.toHashMap(), new ProtocolCallback.UnitCallback<String>() { @Override public void onCompleted(String s) { map.putBoolean("isOk", true); map.putString("responseJson", s); callback2.invoke(map); } @Override public void onFailure(String errMsg) { map.putBoolean("isOk", false); map.putString("message", errMsg); callback2.invoke(map); } }); // }
Example #13
Source File: DatePickerDialogTestCase.java From react-native-GPay with MIT License | 6 votes |
public void testCallback() throws Throwable { final WritableMap options = new WritableNativeMap(); options.putDouble("date", getDateInMillis(2020, 5, 6)); final DialogFragment datePickerFragment = showDialog(options); runTestOnUiThread( new Runnable() { @Override public void run() { ((DatePickerDialog) datePickerFragment.getDialog()) .getButton(DialogInterface.BUTTON_POSITIVE).performClick(); } }); getInstrumentation().waitForIdleSync(); waitForBridgeAndUIIdle(); assertEquals(0, mRecordingModule.getErrors()); assertEquals(1, mRecordingModule.getDates().size()); assertEquals(2020, (int) mRecordingModule.getDates().get(0)[0]); assertEquals(5, (int) mRecordingModule.getDates().get(0)[1]); assertEquals(6, (int) mRecordingModule.getDates().get(0)[2]); }
Example #14
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
/** * 查询不在星标联系人的好友 * * @param callback */ @ReactMethod public void selectFriendsNotInStarContacts(Callback callback) { List<Nick> list = IMDatabaseManager.getInstance().selectFriendsNotInStarContacts(); 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("contacts", array); callback.invoke(re); }
Example #15
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
/** * 同步群置顶信息 * * @param groupId * @param callback */ @ReactMethod public void syncGroupStickyState(String groupId, Callback callback) { // RecentConversation rc = new RecentConversation(); // rc.setId(groupId); // rc.setRealUser(groupId); // rc = ConnectionUtil.getInstance().SelectConversationByRC(rc); UserConfigData userConfigData = new UserConfigData(); userConfigData.setSubkey(groupId + "<>" + groupId); userConfigData.setKey(CacheDataType.kStickJidDic); UserConfigData ucd = ConnectionUtil.getInstance().selectUserConfigValueForKey(userConfigData); // recentConvDataModel.selectRecentConvById(rc); // panelView.setTop(rc.getTop()>0); WritableNativeMap map = new WritableNativeMap(); map.putBoolean("state", ucd != null); callback.invoke(map); }
Example #16
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
/** * 获取群信息 * * @param groupId * @param callback */ @ReactMethod public void getGroupInfo(final String groupId, final Callback callback) { // Nick mucNick = ConnectionUtil.getInstance().getMucNickById(groupId); ConnectionUtil.getInstance().getMucCard(groupId, new IMLogicManager.NickCallBack() { @Override public void onNickCallBack(Nick nick) { WritableNativeMap map = new WritableNativeMap(); // WritableNativeArray array = new WritableNativeArray(); map.putString("GroupId", nick.getGroupId()); map.putString("Name", nick.getName()); map.putString("HeaderSrc", nick.getHeaderSrc()); map.putString("Topic", nick.getTopic()); map.putString("Introduce", nick.getIntroduce()); WritableNativeMap re = new WritableNativeMap(); re.putBoolean("ok", true); re.putMap("GroupInfo", map); callback.invoke(re); } }, true, true); }
Example #17
Source File: RealtimeMessagingAndroid.java From RCTRealtimeMessagingAndroid with MIT License | 6 votes |
@ReactMethod public void subscribeWithFilter(String channel, Boolean subscribeOnReconnect, String filter, Integer id){ OrtcClient client = null; if (queue.containsKey(id)) { client = queue.get(id); client.subscribeWithFilter(channel, subscribeOnReconnect, filter, new OnMessageWithFilter() { @Override public void run(OrtcClient ortcClient, String s, boolean filtered, String s1) { WritableMap params = new WritableNativeMap(); params.putString("channel", s); params.putString("message", s1); params.putBoolean("filtered", filtered); String thisId = "" + RealtimeMessagingAndroid.getKeyByValue(queue, ortcClient); sendEvent(getReactApplicationContext(), thisId + "-onMessageWithFilter", params); } }); } }
Example #18
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 #19
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
@ReactMethod public void selectMemberFromGroup(ReadableMap params, Callback callback) { String groupId = params.getString("groupId"); String searchText = params.getString("searchText"); List<Nick> userList = ConnectionUtil.getInstance().selectMemberFromGroup(groupId, searchText); 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()); array.pushMap(map); } WritableNativeMap re = new WritableNativeMap(); re.putArray("UserList", array); re.putBoolean("ok", true); callback.invoke(re); }
Example #20
Source File: CallListener.java From things-notification with Apache License 2.0 | 6 votes |
@Override public void onReceive(final Context context, Intent intent) { TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); telephony.listen(new PhoneStateListener() { @Override public void onCallStateChanged(int state, String incomingNumber) { Log.d(TAG, "Call received: "+incomingNumber); if (!incomingNumber.isEmpty()) { WritableNativeMap params = new WritableNativeMap(); params.putString("app", "phone"); params.putString("text", incomingNumber); NotificationModule.sendEvent("notificationReceived", params); } } }, PhoneStateListener.LISTEN_CALL_STATE); }
Example #21
Source File: FusedLocationModule.java From react-native-fused-location with MIT License | 6 votes |
private WritableMap convertLocationToJSON(Location l) { WritableMap params = new WritableNativeMap(); params.putDouble("latitude", l.getLatitude()); params.putDouble("longitude", l.getLongitude()); params.putDouble("accuracy", l.getAccuracy()); params.putDouble("altitude", l.getAltitude()); params.putDouble("bearing", l.getBearing()); params.putString("provider", l.getProvider()); params.putDouble("speed", l.getSpeed()); params.putString("timestamp", Long.toString(l.getTime())); boolean isMock; if (android.os.Build.VERSION.SDK_INT >= 18) { isMock = l.isFromMockProvider(); } else { isMock = !Settings.Secure.getString(getReactApplicationContext().getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION).equals("0"); } params.putBoolean("mocked", isMock); return params; }
Example #22
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
@ReactMethod public void selectGroupMemberForKick(ReadableMap params, Callback callback) { String groupId = params.getString("groupId"); List<Nick> userList = ConnectionUtil.getInstance().selectGroupMemberForKick(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()); array.pushMap(map); } WritableNativeMap re = new WritableNativeMap(); re.putArray("UserList", array); re.putBoolean("ok", true); callback.invoke(re); }
Example #23
Source File: ReactNativeJson.java From react-native-couchbase-lite with MIT License | 6 votes |
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; }
Example #24
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
/** * 发送反馈意见 * * @param params */ @ReactMethod public void sendAdviceMessage(ReadableMap params, final Callback callback) { String adviceMsg = params.getString("adviceText"); boolean isUploadDb = params.getBoolean("logSelected"); Logger.i("RNModule:发送反馈意见+++:" + adviceMsg); try { IMDatabaseManager.getInstance().manualCheckPoint();//手动checkpoint数据库 }catch (Exception e){ Logger.e("manualCheckPoint exception:" + e.getLocalizedMessage()); } // FeedBackServcie.runFeedBackServcieService(CommonConfig.globalContext, new String[]{adviceMsg}); IMNotificaitonCenter.getInstance().postMainThreadNotificationName(QtalkEvent.FEED_BACK, new String[]{adviceMsg},true,isUploadDb); WritableNativeMap map = new WritableNativeMap(); map.putBoolean("ok", true); callback.invoke(map); saveRNActLog("Suggestions", "建议反馈", "我的页"); }
Example #25
Source File: TransMissonMoudle.java From ReactNative-AndAndroid with MIT License | 6 votes |
@ReactMethod public void getTime() { new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } String time = getTimeMillis(); WritableMap writableMap = new WritableNativeMap(); writableMap.putString("key", time); sendTransMisson(mReactContext, "EventName", writableMap); } }).start(); }
Example #26
Source File: AMapViewManager.java From react-native-amap with MIT License | 6 votes |
public WritableMap makeClickEventData(LatLng point) { WritableMap event = new WritableNativeMap(); WritableMap coordinate = new WritableNativeMap(); coordinate.putDouble("latitude", point.latitude); coordinate.putDouble("longitude", point.longitude); event.putMap("coordinate", coordinate); Projection projection = map.getProjection(); Point screenPoint = projection.toScreenLocation(point); WritableMap position = new WritableNativeMap(); position.putDouble("x", screenPoint.x); position.putDouble("y", screenPoint.y); event.putMap("position", position); return event; }
Example #27
Source File: ReactNativeJson.java From react-native-fcm with MIT License | 6 votes |
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; }
Example #28
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
/** * 更新通知声音状态 * * @param notifySoundState * @param callback */ @ReactMethod public void updateNotifySoundState(boolean notifySoundState, final Callback callback) { // boolean state = notifySoundState; // CurrentPreference.getInstance().setTurnOnMsgSound(state); // IMDatabaseManager.getInstance().updateConfig(); // WritableMap map = new WritableNativeMap(); // map.putBoolean("ok", true); // callback.invoke(map); final boolean state = notifySoundState; final WritableMap map = new WritableNativeMap(); HttpUtil.setPushMsgSettings(PushSettinsStatus.SOUND_INAPP, state ? 1 : 0, new ProtocolCallback.UnitCallback<Boolean>() { @Override public void onCompleted(Boolean aBoolean) { ConnectionUtil.getInstance().setPushState(PushSettinsStatus.SOUND_INAPP, state ? 1 : 0); com.qunar.im.protobuf.common.CurrentPreference.getInstance().setTurnOnMsgSound(ConnectionUtil.getInstance().getPushStateBy(PushSettinsStatus.SOUND_INAPP)); map.putBoolean("ok", true); callback.invoke(map); } @Override public void onFailure(String errMsg) { map.putBoolean("ok", false); callback.invoke(map); } }); }
Example #29
Source File: TransMissonMoudle.java From ReactNative-AndAndroid with MIT License | 5 votes |
/** * Promise方式 * @param name * @param promise */ @ReactMethod public void sendPromiseTime(String name, Promise promise) { // 1.处理业务逻辑... String result = "处理结果:" + name; Log.e("---",result); // 2.回调RN,即将处理结果返回给RN WritableMap writableMap=new WritableNativeMap(); writableMap.putString("age","20"); writableMap.putString("time",getTimeMillis()); promise.resolve(writableMap); }
Example #30
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
/** * 获取用户通知震动状态 * * @param callback */ @ReactMethod public void getNotifyVibrationState(Callback callback) { // CurrentPreference.ProFile proFile = CurrentPreference.getInstance().getProFile(); // WritableMap map = new WritableNativeMap(); //// WritableMap params = new WritableNativeMap(); //// params.putBoolean("getNotifySoundState",proFile.isTurnOnMsgSound()); // map.putBoolean("state", proFile.isTurnOnMsgShock()); // callback.invoke(map); WritableMap map = new WritableNativeMap(); boolean state = ConnectionUtil.getInstance().getPushStateBy(PushSettinsStatus.VIBRATE_INAPP); map.putBoolean("state", state); callback.invoke(map); }