com.facebook.react.bridge.Callback Java Examples
The following examples show how to use
com.facebook.react.bridge.Callback.
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: ImageEditingManager.java From react-native-GPay with MIT License | 6 votes |
private CropTask( ReactContext context, String uri, int x, int y, int width, int height, Callback success, Callback error) { super(context); if (x < 0 || y < 0 || width <= 0 || height <= 0) { throw new JSApplicationIllegalArgumentException(String.format( "Invalid crop rectangle: [%d, %d, %d, %d]", x, y, width, height)); } mContext = context; mUri = uri; mX = x; mY = y; mWidth = width; mHeight = height; mSuccess = success; mError = error; }
Example #2
Source File: ForwardingCookieHandler.java From react-native-GPay with MIT License | 6 votes |
public void clearCookies(final Callback callback) { if (USES_LEGACY_STORE) { new GuardedResultAsyncTask<Boolean>(mContext) { @Override protected Boolean doInBackgroundGuarded() { getCookieManager().removeAllCookie(); mCookieSaver.onCookiesModified(); return true; } @Override protected void onPostExecuteGuarded(Boolean result) { callback.invoke(result); } }.execute(); } else { clearCookiesAsync(callback); } }
Example #3
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 #4
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
@ReactMethod public void setServiceState(final ReadableMap map, final Callback callback) { if (map == null) { return; } final String st = map.getString("state"); final String sid = map.getString("sid"); ThirdProviderAPI.setServiceStatus(CurrentPreference.getInstance().getUserid(), st, sid, new ProtocolCallback.UnitCallback<Boolean>() { @Override public void onCompleted(Boolean aBoolean) { WritableNativeMap writableNativeMap = new WritableNativeMap(); writableNativeMap.putBoolean("result", aBoolean); callback.invoke(writableNativeMap); } @Override public void onFailure(String errMsg) { } }); }
Example #5
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
/** * 获取用户信息 * * @param userId * @param callback */ @ReactMethod public void getUserInfo(final String userId, final Callback callback) { ConnectionUtil.getInstance().getUserCard(userId, new IMLogicManager.NickCallBack() { @Override public void onNickCallBack(Nick nick) { WritableMap hm = new WritableNativeMap(); hm.putString("Name", nick.getName()); hm.putString("Remarks", nick.getMark()); hm.putString("HeaderUri", nick.getHeaderSrc()); hm.putString("Department", nick.getDescInfo()); hm.putString("UserId", nick.getXmppId()); WritableNativeMap map = new WritableNativeMap(); map.putMap("UserInfo", hm); callback.invoke(map); } }, false, true); }
Example #6
Source File: SamsungHealthModule.java From rn-samsung-health with The Unlicense | 6 votes |
@ReactMethod public void readSleep(double startDate, double endDate, Callback error, Callback success) { HealthDataResolver resolver = new HealthDataResolver(mStore, null); Filter filter = Filter.and( Filter.greaterThanEquals(HealthConstants.Sleep.START_TIME, (long)startDate), Filter.lessThanEquals(HealthConstants.Sleep.END_TIME, (long)endDate) ); HealthDataResolver.ReadRequest request = new ReadRequest.Builder() .setDataType(HealthConstants.Sleep.HEALTH_DATA_TYPE) .setProperties(new String[]{ HealthConstants.Sleep.START_TIME, HealthConstants.Sleep.END_TIME, HealthConstants.Sleep.TIME_OFFSET, HealthConstants.Sleep.DEVICE_UUID }) .setFilter(filter) .build(); try { resolver.read(request).setResultListener(new HealthDataResultListener(this, error, success)); } catch (Exception e) { Log.e(REACT_MODULE, e.getClass().getName() + " - " + e.getMessage()); Log.e(REACT_MODULE, "Getting Sleep fails."); error.invoke("Getting Sleep fails."); } }
Example #7
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
/** * 同步在线通知状态 * * @param callback */ @ReactMethod public void syncOnLineNotifyState(Callback callback) { // CurrentPreference.ProFile proFile = CurrentPreference.getInstance().getProFile(); // WritableMap map = new WritableNativeMap(); //// WritableMap params = new WritableNativeMap(); //// params.putBoolean("syncOnLineNotifyState",proFile.isOfflinePush()); // map.putBoolean("state", proFile.isOfflinePush()); // callback.invoke(map); WritableMap map = new WritableNativeMap(); boolean state = ConnectionUtil.getInstance().getPushStateBy(PushSettinsStatus.PUSH_ONLINE); map.putBoolean("state", state); callback.invoke(map); }
Example #8
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 #9
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 #10
Source File: QimRNBModule.java From imsdk-android with MIT License | 6 votes |
/** * 群踢人 * * @param params */ @ReactMethod public void kickGroupMember(ReadableMap params, Callback callback) { final String groupId = params.getString("groupId"); ReadableMap map = params.getMap("members"); ReadableMapKeySetIterator keySet = map.keySetIterator(); Map<String, String> memberMap = new HashMap<>(); while (keySet.hasNextKey()) { ReadableMap item = map.getMap(keySet.nextKey()); String userId = item.getString("xmppId"); String name = item.getString("name"); memberMap.put(name, userId); } if (TextUtils.isEmpty(groupId) || memberMap.size() == 0) { return; } ConnectionUtil.getInstance().delGroupMember(groupId, memberMap); sendEvent("closeKickMembers", new WritableNativeMap()); toast("成员已移除"); }
Example #11
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 #12
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 #13
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 #14
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 #15
Source File: AsyncStorageModule.java From react-native-GPay with MIT License | 6 votes |
/** * Clears the database. */ @ReactMethod public void clear(final Callback callback) { new GuardedAsyncTask<Void, Void>(getReactApplicationContext()) { @Override protected void doInBackgroundGuarded(Void... params) { if (!mReactDatabaseSupplier.ensureDatabase()) { callback.invoke(AsyncStorageErrorUtil.getDBError(null)); return; } try { mReactDatabaseSupplier.clear(); callback.invoke(); } catch (Exception e) { FLog.w(ReactConstants.TAG, e.getMessage(), e); callback.invoke(AsyncStorageErrorUtil.getError(null, e.getMessage())); } } }.executeOnExecutor(executor); }
Example #16
Source File: OTSessionManager.java From opentok-react-native with MIT License | 6 votes |
@ReactMethod public void sendSignal(String sessionId, ReadableMap signal, Callback callback) { ConcurrentHashMap<String, Session> mSessions = sharedState.getSessions(); Session mSession = mSessions.get(sessionId); ConcurrentHashMap<String, Connection> mConnections = sharedState.getConnections(); String connectionId = signal.getString("to"); Connection mConnection = null; if (connectionId != null) { mConnection = mConnections.get(connectionId); } if (mConnection != null && mSession != null) { mSession.sendSignal(signal.getString("type"), signal.getString("data"), mConnection); callback.invoke(); } else if (mSession != null) { mSession.sendSignal(signal.getString("type"), signal.getString("data")); callback.invoke(); } else { WritableMap errorInfo = EventUtils.createError("There was an error sending the signal. The native session instance could not be found."); callback.invoke(errorInfo); } }
Example #17
Source File: SamsungHealthModule.java From rn-samsung-health with The Unlicense | 6 votes |
@ReactMethod public void readHeight(double startDate, double endDate, Callback error, Callback success) { HealthDataResolver resolver = new HealthDataResolver(mStore, null); Filter filter = Filter.and( Filter.greaterThanEquals(HealthConstants.Height.START_TIME, (long)startDate), Filter.lessThanEquals(HealthConstants.Height.START_TIME, (long)endDate) ); HealthDataResolver.ReadRequest request = new ReadRequest.Builder() .setDataType(HealthConstants.Height.HEALTH_DATA_TYPE) .setProperties(new String[]{ HealthConstants.Height.HEIGHT, HealthConstants.Height.START_TIME, HealthConstants.Height.TIME_OFFSET, HealthConstants.Height.DEVICE_UUID }) .setFilter(filter) .build(); try { resolver.read(request).setResultListener(new HealthDataResultListener(this, error, success)); } catch (Exception e) { Log.e(REACT_MODULE, e.getClass().getName() + " - " + e.getMessage()); Log.e(REACT_MODULE, "Getting Height fails."); error.invoke("Getting Height fails."); } }
Example #18
Source File: SingleLocationUpdate.java From react-native-geolocation-service with MIT License | 5 votes |
public SingleLocationUpdate( FusedLocationProviderClient fusedLocationProviderClient, LocationRequest locationRequest, long timeout, Callback success, Callback error ) { mFusedProviderClient = fusedLocationProviderClient; mLocationRequest = locationRequest; mTimeout = timeout; mSuccessCallback = success; mErrorCallback = error; }
Example #19
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 #20
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 #21
Source File: HotspotModule.java From react-native-wifi-hotspot with ISC License | 5 votes |
@ReactMethod public void enable(Callback success, Callback error) { if(hotspot.isEnabled()) { success.invoke(); } else error.invoke("Hotspot already running"); }
Example #22
Source File: ConnectionListener.java From rn-samsung-health with The Unlicense | 5 votes |
public ConnectionListener(SamsungHealthModule module, Callback error, Callback success) { mModule = module; mErrorCallback = error; mSuccessCallback = success; mKeySet = new HashSet<PermissionKey>(); }
Example #23
Source File: QtalkPlugin.java From imsdk-android with MIT License | 5 votes |
/** * 浏览大图 图片 * * @param params imageUrl为图片地址 * @param callback */ @ReactMethod public void browseBigImage(ReadableMap params, Callback callback) { if (params.hasKey("imageUrl")) { String imageUrl = params.getString("imageUrl"); if (TextUtils.isEmpty(imageUrl)) { } else { NativeApi.openBigImage(imageUrl, MyDiskCache.getSmallFile(imageUrl + "&w=96&h=96").getAbsolutePath()); } } }
Example #24
Source File: HotspotModule.java From react-native-wifi-hotspot with ISC License | 5 votes |
@ReactMethod public void peersList(final Callback success,final Callback error) { hotspot.setPeersCallback(new HotspotManager.peersList() { @Override public void onPeersScanned(ArrayList<ClientScanResult> peers) { if(!peers.isEmpty()) { JSONArray arrayOfPeers = new JSONArray(); int count = 1; for(ClientScanResult peer: peers) { JSONObject object = new JSONObject(); try { object.put("ip", peer.getIpAddr()); object.put("mac", peer.getHWAddr()); peer.setDevice("Device "+(count++)+""); object.put("device", peer.getDevice()); } catch(JSONException e) { error.invoke("Fetching has failed"); } arrayOfPeers.put(object); } success.invoke(arrayOfPeers.toString()); } else { error.invoke("Hotspot is empty"); } } }); }
Example #25
Source File: UIImplementation.java From react-native-GPay with MIT License | 5 votes |
/** * Determines the location on screen, width, and height of the given view relative to the root * view and returns the values via an async callback. */ public void measure(int reactTag, Callback callback) { // This method is called by the implementation of JS touchable interface (see Touchable.js for // more details) at the moment of touch activation. That is after user starts the gesture from // a touchable view with a given reactTag, or when user drag finger back into the press // activation area of a touchable view that have been activated before. mOperationsQueue.enqueueMeasure(reactTag, callback); }
Example #26
Source File: QtalkPlugin.java From imsdk-android with MIT License | 5 votes |
@ReactMethod public void getLocalSearchKeyHistory(ReadableMap params,Callback callback){ int limit = 5; int type = 0 ; List<SearchKeyData> list =IMDatabaseManager.getInstance().getLocalSearchKeyHistory(type ,limit); WritableNativeMap map = new WritableNativeMap(); map.putBoolean("isOk",true); WritableNativeArray array = new WritableNativeArray(); for (int i = 0; i < list.size(); i++) { array.pushString(list.get(i).getSearchKey()); } map.putArray("searchKeys",array); callback.invoke(map); }
Example #27
Source File: ReactNativeAPKModule.java From react-native-apk with MIT License | 5 votes |
@ReactMethod public void isAppInstalled(String packageName, Callback cb) { try { PackageInfo pInfo = this.reactContext.getPackageManager().getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); cb.invoke(true); } catch (PackageManager.NameNotFoundException e) { cb.invoke(false); } }
Example #28
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
/** * 检查该用户此时间段内是否有冲突会议 * * @param params * @param callback */ @ReactMethod public void tripMemberCheck(final ReadableMap params, final Callback callback) { String checkId = params.getString("checkId"); String beginTime = params.getString("beginTime"); String endTime = params.getString("endTime"); CalendarTrip.DataBean.TripsBean bean = new CalendarTrip.DataBean.TripsBean(); bean.setCheckId(checkId); bean.setBeginTime(beginTime); bean.setEndTime(endTime); final WritableNativeMap map = new WritableNativeMap(); HttpUtil.tripMemberCheck(bean, new ProtocolCallback.UnitCallback<TripMemberCheckResponse>() { @Override public void onCompleted(TripMemberCheckResponse tripMemberCheckResponse) { map.putBoolean("ok", true); map.putBoolean("isConform", tripMemberCheckResponse.getData().isIsConform()); callback.invoke(map); } @Override public void onFailure(String errMsg) { map.putBoolean("ok", false); callback.invoke(map); } }); }
Example #29
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
@ReactMethod public void updateRemoteKey(Callback callback) { WritableNativeMap map = new WritableNativeMap(); String newKey = IMLogicManager.getInstance().getRemoteLoginKey(true); if (!TextUtils.isEmpty(newKey)) { map.putBoolean("ok", true); } else { map.putBoolean("ok", false); } callback.invoke(map); }
Example #30
Source File: QimRNBModule.java From imsdk-android with MIT License | 5 votes |
/** * 获取用户签名 * * @param userId * @param callback */ @ReactMethod public void getUserMood(final String userId, final Callback callback) { // VCardAPI.getUserProfile(userId, new ProtocolCallback.UnitCallback<GetMoodResult>() { // @Override // public void onCompleted(GetMoodResult getMoodResult) { // if (getMoodResult.ret) { // String mood = "这家伙很懒,什么都没留下"; // if (!ListUtil.isEmpty(getMoodResult.data)) { // mood = getMoodResult.data.get(0).M; // } // WritableMap hm = new WritableNativeMap(); // hm.putString("Mood", mood); // WritableNativeMap map = new WritableNativeMap(); // map.putMap("UserInfo", hm); // callback.invoke(map); // } // } // // @Override // public void onFailure(String errMsg) { // String mood = "这家伙很懒,什么都没留下"; // WritableMap hm = new WritableNativeMap(); // hm.putString("Mood", mood); // WritableNativeMap map = new WritableNativeMap(); // map.putMap("UserInfo", hm); // callback.invoke(map); // } // }); // callback.invoke(null); }