feat:use DoricPanel instead of DoricContext directly
This commit is contained in:
@@ -66,7 +66,7 @@ public class DoricContext {
|
||||
return doricContext;
|
||||
}
|
||||
|
||||
public void init(int width, int height) {
|
||||
public void init(float width, float height) {
|
||||
this.initParams = new JSONBuilder()
|
||||
.put("width", width)
|
||||
.put("height", height).toJSONObject();
|
||||
|
@@ -25,6 +25,8 @@ import androidx.annotation.RequiresApi;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import pub.doric.utils.DoricUtils;
|
||||
|
||||
/**
|
||||
* @Description: Doric
|
||||
* @Author: pengfei.zhou
|
||||
@@ -58,6 +60,10 @@ public class DoricPanel extends FrameLayout {
|
||||
|
||||
public void config(DoricContext doricContext) {
|
||||
mDoricContext = doricContext;
|
||||
mDoricContext.getRootNode().setRootView(this);
|
||||
if (getMeasuredState() != 0) {
|
||||
mDoricContext.init(DoricUtils.px2dp(getMeasuredWidth()), DoricUtils.px2dp(getMeasuredHeight()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,4 +74,14 @@ public class DoricPanel extends FrameLayout {
|
||||
public DoricContext getDoricContext() {
|
||||
return mDoricContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
if (oldw != w || oldh != h) {
|
||||
if (mDoricContext != null) {
|
||||
mDoricContext.init(DoricUtils.px2dp(w), DoricUtils.px2dp(h));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ package pub.doric;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import pub.doric.plugin.NavigatorPlugin;
|
||||
import pub.doric.plugin.NetworkPlugin;
|
||||
import pub.doric.plugin.ShaderPlugin;
|
||||
import pub.doric.plugin.StoragePlugin;
|
||||
@@ -69,6 +70,7 @@ public class DoricRegistry {
|
||||
this.registerNativePlugin(ModalPlugin.class);
|
||||
this.registerNativePlugin(NetworkPlugin.class);
|
||||
this.registerNativePlugin(StoragePlugin.class);
|
||||
this.registerNativePlugin(NavigatorPlugin.class);
|
||||
this.registerViewNode(RootNode.class);
|
||||
this.registerViewNode(TextNode.class);
|
||||
this.registerViewNode(ImageNode.class);
|
||||
|
@@ -32,7 +32,6 @@ import pub.doric.extension.bridge.DoricPromise;
|
||||
import pub.doric.utils.DoricUtils;
|
||||
import pub.doric.utils.ThreadMode;
|
||||
|
||||
import com.github.pengfeizhou.jscore.ArchiveException;
|
||||
import com.github.pengfeizhou.jscore.JSDecoder;
|
||||
import com.github.pengfeizhou.jscore.JSObject;
|
||||
import com.github.pengfeizhou.jscore.JSValue;
|
||||
|
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright [2019] [Doric.Pub]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pub.doric.plugin;
|
||||
|
||||
import pub.doric.DoricContext;
|
||||
import pub.doric.extension.bridge.DoricPlugin;
|
||||
|
||||
/**
|
||||
* @Description: pub.doric.plugin
|
||||
* @Author: pengfei.zhou
|
||||
* @CreateDate: 2019-11-23
|
||||
*/
|
||||
@DoricPlugin(name = "navigator")
|
||||
public class NavigatorPlugin extends DoricJavaPlugin {
|
||||
public NavigatorPlugin(DoricContext doricContext) {
|
||||
super(doricContext);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user