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
|
||||
* {@link ReactShadowNode} in UIManagerModule, but this class will not output any commands to
|
||||
* 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
|
||||
* the view hierarchy
|
||||
* - 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> {
|
||||
|
||||
@Override
|
||||
public ReactShadowNode createCSSNodeInstance() {
|
||||
public ReactShadowNode createShadowNodeInstance() {
|
||||
return new ReactShadowNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ReactShadowNode> getShadowNodeClass() {
|
||||
return ReactShadowNode.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateExtraData(T root, Object extraData) {
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
|
|||
@ReactMethod
|
||||
public void createView(int tag, String className, int rootViewTag, ReadableMap props) {
|
||||
ViewManager viewManager = mViewManagers.get(className);
|
||||
ReactShadowNode cssNode = viewManager.createCSSNodeInstance();
|
||||
ReactShadowNode cssNode = viewManager.createShadowNodeInstance();
|
||||
ReactShadowNode rootNode = mShadowNodeRegistry.getNode(rootViewTag);
|
||||
cssNode.setReactTag(tag);
|
||||
cssNode.setViewClassName(className);
|
||||
|
|
|
@ -19,10 +19,15 @@ public abstract class ViewGroupManager <T extends ViewGroup>
|
|||
extends BaseViewManager<T, ReactShadowNode> {
|
||||
|
||||
@Override
|
||||
public ReactShadowNode createCSSNodeInstance() {
|
||||
public ReactShadowNode createShadowNodeInstance() {
|
||||
return new ReactShadowNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ReactShadowNode> getShadowNodeClass() {
|
||||
return ReactShadowNode.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateExtraData(T root, Object extraData) {
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.util.Map;
|
|||
|
||||
import android.view.View;
|
||||
|
||||
import com.facebook.csslayout.CSSNode;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.ReadableMapKeySeyIterator;
|
||||
|
@ -76,11 +75,23 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode> {
|
|||
public abstract String getName();
|
||||
|
||||
/**
|
||||
* This method should return a subclass of {@link CSSNode} which will be then used for measuring
|
||||
* position and size of the view. In mose of the cases this should just return an instance of
|
||||
* {@link CSSNode}
|
||||
* This method should return a subclass of {@link ReactShadowNode} which will be then used for
|
||||
* measuring position and size of the view. In mose of the cases this should just return an
|
||||
* 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.
|
||||
|
@ -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
|
||||
* 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
|
||||
*/
|
||||
@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
|
||||
// refactoring is finished
|
||||
Class cls = getClass();
|
||||
Map<String, String> nativeProps = ViewManagersPropertyCache.getNativePropsForView(cls);
|
||||
Map<String, String> nativeProps =
|
||||
ViewManagersPropertyCache.getNativePropsForView(cls);
|
||||
while (cls.getSuperclass() != null) {
|
||||
Map<String, UIProp.Type> props = getNativePropsForClass(cls);
|
||||
for (Map.Entry<String, UIProp.Type> entry : props.entrySet()) {
|
||||
|
|
|
@ -57,10 +57,15 @@ public class ReactProgressBarViewManager extends
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProgressBarShadowNode createCSSNodeInstance() {
|
||||
public ProgressBarShadowNode createShadowNodeInstance() {
|
||||
return new ProgressBarShadowNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ProgressBarShadowNode> getShadowNodeClass() {
|
||||
return ProgressBarShadowNode.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateExtraData(FrameLayout root, Object extraData) {
|
||||
// do nothing
|
||||
|
|
|
@ -21,8 +21,8 @@ import com.facebook.react.bridge.ReactContext;
|
|||
import com.facebook.react.uimanager.ReactProp;
|
||||
import com.facebook.react.uimanager.ReactShadowNode;
|
||||
import com.facebook.react.uimanager.SimpleViewManager;
|
||||
import com.facebook.react.uimanager.UIManagerModule;
|
||||
import com.facebook.react.uimanager.ThemedReactContext;
|
||||
import com.facebook.react.uimanager.UIManagerModule;
|
||||
import com.facebook.react.uimanager.ViewProps;
|
||||
|
||||
/**
|
||||
|
@ -82,10 +82,15 @@ public class ReactSwitchManager extends SimpleViewManager<ReactSwitch> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ReactShadowNode createCSSNodeInstance() {
|
||||
public ReactShadowNode createShadowNodeInstance() {
|
||||
return new ReactSwitchShadowNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getShadowNodeClass() {
|
||||
return ReactSwitchShadowNode.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReactSwitch createViewInstance(ThemedReactContext context) {
|
||||
ReactSwitch view = new ReactSwitch(context);
|
||||
|
|
|
@ -42,7 +42,12 @@ public class ReactRawTextManager extends ReactTextViewManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ReactTextShadowNode createCSSNodeInstance() {
|
||||
public ReactTextShadowNode createShadowNodeInstance() {
|
||||
return new ReactTextShadowNode(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ReactTextShadowNode> getShadowNodeClass() {
|
||||
return ReactTextShadowNode.class;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,12 @@ public class ReactTextViewManager extends BaseViewManager<ReactTextView, ReactTe
|
|||
}
|
||||
|
||||
@Override
|
||||
public ReactTextShadowNode createCSSNodeInstance() {
|
||||
public ReactTextShadowNode createShadowNodeInstance() {
|
||||
return new ReactTextShadowNode(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ReactTextShadowNode> getShadowNodeClass() {
|
||||
return ReactTextShadowNode.class;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,10 +80,15 @@ public class ReactTextInputManager extends
|
|||
}
|
||||
|
||||
@Override
|
||||
public ReactTextInputShadowNode createCSSNodeInstance() {
|
||||
public ReactTextInputShadowNode createShadowNodeInstance() {
|
||||
return new ReactTextInputShadowNode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ReactTextInputShadowNode> getShadowNodeClass() {
|
||||
return ReactTextInputShadowNode.class;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
|
||||
|
|
Loading…
Reference in New Issue