mirror of
https://github.com/Tencent/Hippy.git
synced 2026-10-29 06:06:52 +08:00
feat(android): support getNativeParams from HippyEngineContext
This commit is contained in:
@@ -367,7 +367,7 @@ public abstract class HippyEngine {
|
||||
// 可选参数 传递给前端的rootview:比如:Hippy.entryPage: class App extends Component
|
||||
public HippyMap jsParams;
|
||||
// 可选参数 目前只有一个用处:映射:"CustomViewCreator" <==> 宿主自定义的一个HippyCustomViewCreator(这个creator还得通过ModuleParams.Builder.setCustomViewCreator来指定才行)
|
||||
public Map nativeParams;
|
||||
public Map<String, Object> nativeParams;
|
||||
// 可选参数 方便对将本View和hippyContext进行绑定。对于这种场景时有用:某些View组件的创建先于业务模块初始化的时机(也就是View组件的预先创建、预加载)。
|
||||
public HippyInstanceContext hippyContext;
|
||||
// 可选参数 Bundle加载器,老式用法,不建议使用(若一定要使用,则会覆盖jsAssetsPath,jsFilePath的值)。参见jsAssetsPath,jsFilePath
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.tencent.mtt.hippy;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.tencent.mtt.hippy.bridge.HippyBridgeManager;
|
||||
import com.tencent.mtt.hippy.common.ThreadExecutor;
|
||||
import com.tencent.mtt.hippy.devsupport.DevSupportManager;
|
||||
@@ -24,12 +25,16 @@ import com.tencent.mtt.hippy.uimanager.RenderManager;
|
||||
import com.tencent.mtt.hippy.utils.TimeMonitor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface HippyEngineContext {
|
||||
|
||||
String getComponentName();
|
||||
|
||||
@Nullable
|
||||
Map<String, Object> getNativeParams();
|
||||
|
||||
HippyGlobalConfigs getGlobalConfigs();
|
||||
|
||||
HippyModuleManager getModuleManager();
|
||||
|
||||
@@ -57,6 +57,7 @@ import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
@SuppressWarnings({"deprecation", "unused"})
|
||||
@@ -260,6 +261,7 @@ public abstract class HippyEngineManagerImpl extends HippyEngineManager implemen
|
||||
}
|
||||
if (mEngineContext != null) {
|
||||
mEngineContext.setComponentName(loadParams.componentName);
|
||||
mEngineContext.setNativeParams(loadParams.nativeParams);
|
||||
}
|
||||
if (loadParams.jsParams == null) {
|
||||
loadParams.jsParams = new HippyMap();
|
||||
@@ -939,7 +941,8 @@ public abstract class HippyEngineManagerImpl extends HippyEngineManager implemen
|
||||
*/
|
||||
private final DomManager mDomManager;
|
||||
|
||||
private String componentName;
|
||||
private String mComponentName;
|
||||
private Map<String, Object> mNativeParams;
|
||||
|
||||
public HippyEngineContextImpl(boolean isDevModule, String debugServerHost) {
|
||||
mModuleManager = new HippyModuleManagerImpl(this, mAPIProviders);
|
||||
@@ -951,12 +954,22 @@ public abstract class HippyEngineManagerImpl extends HippyEngineManager implemen
|
||||
}
|
||||
|
||||
public void setComponentName(String componentName) {
|
||||
this.componentName = componentName;
|
||||
mComponentName = componentName;
|
||||
}
|
||||
|
||||
public void setNativeParams(Map<String, Object> nativeParams) {
|
||||
mNativeParams = nativeParams;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Map<String, Object> getNativeParams() {
|
||||
return mNativeParams;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return componentName;
|
||||
return mComponentName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1101,7 +1114,9 @@ public abstract class HippyEngineManagerImpl extends HippyEngineManager implemen
|
||||
if (mEngineLifecycleEventListeners != null) {
|
||||
mEngineLifecycleEventListeners.clear();
|
||||
}
|
||||
if (mNativeParams != null) {
|
||||
mNativeParams.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -98,12 +98,6 @@ public final class HippyInstanceContext extends ContextWrapper {
|
||||
}
|
||||
|
||||
void notifyInstanceDestroy() {
|
||||
if (mModuleParams != null) {
|
||||
@SuppressWarnings("rawtypes") Map map = mModuleParams.nativeParams;
|
||||
if (map != null) {
|
||||
map.clear();
|
||||
}
|
||||
}
|
||||
if (mDestroyListeners != null && mDestroyListeners.size() > 0) {
|
||||
Iterable<InstanceDestroyListener> listeners = mDestroyListeners.getNotifyListeners();
|
||||
for (InstanceDestroyListener l : listeners) {
|
||||
|
||||
Reference in New Issue
Block a user