Java源码示例:com.facebook.react.views.view.ReactViewGroup
示例1
/**
* 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);
}
示例2
@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();
}
}
示例3
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());
}
示例4
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;
}
示例5
@Override
protected ReactViewGroup createViewInstance(ThemedReactContext reactContext) {
return new ReactViewGroup(reactContext);
}
示例6
@ReactProp(name = "radius")
public void setRadius(ReactViewGroup view, int Radius) {
mRadius = Radius;
}
示例7
@ReactProp(name = "downsampling")
public void setRadius(ReactViewGroup view, float factor) {
mFactor = factor;
}
示例8
@ReactProp(name = "brightness")
public void setBrightness(ReactViewGroup view, float brightness) {
mBrightness = brightness;
setBlurred(view);
view.requestFocus();
}
示例9
@Override
public ReactViewGroup createViewInstance(ThemedReactContext context) {
return new ClippableView(context, mEvents);
}
示例10
@ReactProp(name = "clippableViewID")
public void setClippableViewId(ReactViewGroup view, @Nullable String clippableViewId) {
((ClippableView) view).setClippableViewID(clippableViewId);
}
示例11
@Before
public void setUp() {
mViewManager = new ReactViewManager();
mView = new ReactViewGroup(RuntimeEnvironment.application);
}
示例12
@Override
public ReactViewGroup createViewInstance(ThemedReactContext context) {
return new ScreenStackHeaderSubview(context);
}
示例13
@Override
public ReactViewGroup createViewInstance(ThemedReactContext context) {
return new ReactViewGroup(context);
}
示例14
@ReactProp(name = "id")
public void setIdentifier(ReactViewGroup view, String id) {
view.setTag(R.id.react_shared_element_transition_name, id);
}
示例15
@ReactProp(name = "nativeNavigationInstanceId")
public void setInstanceId(ReactViewGroup view, String instanceId) {
view.setTag(R.id.react_shared_element_screen_instance_id, instanceId);
}
示例16
@Override
public ReactViewGroup createViewInstance(ThemedReactContext context) {
return new ReactViewGroup(context);
}
示例17
@ReactProp(name = "id")
public void setIdentifier(ReactViewGroup view, String id) {
view.setTag(R.id.react_shared_element_group_id, id);
}