Java 类com.facebook.react.bridge.WritableMap 实例源码

项目:nfc-react-native-simple    文件:NfcReactNativeSimpleModule.java   
@Override
    public void onNewIntent(Intent intent) 
    {
          String action = intent.getAction();
//      Log.i("!intent! ", action);

          Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);

        byte[] id = tag.getId();
        String serialNumber = bytesToHex(id);
        WritableMap idData = Arguments.createMap();
        idData.putString("id", serialNumber);

        sendEvent(this.reactContext, "NFCCardID", idData);

    }
项目:react-native-background-task    文件:HeadlessTaskService.java   
@Override
protected @Nullable HeadlessJsTaskConfig getTaskConfig(Intent intent) {
    Bundle extras = intent.getExtras();
    // If extras have been passed to the intent, pass them on into the JS as taskData
    // which can be accessed as the first param.
    WritableMap data = /* extras != null ? Arguments.fromBundle(extras) : */ Arguments.createMap();

    int timeout = extras.getInt("timeout");

    Log.d(TAG, String.format("Returning HeadlessJsTaskConfig, timeout=%s ms", timeout));
    return new HeadlessJsTaskConfig(
            // The the task was registered with in JS - must match
            "BackgroundTask",
            data,
            TimeUnit.SECONDS.toMillis(timeout)
    );
}
项目:react-native-twilio-chat    文件:RCTConvert.java   
public static WritableMap Message(Message message) {
    WritableMap map = Arguments.createMap();

    map.putString("sid", message.getSid());
    map.putInt("index", (int) message.getMessageIndex());
    map.putString("author", message.getAuthor());
    map.putString("body", message.getMessageBody());
    map.putString("timestamp", message.getTimeStamp());

    WritableMap attributes = Arguments.createMap();
    try {
        attributes = jsonToWritableMap(message.getAttributes());
    }
    catch (JSONException e) {}
    map.putMap("attributes", attributes);
    return map;
}
项目:react-native-fused-location    文件:FusedLocationModule.java   
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 = false;
    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;
}
项目:RNLearn_Project1    文件:DatePickerDialogTestCase.java   
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]);
}
项目:react-native-nfc-manager    文件:JsonConvert.java   
public static WritableMap jsonToReact(JSONObject jsonObject) throws JSONException {
    WritableMap writableMap = Arguments.createMap();
    Iterator iterator = jsonObject.keys();
    while(iterator.hasNext()) {
        String key = (String) iterator.next();
        Object value = jsonObject.get(key);
        if (value instanceof Float || value instanceof Double) {
            writableMap.putDouble(key, jsonObject.getDouble(key));
        } else if (value instanceof Number) {
            writableMap.putInt(key, jsonObject.getInt(key));
        } else if (value instanceof String) {
            writableMap.putString(key, jsonObject.getString(key));
        } else if (value instanceof JSONObject) {
            writableMap.putMap(key,jsonToReact(jsonObject.getJSONObject(key)));
        } else if (value instanceof JSONArray){
            writableMap.putArray(key, jsonToReact(jsonObject.getJSONArray(key)));
        } else if (value == JSONObject.NULL){
            writableMap.putNull(key);
        }
    }

    return writableMap;
}
项目:RNLearn_Project1    文件:ShareModule.java   
/**
 * Open a chooser dialog to send text content to other apps.
 *
 * Refer http://developer.android.com/intl/ko/training/sharing/send.html
 *
 * @param content the data to send
 * @param dialogTitle the title of the chooser dialog
 */
@ReactMethod
public void share(ReadableMap content, String dialogTitle, Promise promise) {
  if (content == null) {
    promise.reject(ERROR_INVALID_CONTENT, "Content cannot be null");
    return;
  }

  try {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setTypeAndNormalize("text/plain");

    if (content.hasKey("title")) {
      intent.putExtra(Intent.EXTRA_SUBJECT, content.getString("title"));
    }

    if (content.hasKey("message")) {
      intent.putExtra(Intent.EXTRA_TEXT, content.getString("message"));
    }

    Intent chooser = Intent.createChooser(intent, dialogTitle);
    chooser.addCategory(Intent.CATEGORY_DEFAULT);

    Activity currentActivity = getCurrentActivity();
    if (currentActivity != null) {
      currentActivity.startActivity(chooser);
    } else {
      getReactApplicationContext().startActivity(chooser);
    }
    WritableMap result = Arguments.createMap();
    result.putString("action", ACTION_SHARED);
    promise.resolve(result);
  } catch (Exception e) {
    promise.reject(ERROR_UNABLE_TO_OPEN_DIALOG, "Failed to open share dialog");
  }
}
项目:RNLearn_Project1    文件:ReactWebViewManager.java   
@Override
public void onReceivedError(
    WebView webView,
    int errorCode,
    String description,
    String failingUrl) {
  super.onReceivedError(webView, errorCode, description, failingUrl);
  mLastLoadFailed = true;

  // In case of an error JS side expect to get a finish event first, and then get an error event
  // Android WebView does it in the opposite way, so we need to simulate that behavior
  emitFinishEvent(webView, failingUrl);

  WritableMap eventData = createWebViewEvent(webView, failingUrl);
  eventData.putDouble("code", errorCode);
  eventData.putString("description", description);

  dispatchEvent(
      webView,
      new TopLoadingErrorEvent(webView.getId(), eventData));
}
项目:react-native-google-fit    文件:StepCounter.java   
@Override
public void onDataPoint(DataPoint dataPoint) {
    DataType type = dataPoint.getDataType();
    Log.i(TAG, "Detected DataPoint type: " + type);

    for (final Field field : type.getFields()) {
        final Value value = dataPoint.getValue(field);
        Log.i(TAG, "Detected DataPoint field: " + field.getName());
        Log.i(TAG, "Detected DataPoint value: " + value);


   /*     activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(mReactContext.getApplicationContext(), "Field: " + field.getName() + " Value: " + value, Toast.LENGTH_SHORT).show();
            }
        });*/

        if(type.equals(DataType.TYPE_STEP_COUNT_CUMULATIVE)) {
            WritableMap map = Arguments.createMap();
            map.putDouble("steps", value.asInt());
            sendEvent(this.mReactContext, "StepChangedEvent", map);
        }

    }
}
项目:react-native-call-events    文件:CallStateListenerTest.java   
@Test
public void onCallStateChanged_CALL_STATE_IDLE_returnOnEndTrue() {
    CallStateListener instance = getInstance(false, true, mockReactContext);

    instance.onCallStateChanged(TelephonyManager.CALL_STATE_IDLE, "8675309");

    //always set the return flags
    verify(mockIntent).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

    //Should always fire the event back to Javascript
    WritableMap expected = new MockWritableMap();
    expected.putString("phonenumber", "8675309");
    expected.putString("state", "CALL_STATE_END");
    verify(mockEmitter).emit("callStatusUpdate", expected);

    //should launch the app
    verify(mockApplicationContext).startActivity(mockIntent);
}
项目:react-native-call-events    文件:CallStateListenerTest.java   
@Test
public void onCallStateChanged_CALL_STATE_RINGING_returnOnCallFalse() {
    CallStateListener instance = getInstance(false, true, mockReactContext);

    instance.onCallStateChanged(TelephonyManager.CALL_STATE_RINGING, "8675309");

    //always set the return flags
    verify(mockIntent).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

    //Should always fire the event back to Javascript
    WritableMap expected = new MockWritableMap();
    expected.putString("phonenumber", "8675309");
    expected.putString("state", "CALL_STATE_RINGING");
    verify(mockEmitter).emit("callStatusUpdate", expected);

    //should not attempt to launch the app
    verify(mockApplicationContext, never()).startActivity(any(Intent.class));
}
项目:react-native-blue-manager    文件:Peripheral.java   
public WritableMap asWritableMap() {

        WritableMap map = Arguments.createMap();

        try {
            map.putString("name", device.getName());
            map.putBoolean("connected", connected);
            map.putString("id", device.getAddress()); // mac address
            map.putMap("advertising", byteArrayToWritableMap(advertisingData));
            map.putInt("rssi", advertisingRSSI);
        } catch (Exception e) { // this shouldn't happen
            e.printStackTrace();
        }

        return map;
    }
项目:react-native-call-events    文件:CallStateListenerTest.java   
@Test
public void onCallStateChanged_CALL_STATE_OFFHOOK_returnOnCallFalse() {
    CallStateListener instance = getInstance(false, true, mockReactContext);

    instance.onCallStateChanged(TelephonyManager.CALL_STATE_OFFHOOK, "8675309");

    //always set the return flags
    verify(mockIntent).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

    //Should always fire the event back to Javascript
    WritableMap expected = new MockWritableMap();
    expected.putString("phonenumber", "8675309");
    expected.putString("state", "CALL_STATE_OFFHOOK");
    verify(mockEmitter).emit("callStatusUpdate", expected);

    //should not attempt to launch the app
    verify(mockApplicationContext, never()).startActivity(any(Intent.class));
}
项目:react-native-android-text-to-speech    文件:RNAndroidTextToSpeechModule.java   
private WritableMap returnMapForVoice(Voice voice) {
    WritableMap voiceData = Arguments.createMap();
    voiceData.putString("voiceName", voice.getName());
    voiceData.putString("languageName", voice.getLocale().getDisplayLanguage());
    voiceData.putString("languageCode", voice.getLocale().getISO3Language());
    voiceData.putString("languageString", voice.getLocale().toString());
    voiceData.putString("countryName", voice.getLocale().getDisplayCountry());
    voiceData.putString("countryCode", voice.getLocale().getISO3Country());

    return voiceData;
}
项目:RNLearn_Project1    文件:DatePickerDialogModule.java   
@Override
public void onDateSet(DatePicker view, int year, int month, int day) {
  if (!mPromiseResolved && getReactApplicationContext().hasActiveCatalystInstance()) {
    WritableMap result = new WritableNativeMap();
    result.putString("action", ACTION_DATE_SET);
    result.putInt("year", year);
    result.putInt("month", month);
    result.putInt("day", day);
    mPromise.resolve(result);
    mPromiseResolved = true;
  }
}
项目:RNLearn_Project1    文件:CameraRollManager.java   
private static void putBasicNodeInfo(
    Cursor photos,
    WritableMap node,
    int mimeTypeIndex,
    int groupNameIndex,
    int dateTakenIndex) {
  node.putString("type", photos.getString(mimeTypeIndex));
  node.putString("group_name", photos.getString(groupNameIndex));
  node.putDouble("timestamp", photos.getLong(dateTakenIndex) / 1000d);
}
项目:RNLearn_Project1    文件:ResponseUtil.java   
public static void onResponseReceived(
  RCTDeviceEventEmitter eventEmitter,
  int requestId,
  int statusCode,
  WritableMap headers,
  String url) {
  WritableArray args = Arguments.createArray();
  args.pushInt(requestId);
  args.pushInt(statusCode);
  args.pushMap(headers);
  args.pushString(url);

  eventEmitter.emit("didReceiveNetworkResponse", args);
}
项目:react-native-videoplayer    文件:ReactVideoView.java   
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {

    WritableMap error = Arguments.createMap();
    error.putInt(EVENT_PROP_WHAT, what);
    error.putInt(EVENT_PROP_EXTRA, extra);
    WritableMap event = Arguments.createMap();
    event.putMap(EVENT_PROP_ERROR, error);
    mEventEmitter.receiveEvent(getId(), Events.EVENT_ERROR.toString(), event);
    return true;
}
项目:react-native-scandit    文件:ScanditBarcodeHelpers.java   
static public WritableMap rectToWritableMap(RectF rect) {
    WritableMap map = Arguments.createMap();
    map.putDouble("x", rect.left);
    map.putDouble("y", rect.top);
    map.putDouble("width", rect.width());
    map.putDouble("height", rect.height());
    return map;
}
项目:react-native-webrtc    文件:PeerConnectionObserver.java   
@Override
public void onIceConnectionChange(PeerConnection.IceConnectionState iceConnectionState) {
    WritableMap params = Arguments.createMap();
    params.putInt("id", id);
    params.putString("iceConnectionState", iceConnectionStateString(iceConnectionState));

    webRTCModule.sendEvent("peerConnectionIceConnectionChanged", params);
}
项目:RNLearn_Project1    文件:AsyncStorageErrorUtil.java   
/**
 * Create Error object to be passed back to the JS callback.
 */
/* package */ static WritableMap getError(@Nullable String key, String errorMessage) {
  WritableMap errorMap = Arguments.createMap();
  errorMap.putString("message", errorMessage);
  if (key != null) {
    errorMap.putString("key", key);
  }
  return errorMap;
}
项目:RNLearn_Project1    文件:TouchesHelper.java   
/**
 * Creates catalyst pointers array in format that is expected by RCTEventEmitter JS module from
 * given {@param event} instance. This method use {@param reactTarget} parameter to set as a
 * target view id associated with current gesture.
 */
private static WritableArray createsPointersArray(int reactTarget, TouchEvent event) {
  WritableArray touches = Arguments.createArray();
  MotionEvent motionEvent = event.getMotionEvent();

  // Calculate the coordinates for the target view.
  // The MotionEvent contains the X,Y of the touch in the coordinate space of the root view
  // The TouchEvent contains the X,Y of the touch in the coordinate space of the target view
  // Subtracting them allows us to get the coordinates of the target view's top left corner
  // We then use this when computing the view specific touches below
  // Since only one view is actually handling even multiple touches, the values are all relative
  // to this one target view.
  float targetViewCoordinateX = motionEvent.getX() - event.getViewX();
  float targetViewCoordinateY = motionEvent.getY() - event.getViewY();

  for (int index = 0; index < motionEvent.getPointerCount(); index++) {
    WritableMap touch = Arguments.createMap();
    // pageX,Y values are relative to the RootReactView
    // the motionEvent already contains coordinates in that view
    touch.putDouble(PAGE_X_KEY, PixelUtil.toDIPFromPixel(motionEvent.getX(index)));
    touch.putDouble(PAGE_Y_KEY, PixelUtil.toDIPFromPixel(motionEvent.getY(index)));
    // locationX,Y values are relative to the target view
    // To compute the values for the view, we subtract that views location from the event X,Y
    float locationX = motionEvent.getX(index) - targetViewCoordinateX;
    float locationY = motionEvent.getY(index) - targetViewCoordinateY;
    touch.putDouble(LOCATION_X_KEY, PixelUtil.toDIPFromPixel(locationX));
    touch.putDouble(LOCATION_Y_KEY, PixelUtil.toDIPFromPixel(locationY));
    touch.putInt(TARGET_KEY, reactTarget);
    touch.putDouble(TIMESTAMP_KEY, event.getTimestampMs());
    touch.putDouble(POINTER_IDENTIFIER_KEY, motionEvent.getPointerId(index));
    touches.pushMap(touch);
  }

  return touches;
}
项目:react-native-batch    文件:MapUtil.java   
public static WritableMap toWritableMap(Map<String, Object> map) {
    WritableMap writableMap = Arguments.createMap();
    Iterator iterator = map.entrySet().iterator();

    while (iterator.hasNext()) {
        Map.Entry pair = (Map.Entry) iterator.next();
        Object value = pair.getValue();

        if (value == null) {
            writableMap.putNull((String) pair.getKey());
        } else if (value instanceof Boolean) {
            writableMap.putBoolean((String) pair.getKey(), (Boolean) value);
        } else if (value instanceof Double) {
            writableMap.putDouble((String) pair.getKey(), (Double) value);
        } else if (value instanceof Integer) {
            writableMap.putInt((String) pair.getKey(), (Integer) value);
        } else if (value instanceof String) {
            writableMap.putString((String) pair.getKey(), (String) value);
        } else if (value instanceof Map) {
            writableMap.putMap((String) pair.getKey(), MapUtil.toWritableMap((Map<String, Object>) value));
        } else if (value.getClass() != null && value.getClass().isArray()) {
            writableMap.putArray((String) pair.getKey(), ArrayUtil.toWritableArray((Object[]) value));
        }

        iterator.remove();
    }

    return writableMap;
}
项目:react-native-scandit    文件:SGScanditPicker.java   
public PromiseSender(WritableMap promiseResponse) {
    this.promiseResponse = promiseResponse;
    if (promiseResponse.hasKey("commandid")) {
        addResponse();
        nativeAppEventEmitter.emit(COMMAND_DONE_EVENT_NAME, promiseResponse);
    }
}
项目:RNLearn_Project1    文件:ReactSliderEvent.java   
private WritableMap serializeEventData() {
  WritableMap eventData = Arguments.createMap();
  eventData.putInt("target", getViewTag());
  eventData.putDouble("value", getValue());
  eventData.putBoolean("fromUser", isFromUser());
  return eventData;
}
项目:RNLearn_Project1    文件:ReactRootView.java   
private void emitOrientationChanged(final int newRotation) {
  String name;
  double rotationDegrees;
  boolean isLandscape = false;

  switch (newRotation) {
    case Surface.ROTATION_0:
      name = "portrait-primary";
      rotationDegrees = 0.0;
      break;
    case Surface.ROTATION_90:
      name = "landscape-primary";
      rotationDegrees = -90.0;
      isLandscape = true;
      break;
    case Surface.ROTATION_180:
      name = "portrait-secondary";
      rotationDegrees = 180.0;
      break;
    case Surface.ROTATION_270:
      name = "landscape-secondary";
      rotationDegrees = 90.0;
      isLandscape = true;
      break;
    default:
      return;
  }
  WritableMap map = Arguments.createMap();
  map.putString("name", name);
  map.putDouble("rotationDegrees", rotationDegrees);
  map.putBoolean("isLandscape", isLandscape);

  sendEvent("namedOrientationDidChange", map);
}
项目:react-native-stt    文件:SpeechRecognitionListener.java   
@Override
public void onReadyForSpeech(Bundle params) {
  Logger.debug(TAG, "onReadyForSpeech: " + params);
  WritableMap data = Arguments.createMap();
  data.putMap("params", Arguments.fromBundle(params));
  emit(SPEECH_TO_TEXT, data);
}
项目:RNLearn_Project1    文件:ReactRootView.java   
private void sendEvent(String eventName, @Nullable WritableMap params) {
  if (mReactInstanceManager != null) {
    mReactInstanceManager.getCurrentReactContext()
        .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
        .emit(eventName, params);
  }
}
项目:react-native-ibeacons    文件:BeaconsAndroidModule.java   
@ReactMethod
public void getMonitoredRegions(Callback callback) {
    WritableArray array = new WritableNativeArray();
    for (Region region: mBeaconManager.getMonitoredRegions()) {
        WritableMap map = new WritableNativeMap();
        map.putString("identifier", region.getUniqueId());
        map.putString("uuid", region.getId1().toString());
        map.putInt("major", region.getId2() != null ? region.getId2().toInt() : 0);
        map.putInt("minor", region.getId3() != null ? region.getId3().toInt() : 0);
        array.pushMap(map);
    }
    callback.invoke(array);
}
项目:react-native-mercadopago-checkout    文件:MercadoPagoCheckoutEventListener.java   
private WritableMap paymentToMap(@NonNull Payment payment) {
    final String paymentId = payment.getId().toString();
    final String paymentStatus = payment.getStatus();

    final WritableMap map = Arguments.createMap();

    map.putString(PAYMENT_ID, paymentId);
    map.putString(PAYMENT_STATUS, paymentStatus);

    return map;
}
项目:react-native-twitterkit    文件:TweetView.java   
private void handleSuccess() {
  WritableMap evt = Arguments.createMap();

  ReactContext ctx = (ReactContext) getContext();
  ctx.getJSModule(RCTEventEmitter.class).receiveEvent(
          getId(),
          "onLoadSuccess",
          evt);
}
项目:react-native-mssql    文件:MapUtil.java   
public static WritableMap toWritableMap(Map<String, Object> map) {
  WritableMap writableMap = Arguments.createMap();
  Iterator iterator = map.entrySet().iterator();

  while (iterator.hasNext()) {
    Map.Entry pair = (Map.Entry)iterator.next();
    Object value = pair.getValue();

    if (value == null) {
      writableMap.putNull((String) pair.getKey());
    } else if (value instanceof Boolean) {
      writableMap.putBoolean((String) pair.getKey(), (Boolean) value);
    } else if (value instanceof Double) {
      writableMap.putDouble((String) pair.getKey(), (Double) value);
    } else if (value instanceof Integer) {
      writableMap.putInt((String) pair.getKey(), (Integer) value);
    } else if (value instanceof String) {
      writableMap.putString((String) pair.getKey(), (String) value);
    } else if (value instanceof Map) {
      writableMap.putMap((String) pair.getKey(), MapUtil.toWritableMap((Map<String, Object>) value));
    } else if (value.getClass() != null && value.getClass().isArray()) {
      writableMap.putArray((String) pair.getKey(), ArrayUtil.toWritableArray((Object[]) value));
    }

    iterator.remove();
  }

  return writableMap;
}
项目:react-native-cafe-bazaar    文件:CafeBazaar.java   
@ReactMethod
public void consume(String sku,final Promise promise){
  if(userInvo!=null){
    if(userInvo.hasPurchase(sku)){
      mHelper.consumeAsync(userInvo.getPurchase(sku),
      new IabHelper.OnConsumeFinishedListener() {
      public void onConsumeFinished(Purchase purchase, IabResult result) {
        WritableMap params = Arguments.createMap();
         if (result.isSuccess()) {
            // provision the in-app purchase to the user
            promise.resolve(gson.toJson(purchase));
         }
         else {
            // handle error
            promise.reject(E_CONSUME_FAILURE,result.getMessage());
         }
        }
     });
    }
    else{
      promise.reject(E_CONSUME_ERROR,"user did not purchase item");
    }
  }
  else{
    promise.reject(E_CONSUME_INITIAL,"inventory not loaded!");
  }
}
项目:react-native-android-piliplayer    文件:PLVideoTextureViewManager.java   
@Override
public boolean onError(PLMediaPlayer plMediaPlayer, int errorCode) {
    //Log.e(TAG, "Error happened, errorCode = " + errorCode);
    WritableMap event = Arguments.createMap();
    event.putInt("errorCode",errorCode);
    mEventEmitter.receiveEvent(getTargetId(), Events.ERROR.toString(), Arguments.createMap());
    return true;
}
项目:react-native-ibeacons    文件:BeaconsAndroidModule.java   
@ReactMethod
public void getRangedRegions(Callback callback) {
    WritableArray array = new WritableNativeArray();
    for (Region region: mBeaconManager.getRangedRegions()) {
        WritableMap map = new WritableNativeMap();
        map.putString("region", region.getUniqueId());
        map.putString("uuid", region.getId1().toString());
        array.pushMap(map);
    }
    callback.invoke(array);
}
项目:react-native-twilio-chat    文件:RCTConvert.java   
public static WritableMap UserInfo(UserInfo userInfo) {
    WritableMap map = Arguments.createMap();

    map.putString("identity", userInfo.getIdentity());
    map.putString("friendlyName", userInfo.getFriendlyName());
    map.putMap("attributes", jsonToWritableMap(userInfo.getAttributes()));
    map.putBoolean("isOnline", userInfo.isOnline());
    map.putBoolean("isNotifiable", userInfo.isNotifiable());

    return map;
}
项目:react-native-android-speech-recognizer    文件:ListenerMapRecognitionListener.java   
@Override
public void onError(int error) {
  Log.i(TAG, "onError: " + error);
  if (isEnabled(ListenerEvents.ON_ERROR)) {
    WritableMap data = Arguments.createMap();
    data.putInt("error", error);
    emit(ListenerEvents.ON_ERROR, data);
  }
}
项目:react-native-sockets    文件:SocketServer.java   
private void handleIOException(IOException e) {
    //debug log
    Log.e(eTag, "Server IOException", e);
    //emit event
    String message = e.getMessage();
    WritableMap eventParams = Arguments.createMap();
    eventParams.putString("error", message);
    if (message.equals("Socket closed")) {
        sendEvent(mReactContext, event_closed, eventParams);
        isOpen = false;
    } else {
        sendEvent(mReactContext, event_error, eventParams);
    }
}
项目:react-native-android-speech-recognizer    文件:ListenerMapRecognitionListener.java   
@Override
public void onReadyForSpeech(Bundle params) {
  Log.d(TAG, "onReadyForSpeech: " + params);
  if (isEnabled(ListenerEvents.ON_READY_FOR_SPEECH)) {
    WritableMap data = Arguments.createMap();
    data.putMap("params", ArgumentsConverter.fromBundle(params));
    emit(ListenerEvents.ON_READY_FOR_SPEECH, data);
  }
}
项目:RNLearn_Project1    文件:CatalystNativeJavaToJSReturnValuesTestCase.java   
@ReactMethod(isBlockingSynchronousMethod = true)
WritableMap getMap() {
  WritableMap map = new WritableNativeMap();
  map.putBoolean("a", true);
  map.putBoolean("b", false);
  return map;
}