Java Code Examples for com.facebook.react.bridge.WritableNativeMap#putBoolean()
The following examples show how to use
com.facebook.react.bridge.WritableNativeMap#putBoolean() .
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: 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 2
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
/** * 获取日历功能城市列表 * * @param callback */ @ReactMethod public void getTripCity(Callback callback) { List<CityLocal.DataBean> list = IMDatabaseManager.getInstance().getCityList(); WritableNativeMap map = new WritableNativeMap(); WritableNativeArray array = new WritableNativeArray(); for (int i = 0; i < list.size(); i++) { WritableNativeMap item = new WritableNativeMap(); item.putString("CityName", list.get(i).getCityName()); item.putInt("CityId", list.get(i).getId()); array.pushMap(item); } map.putBoolean("ok", true); map.putArray("cityList", array); callback.invoke(map); }
Example 3
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
/** * 获取日历功能区域列表 * * @param callback */ @ReactMethod public void getTripArea(Callback callback) { List<AreaLocal.DataBean.ListBean> list = IMDatabaseManager.getInstance().getAreaList(); WritableNativeMap map = new WritableNativeMap(); WritableNativeArray array = new WritableNativeArray(); for (int i = 0; i < list.size(); i++) { WritableNativeMap item = new WritableNativeMap(); item.putString("AddressName", list.get(i).getAreaName()); item.putInt("AddressNumber", list.get(i).getAreaID()); item.putString("rStartTime", list.get(i).getMorningStarts()); item.putString("rEndTime", list.get(i).getEveningEnds()); array.pushMap(item); } map.putBoolean("ok", true); map.putArray("areaList", array); callback.invoke(map); }
Example 4
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 5
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
/** * 获取会话PushState * * @param groupId * @param callback */ @ReactMethod public void syncPushState(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); userConfigData.setKey(CacheDataType.kNoticeStickJidDic); UserConfigData ucd = ConnectionUtil.getInstance().selectUserConfigValueForKey(userConfigData); // recentConvDataModel.selectRecentConvById(rc); // panelView.setReMind(rc.getRemind()>0); WritableNativeMap map = new WritableNativeMap(); map.putBoolean("state", ucd == null); callback.invoke(map); }
Example 6
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 7
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
/** * 根据文字搜索联系人 * * @param params * @param callback */ @ReactMethod public void selectUserListByText(ReadableMap params, Callback callback) { String groupId = params.getString("groupId"); String searchText = params.getString("searchText"); List<Nick> userList = ConnectionUtil.getInstance().SelectUserListBySearchText(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()); map.putBoolean("hasInGroup", nick.isInGroup()); map.putString("desc",nick.getDescInfo()); array.pushMap(map); } WritableNativeMap re = new WritableNativeMap(); re.putArray("UserList", array); re.putBoolean("ok", true); callback.invoke(re); }
Example 8
Source File: CatalystNativeJavaToJSArgumentsTestCase.java From react-native-GPay with MIT License | 5 votes |
public void testMapWithBasicTypes() { WritableNativeMap map = new WritableNativeMap(); map.putString("stringKey", "stringValue"); map.putDouble("doubleKey", 3.14); map.putBoolean("booleanKey", true); map.putNull("nullKey"); mInstance.getJSModule(TestJavaToJSArgumentsModule.class).receiveMapWithBasicTypes(map); waitForBridgeAndUIIdle(); mAssertModule.verifyAssertsAndReset(); }
Example 9
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
/** * 判断是否为好友 * * @param userId * @param callback */ @ReactMethod public void getFriend(String userId, Callback callback) { boolean isfriend = ConnectionUtil.getInstance().isMyFriend(userId); WritableNativeMap map = new WritableNativeMap(); map.putBoolean("FriendBOOL", isfriend); callback.invoke(map); }
Example 10
Source File: ReactRootView.java From react-native-GPay with MIT License | 5 votes |
/** * Calls into JS to start the React application. Can be called multiple times with the * same rootTag, which will re-render the application from the root. */ /* package */ void runApplication() { Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "ReactRootView.runApplication"); try { if (mReactInstanceManager == null || !mIsAttachedToInstance) { return; } ReactContext reactContext = mReactInstanceManager.getCurrentReactContext(); if (reactContext == null) { return; } CatalystInstance catalystInstance = reactContext.getCatalystInstance(); WritableNativeMap appParams = new WritableNativeMap(); appParams.putDouble("rootTag", getRootViewTag()); @Nullable Bundle appProperties = getAppProperties(); if (appProperties != null) { appParams.putMap("initialProps", Arguments.fromBundle(appProperties)); } if (getUIManagerType() == FABRIC) { appParams.putBoolean("fabric", true); } mShouldLogContentAppeared = true; String jsAppModuleName = getJSModuleName(); catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams); } finally { Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); } }
Example 11
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 12
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
/** * 同步单人聊天置顶信息 * * @param params * @param callback */ @ReactMethod public void syncChatStickyState(ReadableMap params, Callback callback) { String xmppId = params.getString("xmppId"); String realJid = params.getString("realJid"); if (TextUtils.isEmpty(realJid)) { realJid = xmppId; } // RecentConversation rc = new RecentConversation(); // rc.setId(xmppId); // rc.setRealUser(realJid); // rc = ConnectionUtil.getInstance().SelectConversationByRC(rc); UserConfigData userConfigData = new UserConfigData(); userConfigData.setSubkey(xmppId + "<>" + realJid); 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); // // WritableNativeMap map = new WritableNativeMap(); // map.putBoolean("state", rc.getTop() > 0); // callback.invoke(map); }
Example 13
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
/** * 是否显示红点 * * @param callback */ @ReactMethod public void showRedView(Callback callback) { boolean show = DataUtils.getInstance(CommonConfig.globalContext).getPreferences("searchlocal", true); WritableNativeMap map = new WritableNativeMap(); map.putBoolean("show", show); // map.putString("test","aaa"); callback.invoke(map); }
Example 14
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
/** * 销毁群组 * * @param groupId * @param callback */ @ReactMethod public void destructionGroup(String groupId, Callback callback) { ConnectionUtil.getInstance().destroyGroup(groupId); WritableNativeMap map = new WritableNativeMap(); map.putBoolean("ok", true); callback.invoke(map); }
Example 15
Source File: QtalkPlugin.java From imsdk-android with MIT License | 5 votes |
private WritableNativeMap parseFound(FoundConfiguration foundConfiguration) { WritableNativeMap map = new WritableNativeMap(); WritableNativeArray groupList = new WritableNativeArray(); for (int i = 0; i < foundConfiguration.getData().size(); i++) { FoundConfiguration.DataBean data = foundConfiguration.getData().get(i); WritableNativeMap item = new WritableNativeMap(); item.putString("groupIcon", data.getGroupIcon()); item.putInt("groupId", data.getGroupId()); item.putString("groupName", data.getGroupName()); WritableNativeArray array = new WritableNativeArray(); for (int j = 0; j < data.getMembers().size(); j++) { FoundConfiguration.DataBean.MembersBean membersBean = data.getMembers().get(j); WritableNativeMap mem = new WritableNativeMap(); mem.putString("memberAction", membersBean.getMemberAction()); mem.putString("memberIcon", membersBean.getMemberIcon()); mem.putString("memberName", membersBean.getMemberName()); mem.putInt("memberId", membersBean.getMemberId()); mem.putString("Entrance", membersBean.getEntrance()); mem.putString("Bundle", membersBean.getBundle()); mem.putString("Version", membersBean.getVersion() + ""); mem.putString("BundleUrls", membersBean.getBundleUrls()); mem.putString("Module", membersBean.getModule()); mem.putString("AppType", membersBean.getAppType() + ""); mem.putBoolean("showNativeNav", membersBean.isShowNativeNav()); mem.putString("navTitle", membersBean.getNavTitle()); mem.putString("appParams", membersBean.getProperties()); array.pushMap(mem); } item.putArray("members", array); groupList.pushMap(item); } map.putBoolean("isOk", true); map.putArray("data", groupList); return map; }
Example 16
Source File: QTalkSearchCheckUpdate.java From imsdk-android with MIT License | 4 votes |
@ReactMethod public void update( ReadableMap param, final Callback callback) { WritableNativeMap map = new WritableNativeMap(); // @{@"is_ok": @YES, @"errorMsg": @""}; boolean is_ok = false; Activity activity = getCurrentActivity(); if(activity != null) { // TODO get param String fullpackageUrl = param.getString("bundleUrl"); String fullpackageMd5 = param.getString("zipMd5"); String patchUrl = param.getString("patchUrl"); String patchMd5 = param.getString("patchMd5"); String fullMd5 = param.getString("bundleMd5"); String bundleName = param.getString("bundleName"); // TODO switch update type if(param.getBoolean("new")){ String updateType = param.getString("update_type"); if(updateType.equalsIgnoreCase(FULL_UPDATE)){ // todo full update is_ok = QTalkPatchDownloadHelper.downloadFullPackageAndCheck(fullpackageUrl, fullpackageMd5, bundleName, QTalkSearchRNViewInstanceManager.JS_BUNDLE_NAME_ZIP_NAME, QTalkSearchRNViewInstanceManager.getLocalBundlePath(activity), QTalkSearchRNViewInstanceManager.CACHE_BUNDLE_NAME); } else if(updateType.equalsIgnoreCase(PATCH_UPDATE)) { // todo patch update is_ok = QTalkPatchDownloadHelper.downloadPatchAndCheck(patchUrl, patchMd5, fullMd5, QTalkSearchRNViewInstanceManager.getLocalBundlePath(activity), QTalkSearchRNViewInstanceManager.CACHE_BUNDLE_NAME, QTalkSearchRNViewInstanceManager.JS_BUNDLE_NAME); } else if(updateType.equalsIgnoreCase(AUTO_UPDATE)){ // todo auto update // first patch, if patch error full update is_ok = QTalkPatchDownloadHelper.downloadPatchAndCheck(patchUrl, patchMd5, fullMd5, QTalkSearchRNViewInstanceManager.getLocalBundlePath(activity), QTalkSearchRNViewInstanceManager.CACHE_BUNDLE_NAME, QTalkSearchRNViewInstanceManager.JS_BUNDLE_NAME); if(!is_ok){ is_ok = QTalkPatchDownloadHelper.downloadFullPackageAndCheck(fullpackageUrl, fullpackageMd5, bundleName, QTalkSearchRNViewInstanceManager.JS_BUNDLE_NAME_ZIP_NAME, QTalkSearchRNViewInstanceManager.getLocalBundlePath(activity), QTalkSearchRNViewInstanceManager.CACHE_BUNDLE_NAME); } } } } map.putBoolean("is_ok", is_ok); map.putString("errorMsg", ""); if(is_ok){ CommonConfig.mainhandler.post(new Runnable() { @Override public void run() { QTalkSearchActivity.clearBridge(); } }); } callback.invoke(map); }
Example 17
Source File: QimRNBModule.java From imsdk-android with MIT License | 4 votes |
/************************** Search end************************/ public void updateMyPersonalInfo(final String selGravatarPath) { // if (gravatarView == null || TextUtils.isEmpty(gravatarView.getGravatarPath())) { // personalInfoView.setUpdateResult(false); // } final WritableNativeMap failure = new WritableNativeMap(); failure.putBoolean("ok", false); sendEvent("imageUpdateStart", failure); if (TextUtils.isEmpty(selGravatarPath)) { sendEvent("imageUpdateEnd", failure); return; } final UploadImageRequest request = new UploadImageRequest(); request.FileType = UploadImageRequest.LOGO; request.id = QtalkStringUtils.parseLocalpart(CurrentPreference.getInstance().getPreferenceUserId()) + ".gravatar"; request.filePath = selGravatarPath; request.requestComplete = new IUploadRequestComplete() { @Override public void onRequestComplete(String id, final UploadImageResult result) { if (result != null && !TextUtils.isEmpty(result.httpUrl) && !result.httpUrl.contains("error")) { final List<SetVCardData> datas = generateSetData(result.httpUrl, CurrentPreference.getInstance().getPreferenceUserId()); VCardAPI.setVCardInfo(datas, new ProtocolCallback.UnitCallback<SetVCardResult>() { @Override public void onCompleted(SetVCardResult setVCardResult) { if (setVCardResult != null && !ListUtil.isEmpty(setVCardResult.data)) { SetVCardResult.SetVCardItem data = setVCardResult.data.get(0); if (data == null || TextUtils.isEmpty(data.version) || data.version.equals("-1")) { sendEvent("imageUpdateEnd", failure); //失败 // personalInfoView.setUpdateResult(false); // Toast.makeText(CommonConfig.globalContext,"更新失败",Toast.LENGTH_SHORT); } else { // ProfileUtils.updateGVer(result.httpUrl, // data.version, null, CurrentPreference.getInstance().getPreferenceUserId()); //此数据为更新成功后的头像地址 String cacheUrl = QtalkStringUtils. getGravatar(result.httpUrl, true); File targetFile = MyDiskCache.getSmallFile(cacheUrl); File file = new File(selGravatarPath); file.renameTo(targetFile); InternDatas.JidToUrl.put(CurrentPreference.getInstance().getPreferenceUserId(), cacheUrl); WritableNativeMap success = new WritableNativeMap(); ConnectionUtil.getInstance().updateUserImage(CurrentPreference.getInstance().getPreferenceUserId(), cacheUrl); success.putBoolean("ok", true); success.putString("headerUrl", cacheUrl); sendEvent("imageUpdateEnd", success); // personalInfoView.setUpdateResult(true); // Toast.makeText(CommonConfig.globalContext,"更新成功",Toast.LENGTH_SHORT); //成功 } } } @Override public void onFailure(String errMsg) { // Toast.makeText(CommonConfig.globalContext,"更新失败",Toast.LENGTH_SHORT); //失败 sendEvent("imageUpdateEnd", failure); // personalInfoView.setUpdateResult(false); } }); } else { // Toast.makeText(CommonConfig.globalContext,"更新失败",Toast.LENGTH_SHORT); //失败 sendEvent("imageUpdateEnd", failure); // personalInfoView.setUpdateResult(false); } } @Override public void onError(String msg) { sendEvent("imageUpdateEnd", failure); } }; CommonUploader.getInstance().setUploadImageRequest(request); }
Example 18
Source File: QIMRnCheckUpdate.java From imsdk-android with MIT License | 4 votes |
@ReactMethod public void update( ReadableMap param, final Callback success) { Logger.i("开始尝试更新Rn"); boolean is_ok = false; // TODO get param String fullpackageUrl = param.getString("bundleUrl"); String fullpackageMd5 = param.getString("zipMd5"); String patchUrl = TextUtils.isEmpty(param.getString("patchUrl")) ? param.getString("bundleUrl") : param.getString("patchUrl"); String patchMd5 = param.getString("patchMd5"); String fullMd5 = param.getString("bundleMd5"); String bundleName = param.getString("bundleName"); // TODO switch update type if (!TextUtils.isEmpty(fullpackageUrl)) { if (param.getBoolean("new")) { // String updateType = param.getString("update_type"); // if (updateType.equalsIgnoreCase(FULL_UPDATE)) { // todo full update // if (TextUtils.isEmpty(QtalkNavicationService.getInstance().getNewSerarchUrl())) { // is_ok = QTalkServicePatchDownloadHelper.downloadFullPackageAndCheck(fullpackageUrl, // fullpackageMd5, bundleName, BUNDLE_ZIP_NAME, JS_BUNDLE_LOCAL_BASE_PATH, QTalkSearchRNViewOldInstanceManager.CACHE_BUNDLE_NAME); //// mReactInstanceManager = QTalkSearchRNViewOldInstanceManager.getInstanceManager(getApplication()); // } else { if (IMDatabaseManager.getInstance().getFocusSearch()) { is_ok = QTalkServicePatchDownloadHelper.downloadFullPackageAndCheck(fullpackageUrl, fullpackageMd5, bundleName, BUNDLE_ZIP_NAME, JS_BUNDLE_LOCAL_BASE_PATH, QTalkSearchRNViewOldInstanceManager.CACHE_BUNDLE_NAME); } else { is_ok = QTalkServicePatchDownloadHelper.downloadFullPackageAndCheck(fullpackageUrl, fullpackageMd5, bundleName, JS_BUNDLE_NAME_ZIP_NAME, JS_BUNDLE_LOCAL_BASE_PATH, QTalkSearchRNViewInstanceManager.CACHE_BUNDLE_NAME); } // } // } else if (updateType.equalsIgnoreCase(PATCH_UPDATE)) { // // todo patch update // is_ok = QTalkServicePatchDownloadHelper.downloadPatchAndCheck(patchUrl, // patchMd5, fullMd5, JS_BUNDLE_LOCAL_BASE_PATH, QtalkServiceRNViewInstanceManager.CACHE_BUNDLE_NAME, BUNDLE_NAME); // } else if (updateType.equalsIgnoreCase(AUTO_UPDATE)) { // // todo auto update // // first patch, if patch error full update // is_ok = QTalkServicePatchDownloadHelper.downloadPatchAndCheck(patchUrl, // patchMd5, fullMd5, JS_BUNDLE_LOCAL_BASE_PATH, QtalkServiceRNViewInstanceManager.CACHE_BUNDLE_NAME, BUNDLE_NAME); // if (!is_ok) { // is_ok = QTalkServicePatchDownloadHelper.downloadFullPackageAndCheck(fullpackageUrl, // fullpackageMd5, bundleName, BUNDLE_ZIP_NAME, JS_BUNDLE_LOCAL_BASE_PATH, QtalkServiceRNViewInstanceManager.CACHE_BUNDLE_NAME); // } // // } } } WritableNativeMap map = new WritableNativeMap(); // @{@"is_ok": @YES, @"errorMsg": @""}; map.putBoolean("is_ok", is_ok); map.putString("errorMsg", ""); if (is_ok) { // CommonConfig.mainhandler.post(new Runnable() { // @Override // public void run() { //// DiscoverFragment.clearBridge(); //// HyMainActivity.clearBridge(); // } // }); Logger.i("rn更新成功"); IMNotificaitonCenter.getInstance().postMainThreadNotificationName(QtalkEvent.RN_UPDATE); success.invoke(map); } else { // error.invoke(map); } }
Example 19
Source File: QimRNBModule.java From imsdk-android with MIT License | 4 votes |
/** * 查询用户的行车根据 整月查询 * * @param params * @param callback */ @ReactMethod public void selectUserTripByDate(ReadableMap params, Callback callback) { String date = params.getString("showDate"); List<CalendarTrip.DataBean.TripsBean> list = IMDatabaseManager.getInstance().SelectTripByYearMonth(date); Collections.sort(list, new Comparator<CalendarTrip.DataBean.TripsBean>() { @Override public int compare(CalendarTrip.DataBean.TripsBean lhs, CalendarTrip.DataBean.TripsBean rhs) { try { if (DateUtil.string2Time(lhs.getBeginTime()).getTime() > DateUtil.string2Time(rhs.getBeginTime()).getTime()) { return 1; } if (DateUtil.string2Time(lhs.getBeginTime()).getTime() < DateUtil.string2Time(rhs.getBeginTime()).getTime()) { return -1; } } catch (Exception e) { e.printStackTrace(); } return 0; } }); WritableNativeMap map = new WritableNativeMap(); WritableNativeMap dataMap = new WritableNativeMap(); WritableNativeMap.setUseNativeAccessor(true); WritableNativeArray.setUseNativeAccessor(true); Map<String, List<WritableNativeMap>> localMap = new HashMap<>(); // map.putBoolean("ok", true); for (int i = 0; i < list.size(); i++) { CalendarTrip.DataBean.TripsBean bean = list.get(i); if (!localMap.containsKey(bean.getTripDate())) { // WritableNativeArray newArray = new WritableNativeArray(); List<WritableNativeMap> newArray = new ArrayList<>(); newArray.add(getRNDataByTrip(bean)); localMap.put(bean.getTripDate(), newArray); } else { List<WritableNativeMap> lastArray = localMap.get(bean.getTripDate()); lastArray.add(getRNDataByTrip(bean)); localMap.put(bean.getTripDate(), lastArray); } } for (Map.Entry<String, List<WritableNativeMap>> entry : localMap.entrySet()) { WritableNativeArray array = new WritableNativeArray(); for (int i = 0; i < entry.getValue().size(); i++) { array.pushMap(entry.getValue().get(i)); } dataMap.putArray(entry.getKey(), array); } map.putBoolean("ok", true); map.putMap("data", dataMap); callback.invoke(map); }
Example 20
Source File: QimRNBModule.java From imsdk-android with MIT License | 4 votes |
/** * 搜索远程文本数据 * * @param params * @param callback */ @ReactMethod public void searchRemoteMessageByKeyword(ReadableMap params, Callback callback) { String keyword = params.getString("search"); //暂时测试数据 搜索我自己 keyword = "我"; String xmppid = params.getString("xmppid"); String realjid = params.getString("realjid"); String time = params.getString("time"); String chatType = params.getString("chatType"); try { // WritableNativeArray writableNativeArray = new WritableNativeArray(); JSONArray list = IMDatabaseManager.getInstance().selectMessageByKeyWord(keyword, xmppid, realjid); Map<String, List<JSONObject>> map = new LinkedHashMap<>(); for (int i = 0; i < list.length(); i++) { JSONObject imMessage = list.getJSONObject(i); String timeStr = getTimeStr(imMessage.getLong("timeLong")); List<JSONObject> oldList = map.get(timeStr); if (oldList != null) { oldList.add(imMessage); } else { List<JSONObject> newList = new ArrayList<>(); newList.add(imMessage); map.put(timeStr, newList); } } WritableNativeMap cMap = new WritableNativeMap(); WritableNativeArray array = new WritableNativeArray(); for (Map.Entry<String, List<JSONObject>> entry : map.entrySet()) { WritableNativeArray itemArray = new WritableNativeArray(); for (int i = 0; i < entry.getValue().size(); i++) { JSONObject jsonObject = entry.getValue().get(i); WritableNativeMap writableNativeMap = new WritableNativeMap(); writableNativeMap.putString("time", jsonObject.optString("time")); writableNativeMap.putString("timeLong", jsonObject.optString("timeLong")); writableNativeMap.putString("content", jsonObject.optString("content")); writableNativeMap.putString("nickName", jsonObject.optString("nickName")); writableNativeMap.putString("headerUrl", jsonObject.optString("headerUrl")); writableNativeMap.putString("msgId", jsonObject.optString("msgId")); writableNativeMap.putString("from", jsonObject.optString("from")); itemArray.pushMap(writableNativeMap); } WritableNativeMap itemMap = new WritableNativeMap(); itemMap.putArray("data", itemArray); itemMap.putString("key", entry.getKey()); array.pushMap(itemMap); } cMap.putBoolean("ok", true); cMap.putArray("data", array); callback.invoke(cMap); } catch (Exception e) { Logger.i("会话内搜索:" + e.getMessage()); } }