mirror of
https://github.com/Tencent/Hippy.git
synced 2026-10-29 06:06:52 +08:00
fix(android): call update root size when reload in debug mode
This commit is contained in:
@@ -39,6 +39,7 @@ import com.tencent.link_supplier.proxy.framework.ImageLoaderAdapter;
|
||||
import com.tencent.link_supplier.proxy.framework.JSFrameworkProxy;
|
||||
import com.tencent.link_supplier.proxy.renderer.ControllerProvider;
|
||||
import com.tencent.link_supplier.proxy.renderer.NativeRenderProxy;
|
||||
import com.tencent.link_supplier.proxy.renderer.RenderProxy;
|
||||
import com.tencent.mtt.hippy.adapter.device.HippyDeviceAdapter;
|
||||
import com.tencent.mtt.hippy.adapter.monitor.HippyEngineMonitorAdapter;
|
||||
import com.tencent.mtt.hippy.adapter.thirdparty.HippyThirdPartyAdapter;
|
||||
@@ -796,6 +797,10 @@ public abstract class HippyEngineManagerImpl extends HippyEngineManager implemen
|
||||
// Call linker to bind framework until get v8 runtime id after js bridge initialized,
|
||||
// and use v8 runtime id to represent framework id.
|
||||
mLinkHelper.bind((int) runtimeId);
|
||||
RenderProxy renderProxy = mLinkHelper.getRenderer();
|
||||
if (renderProxy instanceof NativeRenderProxy) {
|
||||
((NativeRenderProxy) renderProxy).onJSBridgeInitialized();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class MyActivity extends Activity
|
||||
initParams.imageLoader = new MyImageLoader(this.getApplicationContext());
|
||||
initParams.debugServerHost = "localhost:38989";
|
||||
// 可选:是否设置为debug模式,默认为false。调试模式下,所有jsbundle都是从debug server上下载
|
||||
initParams.debugMode = false;
|
||||
initParams.debugMode = true;
|
||||
// 可选:是否打印引擎的完整的log。默认为false
|
||||
initParams.enableLog = true;
|
||||
// 可选:debugMode = false 时必须设置coreJSAssetsPath或coreJSFilePath(debugMode = true时,所有jsbundle都是从debug server上下载)
|
||||
|
||||
@@ -24,11 +24,12 @@ import com.tencent.link_supplier.proxy.renderer.RenderProxy;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class Linker implements LinkHelper {
|
||||
|
||||
private static final int ROOT_VIEW_ID_INCREMENT = 10;
|
||||
private static final AtomicInteger sRootIdCounter = new AtomicInteger(0);
|
||||
private RenderProxy mRenderProxy;
|
||||
private DomProxy mDomProxy;
|
||||
private AnimationManagerProxy mAniManagerProx;
|
||||
private AnimationManagerProxy mAniManagerProxy;
|
||||
private final int mRootId;
|
||||
|
||||
public Linker() {
|
||||
@@ -55,13 +56,13 @@ public class Linker implements LinkHelper {
|
||||
|
||||
@Override
|
||||
public void createAnimationManager() {
|
||||
if (mAniManagerProx == null && mDomProxy != null) {
|
||||
mAniManagerProx = new AnimationManagerProxy(mDomProxy.getInstanceId());
|
||||
}
|
||||
if (mAniManagerProxy == null && mDomProxy != null) {
|
||||
mAniManagerProxy = new AnimationManagerProxy(mDomProxy.getInstanceId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void createDomHolder(int instanceId) {
|
||||
if (mDomProxy == null) {
|
||||
mDomProxy = new DomHolder(instanceId);
|
||||
@@ -105,7 +106,7 @@ public class Linker implements LinkHelper {
|
||||
|
||||
@Override
|
||||
public void updateAnimationNode(byte[] params, int offset, int length) {
|
||||
updateAnimationNode(mAniManagerProx.getInstanceId(), params, offset, length);
|
||||
updateAnimationNode(mAniManagerProxy.getInstanceId(), params, offset, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,9 +115,9 @@ public class Linker implements LinkHelper {
|
||||
mDomProxy.destroy();
|
||||
mDomProxy = null;
|
||||
}
|
||||
if (mAniManagerProx != null) {
|
||||
mAniManagerProx.destroy();
|
||||
mAniManagerProx = null;
|
||||
if (mAniManagerProxy != null) {
|
||||
mAniManagerProxy.destroy();
|
||||
mAniManagerProxy = null;
|
||||
}
|
||||
if (mRenderProxy != null) {
|
||||
mRenderProxy.destroy();
|
||||
@@ -152,21 +153,22 @@ public class Linker implements LinkHelper {
|
||||
}
|
||||
|
||||
private class AnimationManagerProxy implements LinkProxy {
|
||||
private final int mInstanceId;
|
||||
|
||||
public AnimationManagerProxy(int domId) {
|
||||
mInstanceId = createAnimationManager(domId);
|
||||
}
|
||||
private final int mInstanceId;
|
||||
|
||||
@Override
|
||||
public int getInstanceId() {
|
||||
return mInstanceId;
|
||||
}
|
||||
public AnimationManagerProxy(int domId) {
|
||||
mInstanceId = createAnimationManager(domId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
destroyAnimationManager(mInstanceId);
|
||||
}
|
||||
@Override
|
||||
public int getInstanceId() {
|
||||
return mInstanceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
destroyAnimationManager(mInstanceId);
|
||||
}
|
||||
}
|
||||
|
||||
private RenderProxy createNativeRenderer() {
|
||||
@@ -220,17 +222,10 @@ public class Linker implements LinkHelper {
|
||||
private native void doBind(int domId, int renderId, int frameworkId);
|
||||
|
||||
/**
|
||||
* Update node property on animation update, params buffer format:
|
||||
* [
|
||||
* {
|
||||
* animationId:
|
||||
* nodeId:
|
||||
* animationKey:
|
||||
* animationValue:
|
||||
* }
|
||||
* ]
|
||||
* Update node property on animation update, params buffer format: [ { animationId: nodeId:
|
||||
* animationKey: animationValue: } ]
|
||||
*
|
||||
* @param domId dom manager instance id
|
||||
* @param aniId dom manager instance id
|
||||
* @param params params buffer encoded by serializer
|
||||
* @param offset start position of params buffer
|
||||
* @param length available total length of params buffer
|
||||
|
||||
+5
@@ -22,4 +22,9 @@ public interface NativeRenderProxy extends RenderProxy {
|
||||
* Notify renderer the root view instance delete by framework.
|
||||
*/
|
||||
void onRootDestroy();
|
||||
|
||||
/**
|
||||
* Notify renderer the js bridger has been initialized.
|
||||
*/
|
||||
void onJSBridgeInitialized();
|
||||
}
|
||||
|
||||
@@ -228,6 +228,22 @@ public class NativeRenderer extends Renderer implements NativeRender, NativeRend
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJSBridgeInitialized() {
|
||||
UIThreadUtils.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mRootView != null) {
|
||||
final int width = mRootView.getWidth();
|
||||
final int height = mRootView.getHeight();
|
||||
if (width > 0 && height > 0) {
|
||||
onSizeChanged(width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSizeChanged(int w, int h) {
|
||||
mRenderProvider.onSizeChanged(w, h);
|
||||
|
||||
Reference in New Issue
Block a user