Java Code Examples for com.facebook.react.bridge.Callback#invoke()
The following examples show how to use
com.facebook.react.bridge.Callback#invoke() .
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 |
/** * 获取用户通知是否显示详情 * * @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 2
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 3
Source File: OTSessionManager.java From opentok-react-native with MIT License | 6 votes |
@ReactMethod public void subscribeToStream(String streamId, String sessionId, ReadableMap properties, Callback callback) { ConcurrentHashMap<String, Stream> mSubscriberStreams = sharedState.getSubscriberStreams(); ConcurrentHashMap<String, Subscriber> mSubscribers = sharedState.getSubscribers(); ConcurrentHashMap<String, Session> mSessions = sharedState.getSessions(); Stream stream = mSubscriberStreams.get(streamId); Session mSession = mSessions.get(sessionId); Subscriber mSubscriber = new Subscriber.Builder(getReactApplicationContext(), stream).build(); mSubscriber.setSubscriberListener(this); mSubscriber.setAudioLevelListener(this); mSubscriber.setAudioStatsListener(this); mSubscriber.setVideoStatsListener(this); mSubscriber.setVideoListener(this); mSubscriber.setStreamListener(this); mSubscriber.setSubscribeToAudio(properties.getBoolean("subscribeToAudio")); mSubscriber.setSubscribeToVideo(properties.getBoolean("subscribeToVideo")); mSubscribers.put(streamId, mSubscriber); if (mSession != null) { mSession.subscribe(mSubscriber); callback.invoke(null, streamId); } else { WritableMap errorInfo = EventUtils.createError("Error subscribing. The native session instance could not be found."); callback.invoke(errorInfo); } }
Example 4
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 5
Source File: OTSessionManager.java From opentok-react-native with MIT License | 6 votes |
@Override public void onStreamDestroyed(PublisherKit publisherKit, Stream stream) { String publisherId = Utils.getPublisherId(publisherKit); String event = publisherId + ":" + publisherPreface + "onStreamDestroyed"; ConcurrentHashMap<String, Stream> mSubscriberStreams = sharedState.getSubscriberStreams(); String mStreamId = stream.getStreamId(); mSubscriberStreams.remove(mStreamId); if (publisherId.length() > 0) { WritableMap streamInfo = EventUtils.prepareJSStreamMap(stream, publisherKit.getSession()); sendEventMap(this.getReactApplicationContext(), event, streamInfo); } Callback mCallback = sharedState.getPublisherDestroyedCallbacks().get(publisherId); if (mCallback != null) { mCallback.invoke(); } sharedState.getPublishers().remove(publisherId); printLogs("onStreamDestroyed: Publisher Stream Destroyed. Own stream "+stream.getStreamId()); }
Example 6
Source File: RNStaticSafeAreaInsetsModule.java From react-native-static-safe-area-insets with MIT License | 5 votes |
@ReactMethod public void getSafeAreaInsets(Callback cb) { Map<String, Object> constants = this._getSafeAreaInsets(); WritableMap map = new WritableNativeMap(); map.putInt("safeAreaInsetsTop", ((Float) constants.get("safeAreaInsetsTop")).intValue()); map.putInt("safeAreaInsetsBottom", ((Float) constants.get("safeAreaInsetsBottom")).intValue()); map.putInt("safeAreaInsetsLeft", ((Float) constants.get("safeAreaInsetsLeft")).intValue()); map.putInt("safeAreaInsetsRight", ((Float) constants.get("safeAreaInsetsRight")).intValue()); cb.invoke(map); }
Example 7
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
/** * 获取用户是否开启推送 * * @param callback */ @ReactMethod public void getStartPushState(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.isTurnOnPsuh()); // callback.invoke(map); WritableMap map = new WritableNativeMap(); boolean state = ConnectionUtil.getInstance().getPushStateBy(PushSettinsStatus.PUSH_SWITCH); map.putBoolean("state", state); callback.invoke(map); }
Example 8
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 9
Source File: OTSessionManager.java From opentok-react-native with MIT License | 5 votes |
@ReactMethod public void getSessionInfo(String sessionId, Callback callback) { ConcurrentHashMap<String, Session> mSessions = sharedState.getSessions(); Session mSession = mSessions.get(sessionId); WritableMap sessionInfo = null; if (mSession != null){ sessionInfo = EventUtils.prepareJSSessionMap(mSession); sessionInfo.putString("sessionId", mSession.getSessionId()); sessionInfo.putInt("connectionStatus", getConnectionStatus(mSession.getSessionId())); } callback.invoke(sessionInfo); }
Example 10
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
/** * 获取联系人页展示的用户 * * @param callback */ @ReactMethod public void getContacts(Callback callback) { List<Nick> fList = ConnectionUtil.getInstance().SelectFriendListForRN(); WritableNativeMap map = new WritableNativeMap(); WritableArray array = new WritableNativeArray(); if (fList != null && fList.size() > 0) { // WritableMap map = new WritableNativeMap(); for (int i = 0; i < fList.size(); i++) { Nick nick = fList.get(i); WritableNativeMap item = new WritableNativeMap(); String name = nick.getName(); String pinyin = nick.getXmppId(); if (!TextUtils.isEmpty(name)) { pinyin = HanziToPinyin.zh2Abb(name); } item.putString("Name", TextUtils.isEmpty(name) ? nick.getXmppId() : name); item.putString("HeaderUri", TextUtils.isEmpty(nick.getHeaderSrc()) ? "" : nick.getHeaderSrc()); item.putString("SearchIndex", pinyin); item.putString("XmppId", nick.getXmppId()); item.putString("Remark", nick.getMark()); item.putString("Mood",nick.getMood()); array.pushMap(item); } } map.putArray("contacts", array); callback.invoke(map); // WritableNativeMap map2= new WritableNativeMap(); // map2.putString("aaa","aaaa"); // sendEvent("EventName",map2); }
Example 11
Source File: HotspotModule.java From react-native-wifi-hotspot with ISC License | 5 votes |
@ReactMethod public void create(ReadableMap info, Callback success, Callback error) { if(hotspot.isCreated(info)) success.invoke(); else error.invoke("Hotspot creation has failed"); }
Example 12
Source File: ReactNativeAPKModule.java From react-native-apk with MIT License | 5 votes |
@ReactMethod public void getAppVersion(String packageName, Callback cb) { try { PackageInfo pInfo = this.reactContext.getPackageManager().getPackageInfo(packageName, 0); cb.invoke(pInfo.versionName); } catch (PackageManager.NameNotFoundException e) { cb.invoke(false); } }
Example 13
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
/** * 退出群组 * * @param groupId * @param callback */ @ReactMethod public void quitGroup(String groupId, Callback callback) { // connectionUtil.leaveGroup(key); ConnectionUtil.getInstance().leaveGroup(groupId); WritableNativeMap map = new WritableNativeMap(); map.putBoolean("ok", true); 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: RNTusClientModule.java From react-native-tus-client with MIT License | 5 votes |
@ReactMethod public void abort(String uploadId, Callback callback) { try { TusRunnable executor = this.executorsMap.get(uploadId); if(executor != null) { executor.finish(); } callback.invoke((Object)null); } catch(IOException | ProtocolException e) { callback.invoke(e); } }
Example 16
Source File: PjSipBroadcastReceiver.java From react-native-sip with GNU General Public License v3.0 | 5 votes |
private void onCallback(Intent intent) { // Define callback Callback callback = null; if (intent.hasExtra("callback_id")) { int id = intent.getIntExtra("callback_id", -1); if (callbacks.containsKey(id)) { callback = callbacks.remove(id); } else { Log.w(TAG, "Callback with \""+ id +"\" identifier not found (\""+ intent.getAction() +"\")"); } } if (callback == null) { return; } // ----- if (intent.hasExtra("exception")) { Log.w(TAG, "Callback executed with exception state: " + intent.getStringExtra("exception")); callback.invoke(false, intent.getStringExtra("exception")); } else if (intent.hasExtra("data")) { Object params = ArgumentUtils.fromJson(intent.getStringExtra("data")); callback.invoke(true, params); } else { callback.invoke(true, true); } }
Example 17
Source File: RNAudioPlayerModule.java From react-native-audio-streaming-player with MIT License | 4 votes |
@ReactMethod public void isPlaying(Callback cb) { cb.invoke(mService.getPlayback().isPlaying()); }
Example 18
Source File: DialogModule.java From react-native-GPay with MIT License | 4 votes |
@ReactMethod public void showAlert( ReadableMap options, Callback errorCallback, final Callback actionCallback) { final FragmentManagerHelper fragmentManagerHelper = getFragmentManagerHelper(); if (fragmentManagerHelper == null) { errorCallback.invoke("Tried to show an alert while not attached to an Activity"); return; } final Bundle args = new Bundle(); if (options.hasKey(KEY_TITLE)) { args.putString(AlertFragment.ARG_TITLE, options.getString(KEY_TITLE)); } if (options.hasKey(KEY_MESSAGE)) { args.putString(AlertFragment.ARG_MESSAGE, options.getString(KEY_MESSAGE)); } if (options.hasKey(KEY_BUTTON_POSITIVE)) { args.putString(AlertFragment.ARG_BUTTON_POSITIVE, options.getString(KEY_BUTTON_POSITIVE)); } if (options.hasKey(KEY_BUTTON_NEGATIVE)) { args.putString(AlertFragment.ARG_BUTTON_NEGATIVE, options.getString(KEY_BUTTON_NEGATIVE)); } if (options.hasKey(KEY_BUTTON_NEUTRAL)) { args.putString(AlertFragment.ARG_BUTTON_NEUTRAL, options.getString(KEY_BUTTON_NEUTRAL)); } if (options.hasKey(KEY_ITEMS)) { ReadableArray items = options.getArray(KEY_ITEMS); CharSequence[] itemsArray = new CharSequence[items.size()]; for (int i = 0; i < items.size(); i ++) { itemsArray[i] = items.getString(i); } args.putCharSequenceArray(AlertFragment.ARG_ITEMS, itemsArray); } if (options.hasKey(KEY_CANCELABLE)) { args.putBoolean(KEY_CANCELABLE, options.getBoolean(KEY_CANCELABLE)); } UiThreadUtil.runOnUiThread(new Runnable() { @Override public void run() { fragmentManagerHelper.showNewAlert(mIsInForeground, args, actionCallback); } }); }
Example 19
Source File: FakeAsyncLocalStorage.java From react-native-GPay with MIT License | 4 votes |
@ReactMethod public void clear(Callback callback) { callback.invoke(errorMessage); }
Example 20
Source File: RNAudioPlayerModule.java From react-native-audio-streaming-player with MIT License | 4 votes |
@ReactMethod public void getCurrentPosition(Callback cb) { cb.invoke(mService.getPlayback().getCurrentPosition()); }