feat:fix command view cannot find view,let find on UI Thread

This commit is contained in:
pengfei.zhou 2020-03-23 13:23:04 +08:00 committed by osborn
parent 7408d9cfed
commit 2046baa23d
2 changed files with 92 additions and 83 deletions

View File

@ -90,7 +90,10 @@ public class ShaderPlugin extends DoricJavaPlugin {
} }
@DoricMethod @DoricMethod
public void command(JSObject jsObject, final DoricPromise doricPromise) { public void command(final JSObject jsObject, final DoricPromise doricPromise) {
getDoricContext().getDriver().asyncCall(new Callable<Object>() {
@Override
public Object call() throws Exception {
final JSValue[] viewIds = jsObject.getProperty("viewIds").asArray().toArray(); final JSValue[] viewIds = jsObject.getProperty("viewIds").asArray().toArray();
final String name = jsObject.getProperty("name").asString().value(); final String name = jsObject.getProperty("name").asString().value();
final JSValue args = jsObject.getProperty("args"); final JSValue args = jsObject.getProperty("args");
@ -161,6 +164,10 @@ public class ShaderPlugin extends DoricJavaPlugin {
} }
} }
} }
return null;
}
}, ThreadMode.UI);
} }

View File

@ -50,6 +50,7 @@ - (void)render:(NSDictionary *)argument withPromise:(DoricPromise *)promise {
} }
- (void)command:(NSDictionary *)argument withPromise:(DoricPromise *)promise { - (void)command:(NSDictionary *)argument withPromise:(DoricPromise *)promise {
dispatch_async(dispatch_get_main_queue(), ^{
NSArray *viewIds = argument[@"viewIds"]; NSArray *viewIds = argument[@"viewIds"];
id args = argument[@"args"]; id args = argument[@"args"];
NSString *name = argument[@"name"]; NSString *name = argument[@"name"];
@ -68,6 +69,7 @@ - (void)command:(NSDictionary *)argument withPromise:(DoricPromise *)promise {
} else { } else {
[self findClass:[viewNode class] target:viewNode method:name promise:promise argument:args]; [self findClass:[viewNode class] target:viewNode method:name promise:promise argument:args];
} }
});
} }
- (id)createParamWithMethodName:(NSString *)method promise:(DoricPromise *)promise argument:(id)argument { - (id)createParamWithMethodName:(NSString *)method promise:(DoricPromise *)promise argument:(id)argument {