/** * Uses configured {@link ReactPackage} instances to create all view managers. */ public List<ViewManager> createAllViewManagers( ReactApplicationContext catalystApplicationContext) { ReactMarker.logMarker(CREATE_VIEW_MANAGERS_START); Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createAllViewManagers"); try { List<ViewManager> allViewManagers = new ArrayList<>(); for (ReactPackage reactPackage : mPackages) { allViewManagers.addAll(reactPackage.createViewManagers(catalystApplicationContext)); } return allViewManagers; } finally { Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); ReactMarker.logMarker(CREATE_VIEW_MANAGERS_END); } }
@Override protected void setUp() throws Exception { super.setUp(); final UIManagerModule mUIManager = new UIManagerModule( getContext(), new ArrayList<ViewManager>(), new UIImplementationProvider(), false); mAssertModule = new AssertModule(); mInstance = ReactTestHelper.catalystInstanceBuilder(this) .addNativeModule(mAssertModule) .addNativeModule(new DeviceInfoModule(getContext())) .addNativeModule(new AppStateModule(getContext())) .addNativeModule(new FakeWebSocketModule()) .addJSModule(TestJavaToJSReturnValuesModule.class) .addNativeModule(mUIManager) .addNativeModule(new TestModule()) .build(); }
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); } }
@Override public FlatUIImplementation createUIImplementation( ReactApplicationContext reactContext, List<ViewManager> viewManagers, EventDispatcher eventDispatcher) { return FlatUIImplementation.createInstance( reactContext, viewManagers, eventDispatcher, mMemoryImprovementEnabled); }
@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, new UIImplementationProvider(), false); UiThreadUtil.runOnUiThread(new Runnable() { @Override public void run() { uiManager.onHostResume(); } }); waitForIdleSync(); jsModule = ReactTestHelper.catalystInstanceBuilder(this) .addNativeModule(uiManager) .addNativeModule(new AndroidInfoModule()) .addNativeModule(new DeviceInfoModule(getContext())) .addNativeModule(new AppStateModule(getContext())) .addNativeModule(new FakeWebSocketModule()) .addJSModule(UIManagerTestModule.class) .build() .getJSModule(UIManagerTestModule.class); }
@Override public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { List<ModuleSpec> viewManagerModuleSpecs = getViewManagers(reactContext); if (viewManagerModuleSpecs == null || viewManagerModuleSpecs.isEmpty()) { return Collections.emptyList(); } List<ViewManager> viewManagers = new ArrayList<>(); for (ModuleSpec moduleSpec : viewManagerModuleSpecs) { viewManagers.add((ViewManager) moduleSpec.getProvider().get()); } return viewManagers; }
@Override protected void setUp() throws Exception { super.setUp(); List<ViewManager> viewManagers = Arrays.<ViewManager>asList(new ReactViewManager()); final UIManagerModule uiManager = new UIManagerModule( getContext(), viewManagers, new UIImplementationProvider(), false); UiThreadUtil.runOnUiThread( new Runnable() { @Override public void run() { uiManager.onHostResume(); } }); waitForIdleSync(); mCatalystInstance = ReactTestHelper.catalystInstanceBuilder(this) .addNativeModule(uiManager) .addNativeModule(new AndroidInfoModule()) .addNativeModule(new DeviceInfoModule(getContext())) .addNativeModule(new AppStateModule(getContext())) .addNativeModule(new FakeWebSocketModule()) .addJSModule(ViewRenderingTestModule.class) .build(); mRootView = new ReactRootView(getContext()); mRootTag = uiManager.addMeasuredRootView(mRootView); }
@Override protected ReactShadowNode createShadowNode(String className) { ReactShadowNode cssNode = super.createShadowNode(className); if (cssNode instanceof FlatShadowNode || cssNode.isVirtual()) { return cssNode; } ViewManager viewManager = resolveViewManager(className); return new NativeViewWrapper(viewManager); }
private static @Nullable RCTImageViewManager findRCTImageManager(List<ViewManager> viewManagers) { for (int i = 0, size = viewManagers.size(); i != size; ++i) { if (viewManagers.get(i) instanceof RCTImageViewManager) { return (RCTImageViewManager) viewManagers.get(i); } } return null; }
@Override protected void setUp() throws Exception { super.setUp(); List<ViewManager> viewManagers = Arrays.<ViewManager>asList( new ReactViewManager()); final UIManagerModule mUIManager = new UIManagerModule( getContext(), viewManagers, new UIImplementationProvider(), false); UiThreadUtil.runOnUiThread( new Runnable() { @Override public void run() { mUIManager.onHostResume(); } }); waitForIdleSync(); mStringRecordingModule = new StringRecordingModule(); mInstance = ReactTestHelper.catalystInstanceBuilder(this) .addNativeModule(mStringRecordingModule) .addNativeModule(mUIManager) .addNativeModule(new DeviceInfoModule(getContext())) .addNativeModule(new AppStateModule(getContext())) .addNativeModule(new FakeWebSocketModule()) .addJSModule(TestJSLocaleModule.class) .build(); }
@Override protected void setUp() throws Exception { super.setUp(); List<ViewManager> viewManagers = Arrays.<ViewManager>asList( new ReactViewManager()); final UIManagerModule mUIManager = new UIManagerModule( getContext(), viewManagers, new UIImplementationProvider(), false); UiThreadUtil.runOnUiThread( new Runnable() { @Override public void run() { mUIManager.onHostResume(); } }); waitForIdleSync(); mRecordingTestModule = new RecordingTestModule(); mCatalystInstance = ReactTestHelper.catalystInstanceBuilder(this) .addNativeModule(mRecordingTestModule) .addNativeModule(new AndroidInfoModule()) .addNativeModule(new DeviceInfoModule(getContext())) .addNativeModule(new AppStateModule(getContext())) .addNativeModule(new FakeWebSocketModule()) .addNativeModule(mUIManager) .addJSModule(TestJSToJavaParametersModule.class) .build(); }
@Override protected void setUp() throws Exception { super.setUp(); List<ViewManager> viewManagers = Arrays.<ViewManager>asList( new ReactViewManager()); final UIManagerModule mUIManager = new UIManagerModule( getContext(), viewManagers, new UIImplementationProvider(), false); 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()) .addJSModule(TestJavaToJSArgumentsModule.class) .addNativeModule(mUIManager) .build(); }
@Override protected void setUp() throws Exception { super.setUp(); List<ViewManager> viewManagers = Arrays.<ViewManager>asList( new ReactViewManager(), new ReactProgressBarViewManager()); mUIManager = new UIManagerModule( getContext(), viewManagers, new UIImplementationProvider(), false); UiThreadUtil.runOnUiThread( new Runnable() { @Override public void run() { mUIManager.onHostResume(); } }); waitForIdleSync(); mInstance = ReactTestHelper.catalystInstanceBuilder(this) .addNativeModule(mUIManager) .addNativeModule(new AndroidInfoModule()) .addNativeModule(new DeviceInfoModule(getContext())) .addNativeModule(new AppStateModule(getContext())) .addNativeModule(new FakeWebSocketModule()) .addJSModule(ProgressBarTestModule.class) .build(); mRootView = new ReactRootView(getContext()); DisplayMetrics metrics = getContext().getResources().getDisplayMetrics(); mRootView.setLayoutParams( new FrameLayout.LayoutParams(metrics.widthPixels, metrics.heightPixels)); int rootTag = mUIManager.addMeasuredRootView(mRootView); mInstance.getJSModule(ProgressBarTestModule.class).renderProgressBarApplication(rootTag); waitForBridgeAndUIIdle(); }
@Override public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { return Arrays.<ViewManager>asList( //new PiliLiveViewManager(), new PiliPlayerViewManager(), new PiliLiveViewManager() //new PiliAudioStreamingViewManager() ); }
@Override public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { return Arrays.<ViewManager>asList( new PiliStreamingViewManager(), new PiliPlayerViewManager(), new PiliAudioStreamingViewManager() ); }
@Override public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { return Collections.<ViewManager>singletonList( new MaterialCalendarViewManager() ); }
@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); }
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 ); }
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; }
public UIManagerModule getUIManagerModule() { ReactApplicationContext reactContext = ReactTestHelper.createCatalystContextForTest(); List<ViewManager> viewManagers = Arrays.asList( new ViewManager[] { new ReactTextViewManager(), new ReactRawTextManager(), }); UIManagerModule uiManagerModule = new UIManagerModule( reactContext, viewManagers, new UIImplementationProvider(), false); uiManagerModule.onHostResume(); return uiManagerModule; }
public List<ViewManager> getExtraViewManagers() { return mViewManagers; }
@Override public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { return Collections.emptyList(); }
@Override public List<ViewManager> createViewManagers( ReactApplicationContext reactContext) { return Collections.emptyList(); }
@Override public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { List<ViewManager> viewManagers = new ArrayList<>(); viewManagers.add(ARTRenderableViewManager.createARTGroupViewManager()); viewManagers.add(ARTRenderableViewManager.createARTShapeViewManager()); viewManagers.add(ARTRenderableViewManager.createARTTextViewManager()); viewManagers.add(new ARTSurfaceViewManager()); viewManagers.add(new ReactDialogPickerManager()); viewManagers.add(new ReactDrawerLayoutManager()); viewManagers.add(new ReactDropdownPickerManager()); viewManagers.add(new ReactHorizontalScrollViewManager()); viewManagers.add(new ReactImageManager()); viewManagers.add(new ReactModalHostManager()); viewManagers.add(new ReactProgressBarViewManager()); viewManagers.add(new ReactRawTextManager()); viewManagers.add(new ReactScrollViewManager()); viewManagers.add(new ReactSliderManager()); viewManagers.add(new ReactSwitchManager()); viewManagers.add(new FrescoBasedReactTextInlineImageViewManager()); viewManagers.add(new ReactTextInputManager()); viewManagers.add(new ReactTextViewManager()); viewManagers.add(new ReactToolbarManager()); viewManagers.add(new ReactViewManager()); viewManagers.add(new ReactViewPagerManager()); viewManagers.add(new ReactVirtualTextViewManager()); viewManagers.add(new ReactWebViewManager()); viewManagers.add(new SwipeRefreshLayoutManager()); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(reactContext); if (preferences.getBoolean("flat_uiimplementation", false)) { viewManagers.addAll(Arrays.asList( new RCTViewManager(), new RCTTextManager(), new RCTRawTextManager(), new RCTVirtualTextManager(), new RCTTextInlineImageManager(), new RCTImageViewManager(), new RCTTextInputManager(), new RCTViewPagerManager(), new FlatARTSurfaceViewManager(), new RCTModalHostManager())); } return viewManagers; }
@Override public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) { return Collections.<ViewManager>singletonList( new CameraViewManager() ); }