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

The following examples show how to use com.facebook.react.bridge.ReactContext#getNativeModule() . 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: ReactInstanceManager.java    From react-native-GPay with 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 File: ReactInstanceManager.java    From react-native-GPay with 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
Source File: ReactTweetViewManager.java    From react-native-twitterkit with MIT License 5 votes vote down vote up
@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 File: NativeAdViewManager.java    From react-native-fbads with 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
Source File: ReactAztecText.java    From react-native-aztec with GNU General Public License v2.0 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 6
Source File: Web3WebviewManager.java    From react-native-web3-webview with MIT License 4 votes vote down vote up
public static Web3WebviewModule getModule(ReactContext reactContext) {
    return reactContext.getNativeModule(Web3WebviewModule.class);
}
 
Example 7
Source File: ReactEditText.java    From react-native-GPay with 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
Source File: FpsDebugFrameCallback.java    From react-native-GPay with MIT License 4 votes vote down vote up
public FpsDebugFrameCallback(ChoreographerCompat choreographer, ReactContext reactContext) {
  mChoreographer = choreographer;
  mReactContext = reactContext;
  mUIManagerModule = reactContext.getNativeModule(UIManagerModule.class);
  mDidJSUpdateUiDuringFrameDetector = new DidJSUpdateUiDuringFrameDetector();
}