Skip to content

Commit

Permalink
Fix Android startup exception
Browse files Browse the repository at this point in the history
Summary:
This is an attempt to fix the following startup exception that I get when running any of the example apps:

> Unrecognized type: interface com.facebook.react.bridge.Dynamic for method: com.facebook.react.uimanager.LayoutShadowNode#setFlexBasis

I really have no idea what I'm doing here, just trying to get UIExplorer to compile and run so I can test my upcoming PRs. ~~Unfortunately, this doesn't actually make the apps run, but at least it does get rid of the startup exception!~~ Edit: it works now.

**Test plan:** Run Movies and UIExplorer example app
Closes #11896

Differential Revision: D4418927

Pulled By: mkonicek

fbshipit-source-id: 34788b790b6bfc46ff39a0d9ca1698a5c20662e1
  • Loading branch information
philikon authored and facebook-github-bot committed Jan 14, 2017
1 parent c7e3819 commit 237ee2d
Showing 1 changed file with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.view.View;

import com.facebook.common.logging.FLog;
import com.facebook.react.bridge.Dynamic;
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
Expand Down Expand Up @@ -114,6 +115,22 @@ public void updateShadowNodeProp(
protected abstract @Nullable Object extractProperty(ReactStylesDiffMap props);
}

private static class DynamicPropSetter extends PropSetter {

public DynamicPropSetter(ReactProp prop, Method setter) {
super(prop, "mixed", setter);
}

public DynamicPropSetter(ReactPropGroup prop, Method setter, int index) {
super(prop, "mixed", setter, index);
}

@Override
protected Object extractProperty(ReactStylesDiffMap props) {
return props.getDynamic(mPropName);
}
}

private static class IntPropSetter extends PropSetter {

private final int mDefaultValue;
Expand Down Expand Up @@ -331,7 +348,9 @@ private static PropSetter createPropSetter(
ReactProp annotation,
Method method,
Class<?> propTypeClass) {
if (propTypeClass == boolean.class) {
if (propTypeClass == Dynamic.class) {
return new DynamicPropSetter(annotation, method);
} else if (propTypeClass == boolean.class) {
return new BooleanPropSetter(annotation, method, annotation.defaultBoolean());
} else if (propTypeClass == int.class) {
return new IntPropSetter(annotation, method, annotation.defaultInt());
Expand Down Expand Up @@ -361,7 +380,13 @@ private static void createPropSetters(
Class<?> propTypeClass,
Map<String, PropSetter> props) {
String[] names = annotation.names();
if (propTypeClass == int.class) {
if (propTypeClass == Dynamic.class) {
for (int i = 0; i < names.length; i++) {
props.put(
names[i],
new DynamicPropSetter(annotation, method, i));
}
} else if (propTypeClass == int.class) {
for (int i = 0; i < names.length; i++) {
props.put(
names[i],
Expand Down

0 comments on commit 237ee2d

Please sign in to comment.