feat:add Popover for Android step2
This commit is contained in:
parent
33336b0873
commit
152f136b67
@ -64,6 +64,9 @@ public class DoricContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ViewNode targetViewNode(String id) {
|
public ViewNode targetViewNode(String id) {
|
||||||
|
if (id.equals(mRootNode.getId())) {
|
||||||
|
return mRootNode;
|
||||||
|
}
|
||||||
return mHeadNodes.get(id);
|
return mHeadNodes.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import pub.doric.loader.IDoricJSLoader;
|
|||||||
import pub.doric.plugin.NavBarPlugin;
|
import pub.doric.plugin.NavBarPlugin;
|
||||||
import pub.doric.plugin.NavigatorPlugin;
|
import pub.doric.plugin.NavigatorPlugin;
|
||||||
import pub.doric.plugin.NetworkPlugin;
|
import pub.doric.plugin.NetworkPlugin;
|
||||||
|
import pub.doric.plugin.PopoverPlugin;
|
||||||
import pub.doric.plugin.ShaderPlugin;
|
import pub.doric.plugin.ShaderPlugin;
|
||||||
import pub.doric.plugin.StoragePlugin;
|
import pub.doric.plugin.StoragePlugin;
|
||||||
import pub.doric.refresh.RefreshableNode;
|
import pub.doric.refresh.RefreshableNode;
|
||||||
@ -87,6 +88,7 @@ public class DoricRegistry {
|
|||||||
this.registerNativePlugin(StoragePlugin.class);
|
this.registerNativePlugin(StoragePlugin.class);
|
||||||
this.registerNativePlugin(NavigatorPlugin.class);
|
this.registerNativePlugin(NavigatorPlugin.class);
|
||||||
this.registerNativePlugin(NavBarPlugin.class);
|
this.registerNativePlugin(NavBarPlugin.class);
|
||||||
|
this.registerNativePlugin(PopoverPlugin.class);
|
||||||
|
|
||||||
this.registerViewNode(RootNode.class);
|
this.registerViewNode(RootNode.class);
|
||||||
this.registerViewNode(TextNode.class);
|
this.registerViewNode(TextNode.class);
|
||||||
|
@ -2,12 +2,14 @@ package pub.doric.plugin;
|
|||||||
|
|
||||||
import com.github.pengfeizhou.jscore.JSDecoder;
|
import com.github.pengfeizhou.jscore.JSDecoder;
|
||||||
import com.github.pengfeizhou.jscore.JSObject;
|
import com.github.pengfeizhou.jscore.JSObject;
|
||||||
|
import com.github.pengfeizhou.jscore.JSValue;
|
||||||
import com.github.pengfeizhou.jscore.JavaValue;
|
import com.github.pengfeizhou.jscore.JavaValue;
|
||||||
|
|
||||||
import pub.doric.DoricContext;
|
import pub.doric.DoricContext;
|
||||||
import pub.doric.extension.bridge.DoricMethod;
|
import pub.doric.extension.bridge.DoricMethod;
|
||||||
import pub.doric.extension.bridge.DoricPlugin;
|
import pub.doric.extension.bridge.DoricPlugin;
|
||||||
import pub.doric.extension.bridge.DoricPromise;
|
import pub.doric.extension.bridge.DoricPromise;
|
||||||
|
import pub.doric.shader.ViewNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: pub.doric.plugin
|
* @Description: pub.doric.plugin
|
||||||
@ -22,11 +24,34 @@ public class PopoverPlugin extends DoricJavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DoricMethod
|
@DoricMethod
|
||||||
public void show(JSObject jsObject, DoricPromise promise) {
|
public void show(JSDecoder decoder, DoricPromise promise) {
|
||||||
|
try {
|
||||||
|
JSObject jsObject = decoder.decode().asObject();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
promise.reject(new JavaValue(e.getLocalizedMessage()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@DoricMethod
|
@DoricMethod
|
||||||
public void dismiss(JSObject jsObject, DoricPromise promise) {
|
public void dismiss(JSDecoder decoder, DoricPromise promise) {
|
||||||
|
try {
|
||||||
|
JSObject jsObject = decoder.decode().asObject();
|
||||||
|
JSValue value = jsObject.getProperty("id");
|
||||||
|
if (value.isString()) {
|
||||||
|
String viewId = value.asString().value();
|
||||||
|
ViewNode node = getDoricContext().targetViewNode(viewId);
|
||||||
|
dismissViewNode(node);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
promise.reject(new JavaValue(e.getLocalizedMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dismissViewNode(ViewNode node) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package pub.doric.plugin;
|
package pub.doric.plugin;
|
||||||
|
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import pub.doric.DoricContext;
|
import pub.doric.DoricContext;
|
||||||
import pub.doric.async.AsyncResult;
|
import pub.doric.async.AsyncResult;
|
||||||
import pub.doric.extension.bridge.DoricMethod;
|
import pub.doric.extension.bridge.DoricMethod;
|
||||||
@ -55,9 +57,17 @@ public class ShaderPlugin extends DoricJavaPlugin {
|
|||||||
getDoricContext().getDriver().asyncCall(new Callable<Object>() {
|
getDoricContext().getDriver().asyncCall(new Callable<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object call() throws Exception {
|
public Object call() throws Exception {
|
||||||
|
String viewId = jsObject.getProperty("id").asString().value();
|
||||||
RootNode rootNode = getDoricContext().getRootNode();
|
RootNode rootNode = getDoricContext().getRootNode();
|
||||||
rootNode.setId(jsObject.getProperty("id").asString().value());
|
if (TextUtils.isEmpty(rootNode.getId())) {
|
||||||
rootNode.render(jsObject.getProperty("props").asObject());
|
rootNode.setId(viewId);
|
||||||
|
rootNode.blend(jsObject.getProperty("props").asObject());
|
||||||
|
} else {
|
||||||
|
ViewNode viewNode = getDoricContext().targetViewNode(viewId);
|
||||||
|
if (viewNode != null) {
|
||||||
|
viewNode.blend(jsObject.getProperty("props").asObject());
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}, ThreadMode.UI).setCallback(new AsyncResult.Callback<Object>() {
|
}, ThreadMode.UI).setCallback(new AsyncResult.Callback<Object>() {
|
||||||
@ -93,7 +103,7 @@ public class ShaderPlugin extends DoricJavaPlugin {
|
|||||||
ViewNode viewNode = null;
|
ViewNode viewNode = null;
|
||||||
for (JSValue value : viewIds) {
|
for (JSValue value : viewIds) {
|
||||||
if (viewNode == null) {
|
if (viewNode == null) {
|
||||||
viewNode = getDoricContext().getRootNode();
|
viewNode = getDoricContext().targetViewNode(value.asString().value());
|
||||||
} else {
|
} else {
|
||||||
if (value.isString() && viewNode instanceof SuperNode) {
|
if (value.isString() && viewNode instanceof SuperNode) {
|
||||||
String viewId = value.asString().value();
|
String viewId = value.asString().value();
|
||||||
|
@ -53,8 +53,4 @@ public class RootNode extends StackNode {
|
|||||||
public ViewGroup.LayoutParams getLayoutParams() {
|
public ViewGroup.LayoutParams getLayoutParams() {
|
||||||
return mView.getLayoutParams();
|
return mView.getLayoutParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(JSObject props) {
|
|
||||||
blend(props);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user