com.facebook.react.bridge.WritableMap Java Examples

The following examples show how to use com.facebook.react.bridge.WritableMap. 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: ImageLoaderModule.java    From react-native-GPay with MIT License 7 votes vote down vote up
@ReactMethod
public void queryCache(final ReadableArray uris, final Promise promise) {
  // perform cache interrogation in async task as disk cache checks are expensive
  new GuardedAsyncTask<Void, Void>(getReactApplicationContext()) {
    @Override
    protected void doInBackgroundGuarded(Void... params) {
      WritableMap result = Arguments.createMap();
      ImagePipeline imagePipeline = Fresco.getImagePipeline();
      for (int i = 0; i < uris.size(); i++) {
        String uriString = uris.getString(i);
        final Uri uri = Uri.parse(uriString);
        if (imagePipeline.isInBitmapMemoryCache(uri)) {
          result.putString(uriString, "memory");
        } else if (imagePipeline.isInDiskCacheSync(uri)) {
          result.putString(uriString, "disk");
        }
      }
      promise.resolve(result);
    }
  }.executeOnExecutor(GuardedAsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #2
Source File: MapUtil.java    From vinci with Apache License 2.0 7 votes vote down vote up
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;
}
 
Example #3
Source File: NearbyConnectionModule.java    From react-native-google-nearby-connection with MIT License 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
	if (getReactApplicationContext().hasActiveCatalystInstance()) {
		String endpointId = intent.getStringExtra("endpointId");
		String endpointName = intent.getStringExtra("endpointName");
		String serviceId = intent.getStringExtra("serviceId");
		String authenticationToken = intent.getStringExtra("authenticationToken");
		Boolean incomingConnection = intent.getBooleanExtra("incomingConnection", false);

		WritableMap out = Arguments.createMap();
		out.putString("endpointId", endpointId);
		out.putString("endpointName", endpointName);
		out.putString("serviceId", serviceId);
		out.putString("authenticationToken", authenticationToken);
		out.putBoolean("incomingConnection", incomingConnection);

		sendEvent(getReactApplicationContext(), "connection_initiated_to_endpoint", out);
	}
}
 
Example #4
Source File: RNInstabugBugReportingModule.java    From Instabug-React-Native with MIT License 6 votes vote down vote up
/**
 * Sets a block of code to be executed right after the SDK's UI is dismissed.
 * This block is executed on the UI thread. Could be used for performing any
 * UI changes after the SDK's UI is dismissed.
 *
 * @param handler - A callback to get executed after
 *                              dismissing the SDK.
 */
@ReactMethod
public void setOnSDKDismissedHandler(final Callback handler) {
    MainThreadHandler.runOnMainThread(new Runnable() {
        @Override
        public void run() {
            try {
                BugReporting.setOnDismissCallback(new OnSdkDismissCallback() {
                    @Override
                    public void call(DismissType dismissType, ReportType reportType) {
                        WritableMap params = Arguments.createMap();
                        params.putString("dismissType", dismissType.toString());
                        params.putString("reportType", reportType.toString());
                        InstabugUtil.sendEvent(getReactApplicationContext(), Constants.IBG_POST_INVOCATION_HANDLER, params);
                    }
                });
            } catch (java.lang.Exception exception) {
                exception.printStackTrace();
            }
        }
    });
}
 
Example #5
Source File: BleManager.java    From react-native-ble-manager with Apache License 2.0 6 votes vote down vote up
@ReactMethod
public void getConnectedPeripherals(ReadableArray serviceUUIDs, Callback callback) {
	Log.d(LOG_TAG, "Get connected peripherals");
	WritableArray map = Arguments.createArray();

	if (getBluetoothAdapter() == null) {
		Log.d(LOG_TAG, "No bluetooth support");
		callback.invoke("No bluetooth support");
		return;
	}

	List<BluetoothDevice> periperals = getBluetoothManager().getConnectedDevices(GATT);
	for (BluetoothDevice entry : periperals) {
		Peripheral peripheral = savePeripheral(entry);
		WritableMap jsonBundle = peripheral.asWritableMap();
		map.pushMap(jsonBundle);
	}
	callback.invoke(null, map);
}
 
Example #6
Source File: NavigationBarColorModule.java    From react-native-navigation-bar-color with MIT License 6 votes vote down vote up
@ReactMethod
public void hideNavigationBar(Promise promise) {
    try {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (getCurrentActivity() != null) {
                    View decorView = getCurrentActivity().getWindow().getDecorView();
                    decorView.setSystemUiVisibility(UI_FLAG_HIDE_NAV_BAR);
                }
            }
        });
    } catch (IllegalViewOperationException e) {
        WritableMap map = Arguments.createMap();
        map.putBoolean("success", false);
        promise.reject("error", e);
    }
}
 
Example #7
Source File: NearbyConnectionModule.java    From react-native-google-nearby-connection with MIT License 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
	if (getReactApplicationContext().hasActiveCatalystInstance()) {
		String serviceId = intent.getStringExtra("serviceId");
		String endpointId = intent.getStringExtra("endpointId");
		int payloadType = intent.getIntExtra("payloadType", -1);
		String payloadId = intent.getStringExtra("payloadId");

		WritableMap out = Arguments.createMap();
		out.putString("serviceId", serviceId);
		out.putString("endpointId", endpointId);
		out.putInt("payloadType", payloadType);
		out.putString("payloadId", payloadId);

		if (payloadType == Payload.Type.FILE) {
			long payloadSize = intent.getLongExtra("payloadSize", -1);
			out.putDouble("payloadSize", payloadSize);
		}

		sendEvent(getReactApplicationContext(), "receive_payload", out);
	}
}
 
Example #8
Source File: QtalkPlugin.java    From imsdk-android with MIT License 6 votes vote down vote up
/**
 * 获取指定联系人nick
 *
 * @param xmppId
 * @param callback
 */
@ReactMethod
public void getContactsNick(String xmppId, final Callback callback) {
    ConnectionUtil.getInstance().getUserCard(xmppId, new IMLogicManager.NickCallBack() {
        @Override
        public void onNickCallBack(Nick nick) {
            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());
            WritableMap map = new WritableNativeMap();
            map.putMap("nick", item);
            callback.invoke(map);
        }
    }, true, false);
}
 
Example #9
Source File: WebSocketModule.java    From react-native-GPay with MIT License 6 votes vote down vote up
@ReactMethod
public void ping(int id) {
  WebSocket client = mWebSocketConnections.get(id);
  if (client == null) {
    // This is a programmer error -- display development warning
    WritableMap params = Arguments.createMap();
    params.putInt("id", id);
    params.putString("message", "client is null");
    sendEvent("websocketFailed", params);
    params = Arguments.createMap();
    params.putInt("id", id);
    params.putInt("code", 0);
    params.putString("reason", "client is null");
    sendEvent("websocketClosed", params);
    mWebSocketConnections.remove(id);
    mContentHandlers.remove(id);
    return;
  }
  try {
    client.send(ByteString.EMPTY);
  } catch (Exception e) {
    notifyWebSocketFailed(id, e.getMessage());
  }
}
 
Example #10
Source File: RCTConvert.java    From react-native-twilio-ip-messaging with MIT License 6 votes vote down vote up
public static WritableMap Member(Member member) {
    WritableMap map = Arguments.createMap();

    map.putMap("userInfo", UserInfo(member.getUserInfo()));
    if (member.getLastConsumedMessageIndex() == null) {
        map.putNull("lastConsumedMessageIndex");
    }
    else {
        map.putInt("lastConsumedMessageIndex", member.getLastConsumedMessageIndex().intValue());
    }
    if (member.getLastConsumptionTimestamp() == null) {
        map.putNull("lastConsumptionTimestamp");
    }
    else {
        map.putString("lastConsumptionTimestamp", member.getLastConsumptionTimestamp());
    }

    return map;
}
 
Example #11
Source File: FusedLocationModule.java    From react-native-fused-location with MIT License 6 votes vote down vote up
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 #12
Source File: OrientationModule.java    From react-native-orientation-locker with MIT License 6 votes vote down vote up
@ReactMethod
public void lockToLandscapeLeft() {
    final Activity activity = getCurrentActivity();
    if (activity == null) return;
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    isLocked = true;

    // force send an UI orientation event
    lastOrientationValue = "LANDSCAPE-LEFT";
    WritableMap params = Arguments.createMap();
    params.putString("orientation", lastOrientationValue);
    if (ctx.hasActiveCatalystInstance()) {
        ctx
        .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
        .emit("orientationDidChange", params);
    }

    // send a locked event
    WritableMap lockParams = Arguments.createMap();
    lockParams.putString("orientation", lastOrientationValue);
    if (ctx.hasActiveCatalystInstance()) {
        ctx
        .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
        .emit("lockDidChange", lockParams);
    }
}
 
Example #13
Source File: QimRNBModule.java    From imsdk-android with MIT License 6 votes vote down vote up
/**
 * 获取指定联系人nick
 *
 * @param xmppId
 * @param callback
 */
@ReactMethod
public void getContactsNick(String xmppId, final Callback callback) {
    ConnectionUtil.getInstance().getUserCard(xmppId, new IMLogicManager.NickCallBack() {
        @Override
        public void onNickCallBack(Nick nick) {
            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());
            WritableMap map = new WritableNativeMap();
            map.putMap("nick", item);
            callback.invoke(map);
        }
    }, true, false);
}
 
Example #14
Source File: InCallManagerModule.java    From react-native-incall-manager with ISC License 6 votes vote down vote up
private WritableMap getAudioDeviceStatusMap() {
    WritableMap data = Arguments.createMap();
    String audioDevicesJson = "[";
    for (AudioDevice s: audioDevices) {
        audioDevicesJson += "\"" + s.name() + "\",";
    }

    // --- strip the last `,`
    if (audioDevicesJson.length() > 1) {
        audioDevicesJson = audioDevicesJson.substring(0, audioDevicesJson.length() - 1);
    }
    audioDevicesJson += "]";

    data.putString("availableAudioDeviceList", audioDevicesJson);
    data.putString("selectedAudioDevice", (selectedAudioDevice == null) ? "" : selectedAudioDevice.name());

    return data;
}
 
Example #15
Source File: FloatingVideoWidgetShowService.java    From rn-floating-video-widget with MIT License 6 votes vote down vote up
public void returnToApp(View view) {
    long seek = videoView.getCurrentPosition();
    Intent intent = getPackageManager().getLaunchIntentForPackage(reactContext.getPackageName());
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
    videoView.setKeepScreenOn(false);
    stopSelf();
    WritableMap args = new Arguments().createMap();
    args.putInt("index", index);
    args.putInt("seek", (int) seek);
    args.putString("type", "close");
    args.putString("url", playingVideo.getString("url"));

    sendEvent(reactContext, "onClose", args);
    onDestroy();
}
 
Example #16
Source File: OTSessionManager.java    From opentok-react-native with MIT License 6 votes vote down vote up
@Override
public void onStreamVideoDimensionsChanged(Session session, Stream stream, int width, int height) {
    ConcurrentHashMap<String, Stream> mSubscriberStreams = sharedState.getSubscriberStreams();
    Stream mStream = mSubscriberStreams.get(stream.getStreamId());
    WritableMap oldVideoDimensions = Arguments.createMap();
    if ( mStream != null ){
        oldVideoDimensions.putInt("height", mStream.getVideoHeight());
        oldVideoDimensions.putInt("width", mStream.getVideoWidth());
    }
    WritableMap newVideoDimensions = Arguments.createMap();
    newVideoDimensions.putInt("height", height);
    newVideoDimensions.putInt("width", width);
    WritableMap eventData = EventUtils.prepareStreamPropertyChangedEventData("videoDimensions", oldVideoDimensions, newVideoDimensions, stream, session);
    sendEventMap(this.getReactApplicationContext(), session.getSessionId() + ":" + sessionPreface + "onStreamPropertyChanged", eventData);
    printLogs("onStreamVideoDimensionsChanged");

}
 
Example #17
Source File: ImageLoadEvent.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
public void dispatch(RCTEventEmitter rctEventEmitter) {
  WritableMap eventData = null;

  if (mImageUri != null || mEventType == ON_LOAD) {
    eventData = Arguments.createMap();

    if (mImageUri != null) {
      eventData.putString("uri", mImageUri);
    }

    if (mEventType == ON_LOAD) {
      WritableMap source = Arguments.createMap();
      source.putDouble("width", mWidth);
      source.putDouble("height", mHeight);
      if (mImageUri != null) {
        source.putString("url", mImageUri);
      }
      eventData.putMap("source", source);
    }
  }

  rctEventEmitter.receiveEvent(getViewTag(), getEventName(), eventData);
}
 
Example #18
Source File: RNGoogleSigninModule.java    From google-signin with MIT License 6 votes vote down vote up
private void handleException(RNGoogleSigninModule moduleInstance, Exception cause,
                             WritableMap userProperties, @Nullable WritableMap settings) {
    boolean isRecoverable = cause instanceof UserRecoverableAuthException;
    if (isRecoverable) {
        boolean shouldRecover = settings != null
                && settings.hasKey(SHOULD_RECOVER)
                && settings.getBoolean(SHOULD_RECOVER);
        if (shouldRecover) {
            attemptRecovery(moduleInstance, cause, userProperties);
        } else {
            moduleInstance.promiseWrapper.reject(ERROR_USER_RECOVERABLE_AUTH, cause);
        }
    } else {
        moduleInstance.promiseWrapper.reject(MODULE_NAME, cause);
    }
}
 
Example #19
Source File: RNInstabugReactnativeModuleTest.java    From Instabug-React-Native with MIT License 6 votes vote down vote up
@Test
public void givenCallback$getAllUserAttributes_whenQuery_thenShouldCallNativeApiAndInvokeCallback() {
    // given
    PowerMockito.mockStatic(Instabug.class);
    PowerMockito.mockStatic(Arguments.class);
    Callback callback = mock(Callback.class);
    // when
    HashMap<String, String> userAttributes = new HashMap<>();
    userAttributes.put("email", "[email protected]");
    PowerMockito.when(Arguments.createMap()).thenReturn(new JavaOnlyMap());
    PowerMockito.when(Instabug.getAllUserAttributes()).thenReturn(userAttributes);
    rnModule.getAllUserAttributes(callback);
    // then
    PowerMockito.verifyStatic(VerificationModeFactory.times(1));
    Instabug.getAllUserAttributes();
    WritableMap expectedMap = new JavaOnlyMap();
    expectedMap.putString("email", "[email protected]");
    verify(callback).invoke(expectedMap);
}
 
Example #20
Source File: OrientationModule.java    From react-native-orientation-locker with MIT License 6 votes vote down vote up
@ReactMethod
public void lockToPortraitUpsideDown() {
    final Activity activity = getCurrentActivity();
    if (activity == null) return;
    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
    isLocked = true;

    // force send an UI orientation event
    lastOrientationValue = "PORTRAIT-UPSIDEDOWN";
    WritableMap params = Arguments.createMap();
    params.putString("orientation", lastOrientationValue);
    if (ctx.hasActiveCatalystInstance()) {
        ctx
        .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
        .emit("orientationDidChange", params);
    }

    // send a locked event
    WritableMap lockParams = Arguments.createMap();
    lockParams.putString("orientation", lastOrientationValue);
    if (ctx.hasActiveCatalystInstance()) {
        ctx
        .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
        .emit("lockDidChange", lockParams);
    }
}
 
Example #21
Source File: FIRMessagingModule.java    From react-native-fcm with MIT License 6 votes vote down vote up
private WritableMap parseIntent(Intent intent){
    WritableMap params;
    Bundle extras = intent.getExtras();
    if (extras != null) {
        try {
            params = Arguments.fromBundle(extras);
        } catch (Exception e){
            Log.e(TAG, e.getMessage());
            params = Arguments.createMap();
        }
    } else {
        params = Arguments.createMap();
    }
    WritableMap fcm = Arguments.createMap();
    fcm.putString("action", intent.getAction());
    params.putMap("fcm", fcm);

    params.putInt("opened_from_tray", 1);
    return params;
}
 
Example #22
Source File: NativeAdView.java    From react-native-fbads with MIT License 6 votes vote down vote up
/**
 * Called by the view manager when adsManager prop is set. Sends serialised
 * version of a native ad back to Javascript.
 *
 * @param nativeAd
 */
public void setNativeAd(NativeAd nativeAd) {
  if (mNativeAd != null) {
    mNativeAd.unregisterView();
  }

  mNativeAd = nativeAd;

  if (nativeAd == null) {
    mEventEmitter.receiveEvent(getId(), "onAdLoaded", null);
    return;
  }

  WritableMap event = Arguments.createMap();
  event.putString("headline", nativeAd.getAdHeadline());
  event.putString("socialContext", nativeAd.getAdSocialContext());
  event.putString("bodyText", nativeAd.getAdBodyText());
  event.putString("callToActionText", nativeAd.getAdCallToAction());
  event.putString("sponsoredTranslation", nativeAd.getSponsoredTranslation());
  event.putString("advertiserName", nativeAd.getAdvertiserName());
  event.putString("promotedTranslation", nativeAd.getPromotedTranslation());
  event.putString("translation", nativeAd.getAdTranslation());
  event.putString("linkDescription", nativeAd.getAdLinkDescription());

  mEventEmitter.receiveEvent(getId(), "onAdLoaded", event);
}
 
Example #23
Source File: OTSessionManager.java    From opentok-react-native with MIT License 6 votes vote down vote up
@Override
public void onVideoDisabled(SubscriberKit subscriber, String reason) {

    String streamId = Utils.getStreamIdBySubscriber(subscriber);
    if (streamId.length() > 0) {
        ConcurrentHashMap<String, Stream> streams = sharedState.getSubscriberStreams();
        Stream mStream = streams.get(streamId);
        WritableMap subscriberInfo = Arguments.createMap();
        if (mStream != null) {
            subscriberInfo.putMap("stream", EventUtils.prepareJSStreamMap(mStream, subscriber.getSession()));
        }
        subscriberInfo.putString("reason", reason);
        sendEventMap(this.getReactApplicationContext(), subscriberPreface + "onVideoDisabled", subscriberInfo);
    }
    printLogs("onVideoDisabled " + reason);
}
 
Example #24
Source File: TokenResponseFactory.java    From react-native-app-auth with MIT License 6 votes vote down vote up
public static final WritableMap tokenResponseToMap(TokenResponse response, AuthorizationResponse authResponse) {
    WritableMap map = Arguments.createMap();

    map.putString("accessToken", response.accessToken);
    map.putMap("authorizeAdditionalParameters", MapUtil.createAdditionalParametersMap(authResponse.additionalParameters));
    map.putMap("tokenAdditionalParameters", MapUtil.createAdditionalParametersMap(response.additionalParameters));
    map.putString("idToken", response.idToken);
    map.putString("refreshToken", response.refreshToken);
    map.putString("tokenType", response.tokenType);
    map.putArray("scopes", createScopeArray(authResponse.scope));

    if (response.accessTokenExpirationTime != null) {
        map.putString("accessTokenExpirationDate", DateUtil.formatTimestamp(response.accessTokenExpirationTime));
    }


    return map;
}
 
Example #25
Source File: DatePickerDialogModule.java    From react-native-GPay with MIT License 5 votes vote down vote up
@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;
  }
}
 
Example #26
Source File: YouTubeView.java    From react-native-youtube with MIT License 5 votes vote down vote up
public void receivedError(String param) {
    WritableMap event = Arguments.createMap();
    ReactContext reactContext = getReactContext();
    event.putString("error", param);
    event.putInt("target", getId());
    reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(getId(), "error", event);
}
 
Example #27
Source File: GeolocationModule.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
@Override
public void onGetGeoCodeResult(GeoCodeResult result) {
    WritableMap params = Arguments.createMap();
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        params.putInt("errcode", -1);
        params.putString("errmsg", result.error.name());
    }
    else {
        params.putDouble("latitude",  result.getLocation().latitude);
        params.putDouble("longitude",  result.getLocation().longitude);
    }
    sendEvent("onGetGeoCodeResult", params);
}
 
Example #28
Source File: ReactTextChangedEvent.java    From react-native-GPay with MIT License 5 votes vote down vote up
private WritableMap serializeEventData() {
  WritableMap eventData = Arguments.createMap();
  eventData.putString("text", mText);
  eventData.putInt("eventCount", mEventCount);
  eventData.putInt("target", getViewTag());
  return eventData;
}
 
Example #29
Source File: AuroraIMUIModule.java    From aurora-imui with MIT License 5 votes vote down vote up
/**
 * 裁剪图片,将图片按比例裁剪成 width * height 大小
 * @param map 包含 path,width,height 参数
 * @param callback 回调包含裁剪后的路径
 */
@ReactMethod
public void scaleImage(ReadableMap map, Callback callback) {
    WritableMap result = Arguments.createMap();
    try {
        String path = map.getString("path");
        int width = map.getInt("width");
        int height = map.getInt("height");
        File file = new File(path);
        if (file.exists() && file.isFile()) {
            Bitmap bitmap = BitmapLoader.getBitmapFromFile(path, width, height);
            String fileName = file.getName();
            String thumbPath = saveBitmapToLocal(bitmap, fileName);
            result.putInt("code", 0);
            result.putString("thumbPath", thumbPath);
            callback.invoke(result);
        } else {
            result.putInt("code", -1);
            result.putString("error", "Path is invalid");
            callback.invoke(result);
        }
    } catch (Exception e) {
        e.printStackTrace();
        result.putInt("code", -1);
        result.putString("error", "Scale error. Should check out log.");
        callback.invoke(result);
    }
}
 
Example #30
Source File: OTSessionManager.java    From opentok-react-native with MIT License 5 votes vote down vote up
@Override
public void onStreamCreated(PublisherKit publisherKit, Stream stream) {

    String publisherId = Utils.getPublisherId(publisherKit);
    ConcurrentHashMap<String, Stream> mSubscriberStreams = sharedState.getSubscriberStreams();
    mSubscriberStreams.put(stream.getStreamId(), stream);
    if (publisherId.length() > 0) {
        String event = publisherId + ":" + publisherPreface + "onStreamCreated";;
        WritableMap streamInfo = EventUtils.prepareJSStreamMap(stream, publisherKit.getSession());
        sendEventMap(this.getReactApplicationContext(), event, streamInfo);
    }
    printLogs("onStreamCreated: Publisher Stream Created. Own stream "+stream.getStreamId());

}