Java Code Examples for com.facebook.react.bridge.ReactContext#getNativeModule()

The following examples show how to use com.facebook.react.bridge.ReactContext#getNativeModule() . These examples are extracted from open source projects. 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 Project: react-native-GPay   File: ReactInstanceManager.java    License: MIT License 6 votes vote down vote up
/**
 * This method will give JS the opportunity to receive intents via Linking.
 */
@ThreadConfined(UI)
public void onNewIntent(Intent intent) {
  UiThreadUtil.assertOnUiThread();
  ReactContext currentContext = getCurrentReactContext();
  if (currentContext == null) {
    FLog.w(ReactConstants.TAG, "Instance detached from instance manager");
  } else {
    String action = intent.getAction();
    Uri uri = intent.getData();

    if (Intent.ACTION_VIEW.equals(action) && uri != null) {
      DeviceEventManagerModule deviceEventManagerModule =
        currentContext.getNativeModule(DeviceEventManagerModule.class);
      deviceEventManagerModule.emitNewIntentReceived(uri);
    }

    currentContext.onNewIntent(mCurrentActivity, intent);
  }
}
 
Example 2
Source Project: react-native-GPay   File: ReactInstanceManager.java    License: MIT License 5 votes vote down vote up
/**
 * This method will give JS the opportunity to consume the back button event. If JS does not
 * consume the event, mDefaultBackButtonImpl will be invoked at the end of the round trip to JS.
 */
public void onBackPressed() {
  UiThreadUtil.assertOnUiThread();
  ReactContext reactContext = mCurrentReactContext;
  if (reactContext == null) {
    // Invoke without round trip to JS.
    FLog.w(ReactConstants.TAG, "Instance detached from instance manager");
    invokeDefaultOnBackPressed();
  } else {
    DeviceEventManagerModule deviceEventManagerModule =
      reactContext.getNativeModule(DeviceEventManagerModule.class);
    deviceEventManagerModule.emitHardwareBackPressed();
  }
}
 
Example 3
@Override
public void onSizeChanged(TweetView view, final int width, final int height) {
  Log.d(TAG, "TweetView changed size: " + width + ", " + height);
  ReactContext ctx = (ReactContext) view.getContext();
  final UIManagerModule uiManager = ctx.getNativeModule(UIManagerModule.class);
  final int reactTag = view.getReactTag();

  ctx.runOnNativeModulesQueueThread(new Runnable() {
    @Override
    public void run() {
      uiManager.updateNodeSize(reactTag, width, height);
    }
  });
}
 
Example 4
Source Project: react-native-fbads   File: NativeAdViewManager.java    License: MIT License 5 votes vote down vote up
@ReactProp(name = "adsManager")
public void setAdsManager(NativeAdView view, String adsManagerId) {
  Context viewContext = view.getContext();
  if (viewContext instanceof ReactContext) {
    ReactContext reactContext = (ReactContext) viewContext;
    NativeAdManager adManager = reactContext.getNativeModule(NativeAdManager.class);
    NativeAdsManager adsManager = adManager.getFBAdsManager(adsManagerId);

    view.setNativeAd(adsManager.nextNativeAd());
  } else {
    Log.e("E_NOT_RCT_CONTEXT", "View's context is not a ReactContext, so it's not possible to get NativeAdManager.");
  }
}
 
Example 5
private void setIntrinsicContentSize() {
    ReactContext reactContext = (ReactContext) getContext();
    UIManagerModule uiManager = reactContext.getNativeModule(UIManagerModule.class);
    final ReactTextInputLocalData localData = new ReactTextInputLocalData(this);
    uiManager.setViewLocalData(getId(), localData);
}
 
Example 6
public static Web3WebviewModule getModule(ReactContext reactContext) {
    return reactContext.getNativeModule(Web3WebviewModule.class);
}
 
Example 7
Source Project: react-native-GPay   File: ReactEditText.java    License: MIT License 4 votes vote down vote up
private void setIntrinsicContentSize() {
  ReactContext reactContext = (ReactContext) getContext();
  UIManagerModule uiManager = reactContext.getNativeModule(UIManagerModule.class);
  final ReactTextInputLocalData localData = new ReactTextInputLocalData(this);
  uiManager.setViewLocalData(getId(), localData);
}
 
Example 8
public FpsDebugFrameCallback(ChoreographerCompat choreographer, ReactContext reactContext) {
  mChoreographer = choreographer;
  mReactContext = reactContext;
  mUIManagerModule = reactContext.getNativeModule(UIManagerModule.class);
  mDidJSUpdateUiDuringFrameDetector = new DidJSUpdateUiDuringFrameDetector();
}