Commit 299ed053 authored by ytty's avatar ytty

只在 doInitialFlutter 调用 createEngine,其他只检查mEngine

parent e949c0e5
...@@ -14,12 +14,10 @@ import io.flutter.embedding.engine.dart.DartExecutor; ...@@ -14,12 +14,10 @@ import io.flutter.embedding.engine.dart.DartExecutor;
import io.flutter.plugin.common.PluginRegistry; import io.flutter.plugin.common.PluginRegistry;
import io.flutter.view.FlutterMain; import io.flutter.view.FlutterMain;
import java.lang.reflect.Method;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class FlutterBoost { public class FlutterBoost {
private Platform mPlatform; private Platform mPlatform;
private FlutterViewContainerManager mManager; private FlutterViewContainerManager mManager;
...@@ -68,9 +66,7 @@ public class FlutterBoost { ...@@ -68,9 +66,7 @@ public class FlutterBoost {
} }
if (mPlatform.whenEngineStart() == ConfigBuilder.IMMEDIATELY) { if (mPlatform.whenEngineStart() == ConfigBuilder.IMMEDIATELY) {
boostPluginRegistry(); boostPluginRegistry();
} }
} }
@Override @Override
...@@ -81,7 +77,7 @@ public class FlutterBoost { ...@@ -81,7 +77,7 @@ public class FlutterBoost {
if (mCurrentActiveActivity == null) { if (mCurrentActiveActivity == null) {
Debuger.log("Application entry foreground"); Debuger.log("Application entry foreground");
if (createEngine() != null) { if (mEngine != null) {
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
map.put("type", "foreground"); map.put("type", "foreground");
channel().sendEvent("lifecycle", map); channel().sendEvent("lifecycle", map);
...@@ -113,7 +109,7 @@ public class FlutterBoost { ...@@ -113,7 +109,7 @@ public class FlutterBoost {
if (mCurrentActiveActivity == activity) { if (mCurrentActiveActivity == activity) {
Debuger.log("Application entry background"); Debuger.log("Application entry background");
if (createEngine() != null) { if (mEngine != null) {
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
map.put("type", "background"); map.put("type", "background");
channel().sendEvent("lifecycle", map); channel().sendEvent("lifecycle", map);
...@@ -137,7 +133,7 @@ public class FlutterBoost { ...@@ -137,7 +133,7 @@ public class FlutterBoost {
if (mCurrentActiveActivity == activity) { if (mCurrentActiveActivity == activity) {
Debuger.log("Application entry background"); Debuger.log("Application entry background");
if (createEngine() != null) { if (mEngine != null) {
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
map.put("type", "background"); map.put("type", "background");
channel().sendEvent("lifecycle", map); channel().sendEvent("lifecycle", map);
...@@ -158,9 +154,9 @@ public class FlutterBoost { ...@@ -158,9 +154,9 @@ public class FlutterBoost {
} }
public void doInitialFlutter() { public void doInitialFlutter() {
if (mEngine != null) {
return;
if (mEngine != null) return; }
if (mPlatform.lifecycleListener != null) { if (mPlatform.lifecycleListener != null) {
mPlatform.lifecycleListener.beforeCreateEngine(); mPlatform.lifecycleListener.beforeCreateEngine();
...@@ -182,8 +178,7 @@ public class FlutterBoost { ...@@ -182,8 +178,7 @@ public class FlutterBoost {
); );
flutterEngine.getDartExecutor().executeDartEntrypoint(entrypoint); flutterEngine.getDartExecutor().executeDartEntrypoint(entrypoint);
mRegistry = new BoostPluginRegistry(createEngine()); mRegistry = new BoostPluginRegistry(mEngine);
} }
public void boostPluginRegistry(){ public void boostPluginRegistry(){
...@@ -329,7 +324,6 @@ public class FlutterBoost { ...@@ -329,7 +324,6 @@ public class FlutterBoost {
private FlutterEngine createEngine() { private FlutterEngine createEngine() {
if (mEngine == null) { if (mEngine == null) {
FlutterMain.startInitialization(mPlatform.getApplication()); FlutterMain.startInitialization(mPlatform.getApplication());
FlutterShellArgs flutterShellArgs = new FlutterShellArgs(new String[0]); FlutterShellArgs flutterShellArgs = new FlutterShellArgs(new String[0]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment