@ReactMethod public void applyShadowForView(final Integer tag, final ReadableMap param) { Log.d(TAG,"AndroidShadowManager applyShadowForView! tag: " + tag); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { return; } UIManagerModule uiManager = reactContext.getNativeModule(UIManagerModule.class); uiManager.addUIBlock(new UIBlock() { @Override public void execute(NativeViewHierarchyManager nvhm) { ReactViewGroup targetView = (ReactViewGroup) nvhm.resolveView(tag); Log.d(TAG,"AndroidShadowManager view w = " + targetView.getWidth() + " h = " + targetView.getHeight()); // targetView.setBackgroundColor(Color.CYAN); targetView.getViewTreeObserver().addOnGlobalLayoutListener(new OutlineAdjuster(targetView,param)); } }); }
/** * Makes sure replaceExistingNonRootView by replacing a view with a new view that has a background * color set. */ @Test public void testReplaceExistingNonRootView() { UIManagerModule uiManager = getUIManagerModule(); TestMoveDeleteHierarchy hierarchy = createMoveDeleteHierarchy(uiManager); int newViewTag = 1234; uiManager.createView( newViewTag, ReactViewManager.REACT_CLASS, hierarchy.rootView, JavaOnlyMap.of("backgroundColor", Color.RED)); uiManager.replaceExistingNonRootView(hierarchy.view2, newViewTag); uiManager.onBatchComplete(); executePendingFrameCallbacks(); assertThat(hierarchy.nativeRootView.getChildCount()).isEqualTo(4); assertThat(hierarchy.nativeRootView.getChildAt(2)).isInstanceOf(ReactViewGroup.class); ReactViewGroup view = (ReactViewGroup) hierarchy.nativeRootView.getChildAt(2); assertThat(view.getBackgroundColor()).isEqualTo(Color.RED); }
/** * Makes sure replaceExistingNonRootView by replacing a view with a new view that has a background * color set. */ @Test public void testReplaceExistingNonRootView() { UIManagerModule uiManager = getUIManagerModule(); TestMoveDeleteHierarchy hierarchy = createMoveDeleteHierarchy(uiManager); int newViewTag = 1234; uiManager.createView( newViewTag, ReactViewManager.REACT_CLASS, hierarchy.rootView, JavaOnlyMap.of("backgroundColor", Color.RED)); uiManager.replaceExistingNonRootView(hierarchy.view2, newViewTag); uiManager.onBatchComplete(); executePendingChoreographerCallbacks(); assertThat(hierarchy.nativeRootView.getChildCount()).isEqualTo(4); assertThat(hierarchy.nativeRootView.getChildAt(2)).isInstanceOf(ReactViewGroup.class); ReactViewGroup view = (ReactViewGroup) hierarchy.nativeRootView.getChildAt(2); assertThat(view.getBackgroundColor()).isEqualTo(Color.RED); }
@Override public void addView(ReactViewGroup parent, View child, int index) { String transitionName = (String) parent.getTag(R.id.react_shared_element_transition_name); String instanceId = (String) parent.getTag(R.id.react_shared_element_screen_instance_id); ReactInterface component = coordinator.componentFromId(instanceId); if (child instanceof ReactImageView) { ReactImageView iv = (ReactImageView) child; // TODO(lmr): do something to wait for image to load } ViewCompat.setTransitionName(child, transitionName); parent.addView(child, index); if (component != null) { component.notifySharedElementAddition(); } }
public void testViewRenderedWithCorrectProperties() { float expectedOpacity = 0.75f; int expectedBackgroundColor = Color.rgb(255, 0, 0); mCatalystInstance.getJSModule(ViewRenderingTestModule.class).renderViewApplication(mRootTag); waitForBridgeAndUIIdle(); ReactViewGroup view = getViewAtPath(mRootView); assertEquals("Incorrect (or not applied) opacity", expectedOpacity, view.getAlpha()); assertEquals( "Incorrect (or not applied) backgroundColor", expectedBackgroundColor, view.getBackgroundColor()); }
@Override public View getChildInDrawingOrderAtIndex(ViewGroup parent, int index) { if (parent instanceof ReactViewGroup) { return parent.getChildAt(((ReactViewGroup) parent).getZIndexMappedChildIndex(index)); } return parent.getChildAt(index); }
private View findTitleTextView(Toolbar toolbar){ for (int i = 0; i < toolbar.getChildCount(); i++) { View toolBarChild = toolbar.getChildAt(i); if (toolBarChild instanceof TextView || toolBarChild instanceof ReactViewGroup) { return toolBarChild; } } return null; }
public OutlineAdjuster(ReactViewGroup mTargetView, ReadableMap mParam) { this.mTargetView = mTargetView; this.mParam = mParam; }
@Override public ReactViewGroup createViewInstance(ThemedReactContext context) { return new ClippableView(context, mEvents); }
@ReactProp(name = "clippableViewID") public void setClippableViewId(ReactViewGroup view, @Nullable String clippableViewId) { ((ClippableView) view).setClippableViewID(clippableViewId); }
@Override public ReactViewGroup createViewInstance(ThemedReactContext context) { return new ReactViewGroup(context); }
@ReactProp(name = "id") public void setIdentifier(ReactViewGroup view, String id) { view.setTag(R.id.react_shared_element_transition_name, id); }
@ReactProp(name = "nativeNavigationInstanceId") public void setInstanceId(ReactViewGroup view, String instanceId) { view.setTag(R.id.react_shared_element_screen_instance_id, instanceId); }
@ReactProp(name = "id") public void setIdentifier(ReactViewGroup view, String id) { view.setTag(R.id.react_shared_element_group_id, id); }
private ReactViewGroup getTabContainer() { return (ReactViewGroup) getChildAt(0); }