use of com.taobao.weex.bridge.Invoker in project incubator-weex by apache.
the class WXComponent method updateProperties.
@Deprecated
public void updateProperties(Map<String, Object> props) {
if (props == null || (mHost == null && !isVirtualComponent())) {
return;
}
for (Map.Entry<String, Object> entry : props.entrySet()) {
String key = entry.getKey();
Object param = entry.getValue();
String value = WXUtils.getString(param, null);
if (TextUtils.isEmpty(value)) {
param = convertEmptyProperty(key, value);
}
if (!setProperty(key, param)) {
if (mHolder == null) {
return;
}
Invoker invoker = mHolder.getPropertyInvoker(key);
if (invoker != null) {
try {
Type[] paramClazzs = invoker.getParameterTypes();
if (paramClazzs.length != 1) {
WXLogUtils.e("[WXComponent] setX method only one parameter:" + invoker);
return;
}
param = WXReflectionUtils.parseArgument(paramClazzs[0], param);
invoker.invoke(this, param);
} catch (Exception e) {
WXLogUtils.e("[WXComponent] updateProperties :" + "class:" + getClass() + "method:" + invoker.toString() + " function " + WXLogUtils.getStackTrace(e));
}
}
}
}
readyToRender();
if (this instanceof FlatComponent && mBackgroundDrawable != null) {
FlatComponent flatComponent = (FlatComponent) this;
if (!flatComponent.promoteToView(true) && !(flatComponent.getOrCreateFlatWidget() instanceof AndroidViewWidget)) {
flatComponent.getOrCreateFlatWidget().setBackgroundAndBorder(mBackgroundDrawable);
}
}
}
use of com.taobao.weex.bridge.Invoker in project incubator-weex by apache.
the class SimpleComponentHolder method getMethods.
public static Pair<Map<String, Invoker>, Map<String, Invoker>> getMethods(Class clz) {
Map<String, Invoker> methods = new HashMap<>();
Map<String, Invoker> mInvokers = new HashMap<>();
Annotation[] annotations;
Annotation anno;
try {
for (Method method : clz.getMethods()) {
try {
annotations = method.getDeclaredAnnotations();
for (int i = 0, annotationsCount = annotations.length; i < annotationsCount; ++i) {
anno = annotations[i];
if (anno == null) {
continue;
}
if (anno instanceof WXComponentProp) {
String name = ((WXComponentProp) anno).name();
methods.put(name, new MethodInvoker(method, true));
break;
} else if (anno instanceof JSMethod) {
JSMethod methodAnno = (JSMethod) anno;
String name = methodAnno.alias();
if (JSMethod.NOT_SET.equals(name)) {
name = method.getName();
}
mInvokers.put(name, new MethodInvoker(method, methodAnno.uiThread()));
break;
}
}
} catch (ArrayIndexOutOfBoundsException | IncompatibleClassChangeError e) {
// ignore: getDeclaredAnnotations may throw this
}
}
} catch (IndexOutOfBoundsException e) {
e.printStackTrace();
// ignore: getMethods may throw this
}
return new Pair<>(methods, mInvokers);
}
Aggregations