Skip to content

Commit

Permalink
feat(android): native render provider to c dom
Browse files Browse the repository at this point in the history
refactor(android): adjust some class name of native render

refactor(android): adjust some class name of native render

refactor(android): add updateRootSize interface for provider
  • Loading branch information
siguangli2018 authored and siguangli committed Dec 15, 2021
1 parent ec8e9a9 commit a7da8ec
Show file tree
Hide file tree
Showing 49 changed files with 551 additions and 715 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,6 @@ public interface HippyEngineContext {

void onRuntimeInitialized(long runtimeId);

void createNode(int rootId, HippyArray hippyArray);

void updateNode(int rootId, HippyArray updateArray);

void deleteNode(int rootId, HippyArray deleteArray);

void callUIFunction(HippyArray hippyArray, Promise promise);

void measureInWindow(int id, Promise promise);

void startBatch();

void endBatch();

int getEngineId();

int getRootId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;

import android.view.ViewGroup;
import com.tencent.hippy.support.HippyBaseController;
import com.tencent.hippy.support.IJSFrameworkProxy;
import com.tencent.hippy.support.INativeRendererProxy;
import com.tencent.hippy.support.INativeRenderProxy;
import com.tencent.mtt.hippy.adapter.device.HippyDeviceAdapter;
import com.tencent.mtt.hippy.common.HippyArray;
import com.tencent.mtt.hippy.dom.DomManager;
Expand Down Expand Up @@ -59,7 +58,6 @@
import java.io.InputStream;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;

@SuppressWarnings({"deprecation", "unused"})
Expand Down Expand Up @@ -285,24 +283,6 @@ public String getBundlePath() {
return null;
}

@Override
public void onSizeChanged(int w, int h, int oldw, int oldh) {
if (mEngineContext == null) {
return;
}

HippyModuleManager moduleManager = mEngineContext.getModuleManager();
if (moduleManager != null) {
HippyMap hippyMap = new HippyMap();
hippyMap.pushDouble("width", PixelUtil.px2dp(w));
hippyMap.pushDouble("height", PixelUtil.px2dp(h));
hippyMap.pushDouble("oldWidth", PixelUtil.px2dp(oldw));
hippyMap.pushDouble("oldHeight", PixelUtil.px2dp(oldh));
moduleManager.getJavaScriptModule(EventDispatcher.class)
.receiveNativeEvent("onSizeChanged", hippyMap);
}
}

@Override
public void dispatchUIComponentEvent(int id, String eventName, Object params) {
if (mEngineContext.getModuleManager().getJavaScriptModule(EventDispatcher.class) != null) {
Expand Down Expand Up @@ -642,8 +622,6 @@ private void internalLoadInstance(ModuleLoadParams loadParams) {
}

int rootId = rootView.getId();
mEngineContext.onInstanceLoad();

HippyMap launchParams = loadParams.jsParams;
if (!mDebugMode) {
if (jsBundleLoader != null) {
Expand Down Expand Up @@ -730,7 +708,7 @@ public class HippyEngineContextImpl implements HippyEngineContext, HippyInstance
private String componentName;
private final HippyModuleManager mModuleManager;
private final HippyBridgeManager mBridgeManager;
private INativeRendererProxy nativeRendererProxy;
private INativeRenderProxy nativeRendererProxy;
volatile CopyOnWriteArrayList<HippyEngineLifecycleEventListener> mEngineLifecycleEventListeners;

public HippyEngineContextImpl()
Expand All @@ -741,7 +719,7 @@ public HippyEngineContextImpl()
mServerHost, mGroupId, mThirdPartyAdapter, v8InitParams);
try {
Class nativeRendererClass = Class.forName("com.tencent.renderer.NativeRenderer");
nativeRendererProxy = (INativeRendererProxy)(nativeRendererClass.newInstance());
nativeRendererProxy = (INativeRenderProxy)(nativeRendererClass.newInstance());
List<Class<? extends HippyBaseController>> controllers = null;
for (HippyAPIProvider hippyPackage : mAPIProviders) {
if (controllers == null) {
Expand Down Expand Up @@ -837,9 +815,7 @@ public void removeEngineLifecycleEventListener(HippyEngineLifecycleEventListener

@Override
public void onInstanceLoad() {
if (nativeRendererProxy != null) {
nativeRendererProxy.onInstanceLoad();
}

}

@Override
Expand Down Expand Up @@ -908,57 +884,7 @@ public ViewGroup getRootView() {
return rootView;
}

@Override
public void createNode(int rootId, HippyArray hippyArray) {
if (nativeRendererProxy != null) {
nativeRendererProxy.createNode(rootId, hippyArray);
}
}

@Override
public void updateNode(int rootId, HippyArray updateArray) {
if (nativeRendererProxy != null) {
nativeRendererProxy.updateNode(rootId, updateArray);
}
}

@Override
public void deleteNode(int rootId, HippyArray deleteArray) {
if (nativeRendererProxy != null) {
nativeRendererProxy.deleteNode(rootId, deleteArray);
}
}

@Override
public void callUIFunction(HippyArray hippyArray, Promise promise) {
if (nativeRendererProxy != null) {
nativeRendererProxy.callUIFunction(hippyArray, promise);
}
}

@Override
public void measureInWindow(int id, Promise promise) {
if (nativeRendererProxy != null) {
nativeRendererProxy.measureInWindow(id, promise);
}
}

@Override
public void startBatch() {
if (nativeRendererProxy != null) {
nativeRendererProxy.startBatch();
}
}

@Override
public void endBatch() {
if (nativeRendererProxy != null) {
nativeRendererProxy.endBatch();
}
}

public ViewGroup createRootView(Context context) {
assert nativeRendererProxy != null;
rootView = nativeRendererProxy.createRootView(context);
return rootView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import com.tencent.mtt.hippy.modules.nativemodules.network.WebSocketModule;
import com.tencent.mtt.hippy.modules.nativemodules.storage.StorageModule;
import com.tencent.mtt.hippy.modules.nativemodules.timer.TimerModule;
import com.tencent.mtt.hippy.modules.nativemodules.uimanager.UIManagerModule;
import com.tencent.mtt.hippy.modules.nativemodules.utils.UtilsModule;
import com.tencent.mtt.hippy.uimanager.HippyViewController;
import com.tencent.mtt.hippy.utils.LogUtils;
Expand Down Expand Up @@ -91,12 +90,6 @@ public HippyNativeModuleBase get() {
return new ExceptionModule(context);
}
});
modules.put(UIManagerModule.class, new Provider<HippyNativeModuleBase>() {
@Override
public HippyNativeModuleBase get() {
return new UIManagerModule(context);
}
});
modules.put(AnimationModule.class, new Provider<HippyNativeModuleBase>() {
@Override
public HippyNativeModuleBase get() {
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions framework/js/android/src/main/jni/src/bridge/entry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ REGISTER_JNI("com/tencent/mtt/hippy/bridge/HippyBridgeImpl", // NOLINT(cert-err5
"(JZLcom/tencent/mtt/hippy/bridge/NativeCallback;)V",
DestroyInstance)

REGISTER_JNI("com/tencent/renderer/NativeRendererDelegate",
"onCreateNativeRendererDelegate",
REGISTER_JNI("com/tencent/renderer/NativeRenderProvider",
"onCreateNativeRenderProvider",
"(J)V",
CreateNativeRenderDelegate)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@
public interface IFrameworkProxy {
void onFirstViewAdded();

void onSizeChanged(int w, int h, int oldw, int oldh);

void handleNativeException(Exception exception, boolean haveCaught);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import java.util.List;

public interface INativeRendererProxy extends HippyInstanceLifecycleEventListener {
public interface INativeRenderProxy extends HippyInstanceLifecycleEventListener {
void init(int instanceId, List<Class<? extends HippyBaseController>> controllers,
boolean isDebugMode, ViewGroup rootView);

Expand All @@ -40,18 +40,4 @@ void init(int instanceId, List<Class<? extends HippyBaseController>> controllers
Object getDomManagerObject();

Object getRenderManagerObject();

void createNode(int rootId, HippyArray hippyArray);

void updateNode(int rootId, HippyArray updateArray);

void deleteNode(int rootId, HippyArray deleteArray);

void callUIFunction(HippyArray hippyArray, Promise promise);

void measureInWindow(int id, Promise promise);

void startBatch();

void endBatch();
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public HippyMap() {
mDatas = new HashMap<>();
}

public HippyMap(HashMap<String, Object> map) {
mDatas = map;
}

public HashMap<String, Object> getInternalMap() {
return mDatas;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@
import com.tencent.mtt.hippy.uimanager.RenderNode;
import com.tencent.mtt.hippy.views.hippylist.HippyRecyclerViewHolder;
import com.tencent.mtt.hippy.views.hippylist.NodePositionHelper;
import com.tencent.renderer.INativeRenderer;
import com.tencent.renderer.INativeRender;
import java.util.ArrayList;

public class HippyRecyclerExtension extends RecyclerView.ViewCacheExtension {

private final INativeRenderer hpContext;
private final INativeRender hpContext;
private final NodePositionHelper nodePositionHelper;
private HippyRecyclerViewBase recyclerView;
private int currentPosition;

public HippyRecyclerExtension(HippyRecyclerViewBase recyclerView, INativeRenderer hpContext,
public HippyRecyclerExtension(HippyRecyclerViewBase recyclerView, INativeRender hpContext,
NodePositionHelper nodePositionHelper) {
this.nodePositionHelper = nodePositionHelper;
this.recyclerView = recyclerView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
import com.tencent.mtt.hippy.uimanager.RenderNode;
import com.tencent.mtt.hippy.views.hippylist.HippyRecyclerViewHolder;
import com.tencent.mtt.hippy.views.hippylist.NodePositionHelper;
import com.tencent.renderer.INativeRenderer;
import com.tencent.renderer.INativeRender;

public class HippyRecyclerPool extends RecyclerView.RecycledViewPool {

private final View recyclerView;
private final HippyRecyclerExtension viewCacheExtension;
private final INativeRenderer hpContext;
private final INativeRender hpContext;
private final NodePositionHelper nodePositionHelper;
private IHippyViewAboundListener viewAboundListener;

public HippyRecyclerPool(INativeRenderer hpContext, View recyclerView,
public HippyRecyclerPool(INativeRender hpContext, View recyclerView,
HippyRecyclerExtension viewCacheExtension, NodePositionHelper nodePositionHelper) {
this.nodePositionHelper = nodePositionHelper;
this.hpContext = hpContext;
Expand Down
Loading

0 comments on commit a7da8ec

Please sign in to comment.