Expose the ReactApplicationContext to createShadowNodeInstance()

Reviewed By: AaaChiuuu

Differential Revision: D5581337

fbshipit-source-id: 5030e4f046ede1a99d22b2ffebbbfe79e7ce9c5d
This commit is contained in:
Andrew Y. Chen 2017-08-10 18:20:42 -07:00 committed by Facebook Github Bot
parent b06672e6cf
commit 64e9b24ef5
2 changed files with 14 additions and 12 deletions

View File

@ -8,11 +8,6 @@
*/ */
package com.facebook.react.uimanager; package com.facebook.react.uimanager;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.List;
import com.facebook.common.logging.FLog; import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions; import com.facebook.infer.annotation.Assertions;
import com.facebook.react.animation.Animation; import com.facebook.react.animation.Animation;
@ -30,6 +25,9 @@ import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.systrace.Systrace; import com.facebook.systrace.Systrace;
import com.facebook.systrace.SystraceMessage; import com.facebook.systrace.SystraceMessage;
import com.facebook.yoga.YogaDirection; import com.facebook.yoga.YogaDirection;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
/** /**
* An class that is used to receive React commands from JS and translate them into a * An class that is used to receive React commands from JS and translate them into a
@ -92,7 +90,7 @@ public class UIImplementation {
protected ReactShadowNode createShadowNode(String className) { protected ReactShadowNode createShadowNode(String className) {
ViewManager viewManager = mViewManagers.get(className); ViewManager viewManager = mViewManagers.get(className);
return viewManager.createShadowNodeInstance(); return viewManager.createShadowNodeInstance(mReactContext);
} }
protected final ReactShadowNode resolveShadowNode(int reactTag) { protected final ReactShadowNode resolveShadowNode(int reactTag) {

View File

@ -9,19 +9,17 @@
package com.facebook.react.uimanager; package com.facebook.react.uimanager;
import javax.annotation.Nullable;
import java.util.Map;
import android.view.View; import android.view.View;
import com.facebook.react.bridge.BaseJavaModule; import com.facebook.react.bridge.BaseJavaModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.touch.JSResponderHandler; import com.facebook.react.touch.JSResponderHandler;
import com.facebook.react.touch.ReactInterceptingViewGroup; import com.facebook.react.touch.ReactInterceptingViewGroup;
import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.annotations.ReactPropGroup; import com.facebook.react.uimanager.annotations.ReactPropGroup;
import com.facebook.react.uimanager.annotations.ReactPropertyHolder; import com.facebook.react.uimanager.annotations.ReactPropertyHolder;
import java.util.Map;
import javax.annotation.Nullable;
/** /**
* Class responsible for knowing how to create and update catalyst Views of a given type. It is also * Class responsible for knowing how to create and update catalyst Views of a given type. It is also
@ -62,7 +60,13 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
* measuring position and size of the view. In mose of the cases this should just return an * measuring position and size of the view. In mose of the cases this should just return an
* instance of {@link ReactShadowNode} * instance of {@link ReactShadowNode}
*/ */
public abstract C createShadowNodeInstance(); public C createShadowNodeInstance() {
throw new RuntimeException("ViewManager subclasses must implement createShadowNodeInstance()");
}
public C createShadowNodeInstance(ReactApplicationContext context) {
return createShadowNodeInstance();
}
/** /**
* This method should return {@link Class} instance that represent type of shadow node that this * This method should return {@link Class} instance that represent type of shadow node that this