Java Code Examples for com.facebook.react.bridge.ReactApplicationContext

The following are top voted examples for showing how to use com.facebook.react.bridge.ReactApplicationContext. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: RNLearn_Project1   File: CoreModulesPackage.java   View source code 6 votes vote down vote up
private UIManagerModule createUIManager(ReactApplicationContext reactContext) {
  ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_START);
  Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "createUIManagerModule");
  try {
    List<ViewManager> viewManagersList = mReactInstanceManager.createAllViewManagers(
      reactContext);
    return new UIManagerModule(
      reactContext,
      viewManagersList,
      mUIImplementationProvider,
      mLazyViewManagersEnabled);
  } finally {
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(CREATE_UI_MANAGER_MODULE_END);
  }
}
 
Example 2
Project: RNLearn_Project1   File: CompositeReactPackage.java   View source code 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<NativeModule> createNativeModules(
    ReactApplicationContext reactContext,
    ReactInstanceManager reactInstanceManager) {
  final Map<String, NativeModule> moduleMap = new HashMap<>();
  for (ReactPackage reactPackage: mChildReactPackages) {
    List<NativeModule> nativeModules;
    if (reactPackage instanceof ReactInstancePackage) {
      ReactInstancePackage reactInstancePackage = (ReactInstancePackage) reactPackage;
      nativeModules = reactInstancePackage.createNativeModules(
          reactContext,
          reactInstanceManager);
    } else {
      nativeModules = reactPackage.createNativeModules(reactContext);
    }
    for (NativeModule nativeModule: nativeModules) {
      moduleMap.put(nativeModule.getName(), nativeModule);
    }
  }
  return new ArrayList(moduleMap.values());
}
 
Example 3
Project: RNLearn_Project1   File: DialogModuleTest.java   View source code 6 votes vote down vote up
@Before
public void setUp() throws Exception {
  mActivityController = Robolectric.buildActivity(Activity.class);
  mActivity = mActivityController
      .create()
      .start()
      .resume()
      .get();

  final ReactApplicationContext context = PowerMockito.mock(ReactApplicationContext.class);
  PowerMockito.when(context.hasActiveCatalystInstance()).thenReturn(true);
  PowerMockito.when(context, "getCurrentActivity").thenReturn(mActivity);

  mDialogModule = new DialogModule(context);
  mDialogModule.onHostResume();
}
 
Example 4
Project: RNLearn_Project1   File: LazyReactPackage.java   View source code 6 votes vote down vote up
@Override
public final List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
  List<NativeModule> modules = new ArrayList<>();
  for (ModuleSpec holder : getNativeModules(reactContext)) {
    NativeModule nativeModule;
    SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createNativeModule")
      .arg("module", holder.getType())
      .flush();
    try {
      ReactMarker.logMarker(
        ReactMarkerConstants.CREATE_MODULE_START,
        holder.getType().getSimpleName());
      nativeModule = holder.getProvider().get();
      ReactMarker.logMarker(ReactMarkerConstants.CREATE_MODULE_END);
    } finally {
      Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
    }
    modules.add(nativeModule);
  }
  return modules;
}
 
Example 5
Project: RNLearn_Project1   File: NetworkingModule.java   View source code 6 votes vote down vote up
NetworkingModule(
    ReactApplicationContext reactContext,
    @Nullable String defaultUserAgent,
    OkHttpClient client,
    @Nullable List<NetworkInterceptorCreator> networkInterceptorCreators) {
  super(reactContext);

  if (networkInterceptorCreators != null) {
    OkHttpClient.Builder clientBuilder = client.newBuilder();
    for (NetworkInterceptorCreator networkInterceptorCreator : networkInterceptorCreators) {
      clientBuilder.addNetworkInterceptor(networkInterceptorCreator.create());
    }
    client = clientBuilder.build();
  }
  mClient = client;
  mCookieHandler = new ForwardingCookieHandler(reactContext);
  mCookieJarContainer = (CookieJarContainer) mClient.cookieJar();
  mShuttingDown = false;
  mDefaultUserAgent = defaultUserAgent;
  mRequestIds = new HashSet<>();
}
 
Example 6
Project: react-native-threads   File: ThreadBaseReactPackage.java   View source code 6 votes vote down vote up
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext catalystApplicationContext) {
    return Arrays.<NativeModule>asList(
            // Core list
            new AndroidInfoModule(),
            new ExceptionsManagerModule(reactInstanceManager.getDevSupportManager()),
            new AppStateModule(catalystApplicationContext),
            new Timing(catalystApplicationContext, reactInstanceManager.getDevSupportManager()),
            new UIManagerStubModule(catalystApplicationContext),
            new SourceCodeModule(catalystApplicationContext),
            new JSCHeapCapture(catalystApplicationContext),

            // Main list
            new AsyncStorageModule(catalystApplicationContext),
            new IntentModule(catalystApplicationContext),
            new LocationModule(catalystApplicationContext),
            new NetworkingModule(catalystApplicationContext),
            new NetInfoModule(catalystApplicationContext),
            new VibrationModule(catalystApplicationContext),
            new WebSocketModule(catalystApplicationContext),
            new ThreadSelfModule(catalystApplicationContext)
    );
}
 
Example 7
Project: RNLearn_Project1   File: LazyReactPackage.java   View source code 6 votes vote down vote up
@Override
public final List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
  List<NativeModule> modules = new ArrayList<>();
  for (ModuleSpec holder : getNativeModules(reactContext)) {
    NativeModule nativeModule;
    SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createNativeModule")
      .arg("module", holder.getType())
      .flush();
    try {
      ReactMarker.logMarker(
        ReactMarkerConstants.CREATE_MODULE_START,
        holder.getType().getSimpleName());
      nativeModule = holder.getProvider().get();
      ReactMarker.logMarker(ReactMarkerConstants.CREATE_MODULE_END);
    } finally {
      Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
    }
    modules.add(nativeModule);
  }
  return modules;
}
 
Example 8
Project: react-native-bottomsheet   File: RNBottomSheetPackage.java   View source code 5 votes vote down vote up
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();
    modules.add(new RNBottomSheet(reactContext));

    return modules;
}
 
Example 9
Project: react-native-network-connection-class   File: Package.java   View source code 5 votes vote down vote up
@Override
public List<NativeModule> createNativeModules(
        ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new Module(reactContext));

    return modules;
}
 
Example 10
Project: RNLearn_Project1   File: SimpleViewPropertyTest.java   View source code 5 votes vote down vote up
@Before
public void setup() {
  mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemedContext = new ThemedReactContext(mContext, mContext);
  mManager = new ConcreteViewManager();
}
 
Example 11
Project: RNLearn_Project1   File: UIManagerModuleConstantsTest.java   View source code 5 votes vote down vote up
@Before
public void setUp() {
  mReactContext = new ReactApplicationContext(RuntimeEnvironment.application);
  mUIImplementationProvider = mock(UIImplementationProvider.class);
  when(mUIImplementationProvider.createUIImplementation(
    any(ReactApplicationContext.class),
    any(List.class),
    any(EventDispatcher.class)))
    .thenReturn(mock(UIImplementation.class));
}
 
Example 12
Project: RNLearn_Project1   File: ReactInstanceManager.java   View source code 5 votes vote down vote up
private void setupReactContext(ReactApplicationContext reactContext) {
  ReactMarker.logMarker(PRE_SETUP_REACT_CONTEXT_END);
  ReactMarker.logMarker(SETUP_REACT_CONTEXT_START);
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "setupReactContext");
  UiThreadUtil.assertOnUiThread();
  Assertions.assertCondition(mCurrentReactContext == null);
  mCurrentReactContext = Assertions.assertNotNull(reactContext);
  CatalystInstance catalystInstance =
      Assertions.assertNotNull(reactContext.getCatalystInstance());

  catalystInstance.initialize();
  mDevSupportManager.onNewReactContextCreated(reactContext);
  mMemoryPressureRouter.addMemoryPressureListener(catalystInstance);
  moveReactContextToCurrentLifecycleState();

  for (ReactRootView rootView : mAttachedRootViews) {
    attachMeasuredRootViewToInstance(rootView, catalystInstance);
  }

  ReactInstanceEventListener[] listeners =
    new ReactInstanceEventListener[mReactInstanceEventListeners.size()];
  listeners = mReactInstanceEventListeners.toArray(listeners);

  for (ReactInstanceEventListener listener : listeners) {
    listener.onReactContextInitialized(reactContext);
  }
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
  ReactMarker.logMarker(SETUP_REACT_CONTEXT_END);
}
 
Example 13
Project: react-native-android-wear-demo   File: WearCommunicationReactPackage.java   View source code 5 votes vote down vote up
@Override
public List<NativeModule> createNativeModules(
        ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();
    modules.add(new WearCommunicationModule(reactContext));
    return modules;
}
 
Example 14
Project: react-native-geth   File: GethHolder.java   View source code 5 votes vote down vote up
protected GethHolder(ReactApplicationContext reactContext) {
    this.reactContext = reactContext;
    try {
        NodeConfig nc = new NodeConfig();
        setNodeConfig(nc);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 15
Project: RNLearn_Project1   File: TextInputTest.java   View source code 5 votes vote down vote up
public UIManagerModule getUIManagerModule() {
  ReactApplicationContext reactContext = ReactTestHelper.createCatalystContextForTest();
  List<ViewManager> viewManagers = Arrays.asList(
      new ViewManager[] {
          new ReactTextInputManager(),
      });
  UIManagerModule uiManagerModule = new UIManagerModule(
      reactContext,
      viewManagers,
      new UIImplementationProvider(),
      false);
  uiManagerModule.onHostResume();
  return uiManagerModule;
}
 
Example 16
Project: RNLearn_Project1   File: SimpleViewPropertyTest.java   View source code 5 votes vote down vote up
@Before
public void setup() {
  mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemedContext = new ThemedReactContext(mContext, mContext);
  mManager = new ConcreteViewManager();
}
 
Example 17
Project: nfc-react-native-simple   File: NfcReactNativeSimplePackage.java   View source code 5 votes vote down vote up
/**
 * @param reactContext react application context that can be used to create modules
 * @return list of native modules to register with the newly created catalyst instance
 */
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();
    modules.add(new NfcReactNativeSimpleModule(reactContext));

    return modules;
}
 
Example 18
Project: react-native-cafe-bazaar   File: CafeBazaarPackage.java   View source code 5 votes vote down vote up
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new CafeBazaar(reactContext));

    return modules;
}
 
Example 19
Project: react-native-collapsing-toolbar   File: RNCollapsingToolbarPackage.java   View source code 5 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactApplicationContext) {
    return Arrays.<ViewManager>asList(
            new AppBarLayoutManager(),
            new CoordinatorLayoutManager(),
            new CollapsingToolbarLayoutManager(),
            new CollapsingParallaxManager()
    );
}
 
Example 20
Project: RNLearn_Project1   File: UIImplementation.java   View source code 5 votes vote down vote up
private UIImplementation(
  ReactApplicationContext reactContext,
  ViewManagerRegistry viewManagers,
  EventDispatcher eventDispatcher) {
  this(
      reactContext,
      viewManagers,
      new UIViewOperationQueue(reactContext, new NativeViewHierarchyManager(viewManagers)),
      eventDispatcher);
}
 
Example 21
Project: RNLearn_Project1   File: NativeModuleRegistryBuilder.java   View source code 5 votes vote down vote up
public NativeModuleRegistryBuilder(
  ReactApplicationContext reactApplicationContext,
  ReactInstanceManager reactInstanceManager,
  boolean lazyNativeModulesEnabled) {
  mReactApplicationContext = reactApplicationContext;
  mReactInstanceManager = reactInstanceManager;
  mLazyNativeModulesEnabled = lazyNativeModulesEnabled;
}
 
Example 22
Project: react-native-simple-download-manager   File: ReactNativeDownloadManagerModule.java   View source code 5 votes vote down vote up
public ReactNativeDownloadManagerModule(ReactApplicationContext reactContext) {
    super(reactContext);
    downloader = new Downloader(reactContext);
    appDownloads = new LongSparseArray<>();
    IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
    reactContext.registerReceiver(downloadReceiver, filter);
}
 
Example 23
Project: react-native-threads   File: RNThreadModule.java   View source code 5 votes vote down vote up
public RNThreadModule(final ReactApplicationContext reactContext, ReactNativeHost reactNativehost, ReactPackage additionalThreadPackages[]) {
  super(reactContext);
  this.reactApplicationContext = reactContext;
  threads = new HashMap<>();
  this.reactNativeHost = reactNativehost;
  this.additionalThreadPackages = additionalThreadPackages;
  reactContext.addLifecycleEventListener(this);
}
 
Example 24
Project: RNLearn_Project1   File: ReactTestHelper.java   View source code 5 votes vote down vote up
@Override
public ReactInstanceEasyBuilder addNativeModule(NativeModule nativeModule) {
  if (mNativeModuleRegistryBuilder == null) {
    mNativeModuleRegistryBuilder = new NativeModuleRegistryBuilder(
      (ReactApplicationContext) mContext,
      null,
      false);
  }
  mNativeModuleRegistryBuilder.addNativeModule(nativeModule);
  return this;
}
 
Example 25
Project: RNLearn_Project1   File: ReactSliderPropertyTest.java   View source code 5 votes vote down vote up
@Before
public void setup() {
  ReactApplicationContext mContext = new ReactApplicationContext(RuntimeEnvironment.application);
  CatalystInstance mCatalystInstanceMock = ReactTestHelper.createMockCatalystInstance();
  mContext.initializeWithInstance(mCatalystInstanceMock);
  mThemedContext = new ThemedReactContext(mContext, mContext);
  mManager = new ReactSliderManager();
}
 
Example 26
Project: react-native-location-switch   File: LocationSwitchPackage.java   View source code 5 votes vote down vote up
@Override
public List<NativeModule> createNativeModules(
        ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new Module(reactContext));

    return modules;
}
 
Example 27
Project: react-native-android-library-humaniq-api   File: BlockchainModule.java   View source code 5 votes vote down vote up
public BlockchainModule(ReactApplicationContext reactContext) {
  super(reactContext);
  new Prefs(reactContext);
  ServiceBuilder.init(Constants.BASE_URL, reactContext);

  mixpanel = MixpanelAPI.getInstance(reactContext, Constants.MIXPANEL_TOKEN);
  mixpanel.identify(Prefs.getAccountId());
  mixpanel.getPeople().identify(mixpanel.getDistinctId());
}
 
Example 28
Project: RNLearn_Project1   File: FlatUIImplementation.java   View source code 5 votes vote down vote up
public static FlatUIImplementation createInstance(
    ReactApplicationContext reactContext,
    List<ViewManager> viewManagers,
    EventDispatcher eventDispatcher,
    boolean memoryImprovementEnabled) {

  RCTImageViewManager rctImageViewManager = findRCTImageManager(viewManagers);
  if (rctImageViewManager != null) {
    Object callerContext = rctImageViewManager.getCallerContext();
    if (callerContext != null) {
      RCTImageView.setCallerContext(callerContext);
    }
  }
  DraweeRequestHelper.setResources(reactContext.getResources());

  TypefaceCache.setAssetManager(reactContext.getAssets());

  ViewManagerRegistry viewManagerRegistry = new ViewManagerRegistry(viewManagers);
  FlatNativeViewHierarchyManager nativeViewHierarchyManager = new FlatNativeViewHierarchyManager(
      viewManagerRegistry);
  FlatUIViewOperationQueue operationsQueue = new FlatUIViewOperationQueue(
      reactContext,
      nativeViewHierarchyManager);
  return new FlatUIImplementation(
    reactContext,
    rctImageViewManager,
    viewManagerRegistry,
    operationsQueue,
    eventDispatcher,
    memoryImprovementEnabled
  );
}
 
Example 29
Project: react-native-key-value-storage   File: KeyValueStoragePackage.java   View source code 5 votes vote down vote up
@Override
public List<NativeModule> createNativeModules(
        ReactApplicationContext reactContext) {
    List<NativeModule> modules = new ArrayList<>();

    modules.add(new KeyValueStorageModule(reactContext));

    return modules;
}
 
Example 30
Project: RNLearn_Project1   File: FlatUIImplementation.java   View source code 5 votes vote down vote up
private FlatUIImplementation(
    ReactApplicationContext reactContext,
    @Nullable RCTImageViewManager rctImageViewManager,
    ViewManagerRegistry viewManagers,
    FlatUIViewOperationQueue operationsQueue,
    EventDispatcher eventDispatcher,
    boolean memoryImprovementEnabled) {
  super(reactContext, viewManagers, operationsQueue, eventDispatcher);
  mReactContext = reactContext;
  mRCTImageViewManager = rctImageViewManager;
  mStateBuilder = new StateBuilder(operationsQueue);
  mMemoryImprovementEnabled = memoryImprovementEnabled;
}
 
Example 31
Project: react-native-recyclerview-list   File: RNRecyclerviewListPackage.java   View source code 5 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Arrays.<ViewManager>asList(
            new RecyclerViewBackedScrollViewManager(),
            new RecyclerViewItemViewManager()
    );
}
 
Example 32
Project: react-native-alert   File: PLPAlertPackage.java   View source code 5 votes vote down vote up
@Override
public List<NativeModule> createNativeModules(
                            ReactApplicationContext reactContext) {
  List<NativeModule> modules = new ArrayList<>();

  modules.add(new DialogModule(reactContext));

  return modules;
}
 
Example 33
Project: RNLearn_Project1   File: JSCHeapCapture.java   View source code 4 votes vote down vote up
public JSCHeapCapture(ReactApplicationContext reactContext) {
  super(reactContext);
  mCaptureInProgress = null;
}
 
Example 34
Project: react-native-secure-key-store   File: RNSecureKeyStoreModule.java   View source code 4 votes vote down vote up
public RNSecureKeyStoreModule(ReactApplicationContext reactContext) {
  super(reactContext);
  this.reactContext = reactContext;
}
 
Example 35
Project: react-native-easybluetooth-classic   File: ClassicPackage.java   View source code 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Collections.emptyList();
}
 
Example 36
Project: react-native-immediate-phone-call   File: RNImmediatePhoneCallPackage.java   View source code 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(
        ReactApplicationContext reactContext) {
    return Collections.emptyList();
}
 
Example 37
Project: react-native-udesk   File: UdeskPackage.java   View source code 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Collections.emptyList();
}
 
Example 38
Project: react-native-image-intent   File: ImageIntentPackage.java   View source code 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Collections.emptyList();
}
 
Example 39
Project: RNLearn_Project1   File: ReactPackage.java   View source code 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
  return Collections.emptyList();
}
 
Example 40
Project: react-native-connectivity-status   File: RNConnectivityStatusPackage.java   View source code 4 votes vote down vote up
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
  return Arrays.<NativeModule>asList(new RNConnectivityStatusModule(reactContext));
}