com.facebook.react.bridge.ReactApplicationContext#getNativeModule ( )源码实例Demo

下面列出了com.facebook.react.bridge.ReactApplicationContext#getNativeModule ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private @Nullable View resolveView(int tag) {
  UiThreadUtil.assertOnUiThread();
  ReactApplicationContext context = mContext.get();

  if (context != null) {
    UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);

    NativeViewHierarchyManager manager = ReflectUtils.getFieldValue(
      ReflectUtils.getFieldValue(
        uiManager.getUIImplementation(),
        "mOperationsQueue",
        null
      ),
      "mNativeViewHierarchyManager",
      null
    );

    if (manager != null) {
      return manager.resolveView(tag);
    }
  }

  return null;
}
 
源代码2 项目: react-native-GPay   文件: NativeAnimatedModule.java
@Override
public void initialize() {
  ReactApplicationContext reactCtx = getReactApplicationContext();
  UIManagerModule uiManager = reactCtx.getNativeModule(UIManagerModule.class);
  reactCtx.addLifecycleEventListener(this);
  uiManager.addUIManagerListener(this);
}