doric-cli add createLib
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="pub.doric.android.library">
|
||||
|
||||
</manifest>
|
@@ -0,0 +1,21 @@
|
||||
package pub.doric.library;
|
||||
|
||||
import com.github.pengfeizhou.jscore.JavaValue;
|
||||
|
||||
import pub.doric.DoricContext;
|
||||
import pub.doric.extension.bridge.DoricMethod;
|
||||
import pub.doric.extension.bridge.DoricPlugin;
|
||||
import pub.doric.extension.bridge.DoricPromise;
|
||||
import pub.doric.plugin.DoricJavaPlugin;
|
||||
|
||||
@DoricPlugin(name = "demoPlugin")
|
||||
public class DoricDemoPlugin extends DoricJavaPlugin {
|
||||
public DoricDemoPlugin(DoricContext doricContext) {
|
||||
super(doricContext);
|
||||
}
|
||||
|
||||
@DoricMethod
|
||||
public void call(DoricPromise promise) {
|
||||
promise.resolve(new JavaValue("This is from android"));
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package pub.doric.library;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import pub.doric.Doric;
|
||||
import pub.doric.DoricComponent;
|
||||
import pub.doric.DoricLibrary;
|
||||
import pub.doric.DoricRegistry;
|
||||
|
||||
@DoricComponent
|
||||
public class __$RawName__Library extends DoricLibrary {
|
||||
@Override
|
||||
public void load(DoricRegistry registry) {
|
||||
try {
|
||||
InputStream is = Doric.application().getAssets().open("bundle___$__.js");
|
||||
byte[] bytes = new byte[is.available()];
|
||||
is.read(bytes);
|
||||
String content = new String(bytes);
|
||||
registry.registerJSBundle("__$__", content);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
registry.registerNativePlugin(DoricDemoPlugin.class);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user