com.facebook.react.uimanager.ViewManager Java Examples

The following examples show how to use com.facebook.react.uimanager.ViewManager. 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
/**
 * Uses configured {@link ReactPackage} instances to create all view managers.
 */
public List<ViewManager> getOrCreateViewManagers(
    ReactApplicationContext catalystApplicationContext) {
  ReactMarker.logMarker(CREATE_VIEW_MANAGERS_START);
  Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createAllViewManagers");
  try {
    if (mViewManagers == null) {
      synchronized (mPackages) {
        if (mViewManagers == null) {
          mViewManagers = new ArrayList<>();
          for (ReactPackage reactPackage : mPackages) {
            mViewManagers.addAll(reactPackage.createViewManagers(catalystApplicationContext));
          }
          return mViewManagers;
        }
      }
    }
    return mViewManagers;
  } finally {
    Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
    ReactMarker.logMarker(CREATE_VIEW_MANAGERS_END);
  }
}
 
Example #2
Source File: CompositeReactPackage.java    From react-native-GPay with MIT License 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public @Nullable ViewManager createViewManager(
    ReactApplicationContext reactContext, String viewManagerName) {
  ListIterator<ReactPackage> iterator =
      mChildReactPackages.listIterator(mChildReactPackages.size());
  while (iterator.hasPrevious()) {
    ReactPackage reactPackage = iterator.previous();
    if (reactPackage instanceof ViewManagerOnDemandReactPackage) {
      ViewManager viewManager =
          ((ViewManagerOnDemandReactPackage) reactPackage)
              .createViewManager(reactContext, viewManagerName);
      if (viewManager != null) {
        return viewManager;
      }
    }
  }
  return null;
}
 
Example #3
Source File: CatalystNativeJavaToJSReturnValuesTestCase.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();

  final UIManagerModule mUIManager =
      new UIManagerModule(
          getContext(), new ArrayList<ViewManager>(), 0);

  mAssertModule = new AssertModule();

  mInstance = ReactTestHelper.catalystInstanceBuilder(this)
      .addNativeModule(mAssertModule)
      .addNativeModule(new DeviceInfoModule(getContext()))
      .addNativeModule(new AppStateModule(getContext()))
      .addNativeModule(new FakeWebSocketModule())
      .addNativeModule(mUIManager)
      .addNativeModule(new TestModule())
      .build();
}
 
Example #4
Source File: ViewRenderingTestCase.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();

  List<ViewManager> viewManagers = Arrays.<ViewManager>asList(new ReactViewManager());
  final UIManagerModule uiManager =
      new UIManagerModule(getContext(), viewManagers, 0);
  UiThreadUtil.runOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          uiManager.onHostResume();
        }
      });
  waitForIdleSync();

  mCatalystInstance = ReactTestHelper.catalystInstanceBuilder(this)
      .addNativeModule(uiManager)
      .addNativeModule(new AndroidInfoModule(getContext()))
      .addNativeModule(new DeviceInfoModule(getContext()))
      .addNativeModule(new AppStateModule(getContext()))
      .addNativeModule(new FakeWebSocketModule())
      .build();

  mRootView = new ReactRootView(getContext());
  mRootTag = uiManager.addRootView(mRootView);
}
 
Example #5
Source File: RCTCapturePackage.java    From react-native-smart-barcode with MIT License 5 votes vote down vote up
@Override
        public List<ViewManager> createViewManagers(ReactApplicationContext reactApplicationContext) {
            //noinspection ArraysAsListWithZeroOrOneArgument

//            return Arrays.<ViewManager>asList(captureManager,linearGradientViewManager);
            return Arrays.<ViewManager>asList(captureManager);
        }
 
Example #6
Source File: CompositeReactPackageTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testThatCompositeReturnsASumOfViewManagers() {
  // Given
  CompositeReactPackage composite = new CompositeReactPackage(packageNo1, packageNo2);

  ViewManager managerNo1 = mock(ViewManager.class);
  when(managerNo1.getName()).thenReturn("ManagerNo1");

  // managerNo2 and managerNo3 will share same name, composite should return only the latter one
  final String sameModuleName = "SameModuleName";

  ViewManager managerNo2 = mock(ViewManager.class);
  when(managerNo2.getName()).thenReturn(sameModuleName);

  ViewManager managerNo3 = mock(ViewManager.class);
  when(managerNo3.getName()).thenReturn(sameModuleName);

  ViewManager managerNo4 = mock(ViewManager.class);
  when(managerNo4.getName()).thenReturn("ManagerNo4");

  when(packageNo1.createViewManagers(reactContext)).thenReturn(
      Arrays.asList(new ViewManager[]{managerNo1, managerNo2}));

  when(packageNo2.createViewManagers(reactContext)).thenReturn(
      Arrays.asList(new ViewManager[]{managerNo3, managerNo4}));

  // When
  List<ViewManager> compositeModules = composite.createViewManagers(reactContext);

  // Then

  // Wrapping lists into sets to be order-independent.
  // Note that there should be no managerNo2 returned.
  Set<ViewManager> expected = new HashSet<>(
      Arrays.asList(new ViewManager[]{managerNo1, managerNo3, managerNo4})
  );
  Set<ViewManager> actual = new HashSet<>(compositeModules);

  assertEquals(expected, actual);
}
 
Example #7
Source File: MPAndroidChartPackage.java    From react-native-mp-android-chart with MIT License 5 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Arrays.<ViewManager>asList(
        new BarChartManager(),
        new BubbleChartManager(),
        new CandleStickChartManager(),
        new LineChartManager(),
        new PieChartManager(),
        new RadarChartManager(),
        new ScatterChartManager()
    );
}
 
Example #8
Source File: TextInputTest.java    From react-native-GPay with MIT License 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, 0);
  uiManagerModule.onHostResume();
  return uiManagerModule;
}
 
Example #9
Source File: PjSipModulePackage.java    From react-native-pjsip with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Arrays.<ViewManager>asList(
        new PjSipRemoteVideoViewManager(),
        new PjSipPreviewVideoViewManager()
    );
}
 
Example #10
Source File: Web3WebviewPackage.java    From react-native-web3-webview with MIT License 5 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(
        ReactApplicationContext reactContext) {
    return Collections.<ViewManager>singletonList(
            new Web3WebviewManager(reactContext,this)
    );
}
 
Example #11
Source File: RNShineButtonPackage.java    From react-native-shine-button with Apache License 2.0 5 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    List<ViewManager> modules = new ArrayList<>();
    modules.add(new RNShineButton());

    return modules;
}
 
Example #12
Source File: CatalystUIManagerTestCase.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();

  List<ViewManager> viewManagers = Arrays.<ViewManager>asList(
      new ReactViewManager(),
      new ReactTextViewManager(),
      new ReactRawTextManager());
  uiManager =
      new UIManagerModule(getContext(), viewManagers, 0);
  UiThreadUtil.runOnUiThread(new Runnable() {
    @Override
    public void run() {
      uiManager.onHostResume();
    }
  });
  waitForIdleSync();

  jsModule = ReactTestHelper.catalystInstanceBuilder(this)
      .addNativeModule(uiManager)
      .addNativeModule(new AndroidInfoModule(getContext()))
      .addNativeModule(new DeviceInfoModule(getContext()))
      .addNativeModule(new AppStateModule(getContext()))
      .addNativeModule(new FakeWebSocketModule())
      .build()
      .getJSModule(UIManagerTestModule.class);
}
 
Example #13
Source File: ReactVideoPackage.java    From react-native-video with MIT License 5 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    if (config == null) {
        config = new DefaultReactExoplayerConfig(reactContext);
    }
    return Collections.singletonList(new ReactExoplayerViewManager(config));
}
 
Example #14
Source File: CatalystNativeJavaToJSArgumentsTestCase.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
  super.setUp();

  List<ViewManager> viewManagers = Arrays.<ViewManager>asList(
      new ReactViewManager());
  final UIManagerModule mUIManager =
      new UIManagerModule(getContext(), viewManagers, 0);
  UiThreadUtil.runOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          mUIManager.onHostResume();
        }
      });
  waitForIdleSync();

  mAssertModule = new AssertModule();

  mInstance = ReactTestHelper.catalystInstanceBuilder(this)
      .addNativeModule(mAssertModule)
      .addNativeModule(new DeviceInfoModule(getContext()))
      .addNativeModule(new AppStateModule(getContext()))
      .addNativeModule(new FakeWebSocketModule())
      .addNativeModule(mUIManager)
      .build();
}
 
Example #15
Source File: BrightcovePlayerPackage.java    From react-native-brightcove-player with MIT License 5 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Arrays.<ViewManager>asList(
            new BrightcovePlayerManager(reactContext),
            new BrightcovePlayerPosterManager(reactContext)
    );
}
 
Example #16
Source File: RNAKPackage.java    From react-native-android-kit with MIT License 5 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactApplicationContext) {
	return Arrays.<ViewManager>asList(
			new ButtonManager(),
			new FabManager(),
			new TabLayoutManager()
	);
}
 
Example #17
Source File: speechModulePackage.java    From react-native-speech with MIT License 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Collections.emptyList();
}
 
Example #18
Source File: FloatingVideoWidgetPackage.java    From rn-floating-video-widget with MIT License 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
  return Collections.emptyList();
}
 
Example #19
Source File: RNArcGISMapViewPackage.java    From react-native-arcgis-mapview with MIT License 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Arrays.<ViewManager>asList(new RNArcGISMapViewManager());
}
 
Example #20
Source File: RangeSliderPackage.java    From rn-range-slider with MIT License 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    List<ViewManager> viewManagers = new ArrayList<>();
    viewManagers.add(new RangeSliderViewManager());
    return viewManagers;
}
 
Example #21
Source File: ShadowViewPackage.java    From react-native-simple-shadow-view with MIT License 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Arrays.<ViewManager>asList(new RNTShadowViewManager());
}
 
Example #22
Source File: Package.java    From react-native-android-library-boilerplate with The Unlicense 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Collections.emptyList();
}
 
Example #23
Source File: VideoPlayerPackage.java    From react-native-native-video-player with GNU General Public License v3.0 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Collections.emptyList();
}
 
Example #24
Source File: ScratchViewPackage.java    From react-native-scratch with MIT License 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Arrays.<ViewManager>asList(new RNTScratchViewManager());
}
 
Example #25
Source File: BlurryOverlayPackage.java    From react-native-android-blurryoverlay with MIT License 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Arrays.<ViewManager>asList(
            new BlurryOverlayManager(mActivity)
    );
}
 
Example #26
Source File: RNAudioPlayer.java    From react-native-audioplayer with MIT License 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
  return Collections.emptyList();
}
 
Example #27
Source File: TcpSocketPackage.java    From react-native-tcp-socket with MIT License 4 votes vote down vote up
@Override
public @NonNull List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
    return Collections.emptyList();
}
 
Example #28
Source File: IDFAPackage.java    From react-native-idfa with MIT License 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Collections.emptyList();
}
 
Example #29
Source File: MercadoPagoCheckoutPackage.java    From react-native-mercadopago-checkout with MIT License 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
    return Collections.emptyList();
}
 
Example #30
Source File: SmsListenerPackage.java    From react-native-android-sms-listener with MIT License 4 votes vote down vote up
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext context) {
    return Collections.emptyList();
}