Add getShadowNodeClass method to ViewManager interface.
Differential Revision: D2535731 fb-gh-sync-id: 7a68778ea4ca47b113d73b1d638d74d905ea2da5
This commit is contained in:
parent
393ead59dc
commit
42e9189b77
|
@ -42,7 +42,7 @@ import com.facebook.react.bridge.ReadableMapKeySeyIterator;
|
||||||
* - Create a view with only layout props: a description of that view is created as a
|
* - Create a view with only layout props: a description of that view is created as a
|
||||||
* {@link ReactShadowNode} in UIManagerModule, but this class will not output any commands to
|
* {@link ReactShadowNode} in UIManagerModule, but this class will not output any commands to
|
||||||
* create the view in the native view hierarchy.
|
* create the view in the native view hierarchy.
|
||||||
* - Update a layout-only view to have non-layout props: before issuing the updateProperties call
|
* - Update a layout-only view to have non-layout props: before issuing the updateShadowNode call
|
||||||
* to the native view hierarchy, issue commands to create the view we optimized away move it into
|
* to the native view hierarchy, issue commands to create the view we optimized away move it into
|
||||||
* the view hierarchy
|
* the view hierarchy
|
||||||
* - Manage the children of a view: multiple manageChildren calls for various parent views may be
|
* - Manage the children of a view: multiple manageChildren calls for various parent views may be
|
||||||
|
|
|
@ -23,10 +23,15 @@ public abstract class SimpleViewManager<T extends View> extends
|
||||||
BaseViewManager<T, ReactShadowNode> {
|
BaseViewManager<T, ReactShadowNode> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReactShadowNode createCSSNodeInstance() {
|
public ReactShadowNode createShadowNodeInstance() {
|
||||||
return new ReactShadowNode();
|
return new ReactShadowNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<ReactShadowNode> getShadowNodeClass() {
|
||||||
|
return ReactShadowNode.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateExtraData(T root, Object extraData) {
|
public void updateExtraData(T root, Object extraData) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void createView(int tag, String className, int rootViewTag, ReadableMap props) {
|
public void createView(int tag, String className, int rootViewTag, ReadableMap props) {
|
||||||
ViewManager viewManager = mViewManagers.get(className);
|
ViewManager viewManager = mViewManagers.get(className);
|
||||||
ReactShadowNode cssNode = viewManager.createCSSNodeInstance();
|
ReactShadowNode cssNode = viewManager.createShadowNodeInstance();
|
||||||
ReactShadowNode rootNode = mShadowNodeRegistry.getNode(rootViewTag);
|
ReactShadowNode rootNode = mShadowNodeRegistry.getNode(rootViewTag);
|
||||||
cssNode.setReactTag(tag);
|
cssNode.setReactTag(tag);
|
||||||
cssNode.setViewClassName(className);
|
cssNode.setViewClassName(className);
|
||||||
|
|
|
@ -19,10 +19,15 @@ public abstract class ViewGroupManager <T extends ViewGroup>
|
||||||
extends BaseViewManager<T, ReactShadowNode> {
|
extends BaseViewManager<T, ReactShadowNode> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReactShadowNode createCSSNodeInstance() {
|
public ReactShadowNode createShadowNodeInstance() {
|
||||||
return new ReactShadowNode();
|
return new ReactShadowNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<ReactShadowNode> getShadowNodeClass() {
|
||||||
|
return ReactShadowNode.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateExtraData(T root, Object extraData) {
|
public void updateExtraData(T root, Object extraData) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ import java.util.Map;
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.facebook.csslayout.CSSNode;
|
|
||||||
import com.facebook.react.bridge.ReadableArray;
|
import com.facebook.react.bridge.ReadableArray;
|
||||||
import com.facebook.react.bridge.ReadableMap;
|
import com.facebook.react.bridge.ReadableMap;
|
||||||
import com.facebook.react.bridge.ReadableMapKeySeyIterator;
|
import com.facebook.react.bridge.ReadableMapKeySeyIterator;
|
||||||
|
@ -76,11 +75,23 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode> {
|
||||||
public abstract String getName();
|
public abstract String getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method should return a subclass of {@link CSSNode} which will be then used for measuring
|
* This method should return a subclass of {@link ReactShadowNode} which will be then used for
|
||||||
* position and size of the view. In mose of the cases this should just return an instance of
|
* measuring position and size of the view. In mose of the cases this should just return an
|
||||||
* {@link CSSNode}
|
* instance of {@link ReactShadowNode}
|
||||||
*/
|
*/
|
||||||
public abstract C createCSSNodeInstance();
|
public abstract C createShadowNodeInstance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method should return {@link Class} instance that represent type of shadow node that this
|
||||||
|
* manager will return from {@link #createShadowNodeInstance}.
|
||||||
|
*
|
||||||
|
* This method will be used in the bridge initialization phase to collect properties exposed using
|
||||||
|
* {@link ReactProp} (or {@link ReactPropGroup}) annotation from the {@link ReactShadowNode}
|
||||||
|
* subclass specific for native view this manager provides.
|
||||||
|
*
|
||||||
|
* @return {@link Class} object that represents type of shadow node used by this view manager.
|
||||||
|
*/
|
||||||
|
public abstract Class<? extends C> getShadowNodeClass();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclasses should return a new View instance of the proper type.
|
* Subclasses should return a new View instance of the proper type.
|
||||||
|
@ -108,7 +119,7 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode> {
|
||||||
* when a certain property is present in {@param props} map but the value is null, this property
|
* when a certain property is present in {@param props} map but the value is null, this property
|
||||||
* should be reset to the default value
|
* should be reset to the default value
|
||||||
*
|
*
|
||||||
* TODO(krzysztof) This method should be replaced by updateProperties and removed completely after
|
* TODO(krzysztof) This method should be replaced by updateShadowNode and removed completely after
|
||||||
* all view managers adapt @ReactProp
|
* all view managers adapt @ReactProp
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -219,7 +230,8 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode> {
|
||||||
// TODO(krzysztof): This method will just delegate to ViewManagersPropertyRegistry once
|
// TODO(krzysztof): This method will just delegate to ViewManagersPropertyRegistry once
|
||||||
// refactoring is finished
|
// refactoring is finished
|
||||||
Class cls = getClass();
|
Class cls = getClass();
|
||||||
Map<String, String> nativeProps = ViewManagersPropertyCache.getNativePropsForView(cls);
|
Map<String, String> nativeProps =
|
||||||
|
ViewManagersPropertyCache.getNativePropsForView(cls);
|
||||||
while (cls.getSuperclass() != null) {
|
while (cls.getSuperclass() != null) {
|
||||||
Map<String, UIProp.Type> props = getNativePropsForClass(cls);
|
Map<String, UIProp.Type> props = getNativePropsForClass(cls);
|
||||||
for (Map.Entry<String, UIProp.Type> entry : props.entrySet()) {
|
for (Map.Entry<String, UIProp.Type> entry : props.entrySet()) {
|
||||||
|
|
|
@ -57,10 +57,15 @@ public class ReactProgressBarViewManager extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProgressBarShadowNode createCSSNodeInstance() {
|
public ProgressBarShadowNode createShadowNodeInstance() {
|
||||||
return new ProgressBarShadowNode();
|
return new ProgressBarShadowNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<ProgressBarShadowNode> getShadowNodeClass() {
|
||||||
|
return ProgressBarShadowNode.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateExtraData(FrameLayout root, Object extraData) {
|
public void updateExtraData(FrameLayout root, Object extraData) {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
|
|
@ -21,8 +21,8 @@ import com.facebook.react.bridge.ReactContext;
|
||||||
import com.facebook.react.uimanager.ReactProp;
|
import com.facebook.react.uimanager.ReactProp;
|
||||||
import com.facebook.react.uimanager.ReactShadowNode;
|
import com.facebook.react.uimanager.ReactShadowNode;
|
||||||
import com.facebook.react.uimanager.SimpleViewManager;
|
import com.facebook.react.uimanager.SimpleViewManager;
|
||||||
import com.facebook.react.uimanager.UIManagerModule;
|
|
||||||
import com.facebook.react.uimanager.ThemedReactContext;
|
import com.facebook.react.uimanager.ThemedReactContext;
|
||||||
|
import com.facebook.react.uimanager.UIManagerModule;
|
||||||
import com.facebook.react.uimanager.ViewProps;
|
import com.facebook.react.uimanager.ViewProps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,10 +82,15 @@ public class ReactSwitchManager extends SimpleViewManager<ReactSwitch> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReactShadowNode createCSSNodeInstance() {
|
public ReactShadowNode createShadowNodeInstance() {
|
||||||
return new ReactSwitchShadowNode();
|
return new ReactSwitchShadowNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class getShadowNodeClass() {
|
||||||
|
return ReactSwitchShadowNode.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ReactSwitch createViewInstance(ThemedReactContext context) {
|
protected ReactSwitch createViewInstance(ThemedReactContext context) {
|
||||||
ReactSwitch view = new ReactSwitch(context);
|
ReactSwitch view = new ReactSwitch(context);
|
||||||
|
|
|
@ -42,7 +42,12 @@ public class ReactRawTextManager extends ReactTextViewManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReactTextShadowNode createCSSNodeInstance() {
|
public ReactTextShadowNode createShadowNodeInstance() {
|
||||||
return new ReactTextShadowNode(true);
|
return new ReactTextShadowNode(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<ReactTextShadowNode> getShadowNodeClass() {
|
||||||
|
return ReactTextShadowNode.class;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,12 @@ public class ReactTextViewManager extends BaseViewManager<ReactTextView, ReactTe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReactTextShadowNode createCSSNodeInstance() {
|
public ReactTextShadowNode createShadowNodeInstance() {
|
||||||
return new ReactTextShadowNode(false);
|
return new ReactTextShadowNode(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<ReactTextShadowNode> getShadowNodeClass() {
|
||||||
|
return ReactTextShadowNode.class;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,10 +80,15 @@ public class ReactTextInputManager extends
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReactTextInputShadowNode createCSSNodeInstance() {
|
public ReactTextInputShadowNode createShadowNodeInstance() {
|
||||||
return new ReactTextInputShadowNode();
|
return new ReactTextInputShadowNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<ReactTextInputShadowNode> getShadowNodeClass() {
|
||||||
|
return ReactTextInputShadowNode.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
|
public Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
|
||||||
|
|
Loading…
Reference in New Issue