add shader plugin

This commit is contained in:
pengfei.zhou
2019-07-22 14:36:32 +08:00
parent 6b0b98a0ad
commit b73312d1e4
9 changed files with 63 additions and 11 deletions

View File

@@ -2,6 +2,7 @@ package com.github.penfeizhou.doric;
import android.text.TextUtils;
import com.github.penfeizhou.doric.plugin.ShaderPlugin;
import com.github.penfeizhou.doric.widget.ViewNode;
import com.github.penfeizhou.doric.utils.DoricMetaInfo;
import com.github.penfeizhou.doric.plugin.DoricJavaPlugin;
@@ -36,6 +37,7 @@ public class DoricRegistry {
}
public DoricRegistry() {
this.registerNativePlugin(ShaderPlugin.class);
this.registerNativePlugin(ModalPlugin.class);
initRegistry(this);
}

View File

@@ -0,0 +1,31 @@
package com.github.penfeizhou.doric.plugin;
import com.github.penfeizhou.doric.DoricContext;
import com.github.penfeizhou.doric.extension.bridge.DoricMethod;
import com.github.penfeizhou.doric.extension.bridge.DoricPlugin;
import com.github.penfeizhou.doric.utils.DoricLog;
import com.github.pengfeizhou.jscore.JSDecoder;
import com.github.pengfeizhou.jscore.JSObject;
/**
* @Description: com.github.penfeizhou.doric.plugin
* @Author: pengfei.zhou
* @CreateDate: 2019-07-22
*/
@DoricPlugin(name = "shader")
public class ShaderPlugin extends DoricJavaPlugin {
public ShaderPlugin(DoricContext doricContext) {
super(doricContext);
}
@DoricMethod
public void render(JSDecoder jsDecoder) {
try {
JSObject jsObject = jsDecoder.decode().asObject();
} catch (Exception e) {
e.printStackTrace();
DoricLog.e("Shader.render:error%s", e.getLocalizedMessage());
}
}
}

View File

@@ -10,6 +10,7 @@ import android.view.WindowManager;
import com.github.penfeizhou.doric.Doric;
import com.github.pengfeizhou.jscore.JSArray;
import com.github.pengfeizhou.jscore.JSDecoder;
import com.github.pengfeizhou.jscore.JSONBuilder;
import com.github.pengfeizhou.jscore.JSValue;
import com.github.pengfeizhou.jscore.JavaValue;
@@ -52,6 +53,8 @@ public class DoricUtils {
public static JavaValue toJavaValue(Object arg) {
if (arg == null) {
return new JavaValue();
} else if (arg instanceof JSONBuilder) {
return new JavaValue(((JSONBuilder) arg).toJSONObject());
} else if (arg instanceof JSONObject) {
return new JavaValue((JSONObject) arg);
} else if (arg instanceof String) {