Kill @UIProp in favor of @ReactProp.

Differential Revision: D2582624

fb-gh-sync-id: b04b4c90ee478d995968cab4364e1ab0964b6ebe
This commit is contained in:
Krzysztof Magiera
2015-10-26 14:26:08 -07:00
committed by facebook-github-bot-9
parent 6a7567e742
commit 137a0b8611
5 changed files with 1 additions and 100 deletions

View File

@@ -11,8 +11,6 @@ package com.facebook.react.uimanager;
import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import android.view.View;
@@ -30,8 +28,6 @@ import com.facebook.react.touch.JSResponderHandler;
*/
public abstract class ViewManager<T extends View, C extends ReactShadowNode> {
private static final Map<Class, Map<String, UIProp.Type>> CLASS_PROP_CACHE = new HashMap<>();
public final void updateProperties(T viewToUpdate, CatalystStylesDiffMap props) {
Map<String, ViewManagersPropertyCache.PropSetter> propSetters =
ViewManagersPropertyCache.getNativePropSettersForViewManagerClass(getClass());
@@ -208,42 +204,6 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode> {
}
public Map<String, String> getNativeProps() {
// TODO(krzysztof): This method will just delegate to ViewManagersPropertyRegistry once
// refactoring is finished
Class cls = getClass();
Map<String, String> nativeProps =
ViewManagersPropertyCache.getNativePropsForView(cls, getShadowNodeClass());
while (cls.getSuperclass() != null) {
Map<String, UIProp.Type> props = getNativePropsForClass(cls);
for (Map.Entry<String, UIProp.Type> entry : props.entrySet()) {
nativeProps.put(entry.getKey(), entry.getValue().toString());
}
cls = cls.getSuperclass();
}
return nativeProps;
}
private Map<String, UIProp.Type> getNativePropsForClass(Class cls) {
// TODO(krzysztof): Blow up this method once refactoring is finished
Map<String, UIProp.Type> props = CLASS_PROP_CACHE.get(cls);
if (props != null) {
return props;
}
props = new HashMap<>();
for (Field f : cls.getDeclaredFields()) {
UIProp annotation = f.getAnnotation(UIProp.class);
if (annotation != null) {
UIProp.Type type = annotation.value();
try {
String name = (String) f.get(this);
props.put(name, type);
} catch (IllegalAccessException e) {
throw new RuntimeException(
"UIProp " + cls.getName() + "." + f.getName() + " must be public.");
}
}
}
CLASS_PROP_CACHE.put(cls, props);
return props;
return ViewManagersPropertyCache.getNativePropsForView(getClass(), getShadowNodeClass());
}
}