use of com.taobao.weex.bridge.MethodInvoker in project weex-example by KalicyZhou.
the class TypeModuleFactory method generateMethodMap.
private void generateMethodMap() {
if (WXEnvironment.isApkDebugable()) {
WXLogUtils.d(TAG, "extractMethodNames:" + mClazz.getSimpleName());
}
HashMap<String, Invoker> methodMap = new HashMap<>();
try {
for (Method method : mClazz.getMethods()) {
// iterates all the annotations available in the method
for (Annotation anno : method.getDeclaredAnnotations()) {
if (anno != null) {
if (anno instanceof JSMethod) {
JSMethod methodAnnotation = (JSMethod) anno;
String name = JSMethod.NOT_SET.equals(methodAnnotation.alias()) ? method.getName() : methodAnnotation.alias();
methodMap.put(name, new MethodInvoker(method, methodAnnotation.uiThread()));
break;
} else if (anno instanceof WXModuleAnno) {
WXModuleAnno methodAnnotation = (WXModuleAnno) anno;
methodMap.put(method.getName(), new MethodInvoker(method, methodAnnotation.runOnUIThread()));
break;
}
}
}
}
} catch (Throwable e) {
WXLogUtils.e("[WXModuleManager] extractMethodNames:", e);
}
mMethodMap = methodMap;
}
use of com.taobao.weex.bridge.MethodInvoker in project incubator-weex by apache.
the class ConfigModuleFactory method generateMethodMap.
private void generateMethodMap() {
if (WXEnvironment.isApkDebugable()) {
WXLogUtils.d(TAG, "extractMethodNames:" + mClazz.getSimpleName());
}
HashMap<String, Invoker> methodMap = new HashMap<>();
try {
for (Method method : mClazz.getMethods()) {
// iterates all the annotations available in the method
for (Annotation anno : method.getDeclaredAnnotations()) {
if (anno != null) {
if (anno instanceof JSMethod) {
JSMethod methodAnnotation = (JSMethod) anno;
String name = JSMethod.NOT_SET.equals(methodAnnotation.alias()) ? method.getName() : methodAnnotation.alias();
methodMap.put(name, new MethodInvoker(method, methodAnnotation.uiThread()));
break;
} else if (anno instanceof WXModuleAnno) {
WXModuleAnno methodAnnotation = (WXModuleAnno) anno;
methodMap.put(method.getName(), new MethodInvoker(method, methodAnnotation.runOnUIThread()));
break;
}
}
}
}
} catch (Throwable e) {
WXLogUtils.e("[WXModuleManager] extractMethodNames:", e);
}
mMethodMap = methodMap;
}
use of com.taobao.weex.bridge.MethodInvoker in project incubator-weex by apache.
the class TypeModuleFactory method generateMethodMap.
private void generateMethodMap() {
if (WXEnvironment.isApkDebugable()) {
WXLogUtils.d(TAG, "extractMethodNames:" + mClazz.getSimpleName());
}
HashMap<String, Invoker> methodMap = new HashMap<>();
try {
for (Method method : mClazz.getMethods()) {
// iterates all the annotations available in the method
for (Annotation anno : method.getDeclaredAnnotations()) {
if (anno != null) {
if (anno instanceof JSMethod) {
JSMethod methodAnnotation = (JSMethod) anno;
String name = JSMethod.NOT_SET.equals(methodAnnotation.alias()) ? method.getName() : methodAnnotation.alias();
methodMap.put(name, new MethodInvoker(method, methodAnnotation.uiThread()));
break;
} else if (anno instanceof WXModuleAnno) {
WXModuleAnno methodAnnotation = (WXModuleAnno) anno;
methodMap.put(method.getName(), new MethodInvoker(method, methodAnnotation.runOnUIThread()));
break;
}
}
}
}
} catch (Throwable e) {
WXLogUtils.e("[WXModuleManager] extractMethodNames:", e);
}
mMethodMap = methodMap;
}
use of com.taobao.weex.bridge.MethodInvoker in project weex-example by KalicyZhou.
the class SimpleComponentHolder method getMethods.
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);
}
use of com.taobao.weex.bridge.MethodInvoker 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