Commit 9c19498c authored by yangwu.jia's avatar yangwu.jia

注册时机修改

parent f0aa4aec
...@@ -43,7 +43,13 @@ class BoostRegistrar implements Registrar, FlutterPlugin, ActivityAware { ...@@ -43,7 +43,13 @@ class BoostRegistrar implements Registrar, FlutterPlugin, ActivityAware {
} }
public Activity activity() { public Activity activity() {
return this.activityPluginBinding != null ? this.activityPluginBinding.getActivity() : null; if(this.activityPluginBinding != null){
return this.activityPluginBinding.getActivity();
}
if(NewFlutterBoost.instance().currentActivity()!=null){
return NewFlutterBoost.instance().currentActivity();
}
return null;
} }
public Context context() { public Context context() {
......
...@@ -29,8 +29,6 @@ public class NewFlutterBoost { ...@@ -29,8 +29,6 @@ public class NewFlutterBoost {
private FlutterEngine mEngine; private FlutterEngine mEngine;
private Activity mCurrentActiveActivity; private Activity mCurrentActiveActivity;
private PluginRegistry mRegistry; private PluginRegistry mRegistry;
private boolean hasRegistry=false;
static NewFlutterBoost sInstance = null; static NewFlutterBoost sInstance = null;
public static NewFlutterBoost instance() { public static NewFlutterBoost instance() {
...@@ -159,8 +157,8 @@ public class NewFlutterBoost { ...@@ -159,8 +157,8 @@ public class NewFlutterBoost {
); );
flutterEngine.getDartExecutor().executeDartEntrypoint(entrypoint); flutterEngine.getDartExecutor().executeDartEntrypoint(entrypoint);
mRegistry = new BoostPluginRegistry(createEngine()); mRegistry = new BoostPluginRegistry(createEngine());
registerPlugins();
} }
...@@ -317,8 +315,7 @@ public class NewFlutterBoost { ...@@ -317,8 +315,7 @@ public class NewFlutterBoost {
} }
public void registerPlugins() { private void registerPlugins() {
if(!hasRegistry&&mRegistry!=null){
try { try {
Class clz = Class.forName("io.flutter.plugins.GeneratedPluginRegistrant"); Class clz = Class.forName("io.flutter.plugins.GeneratedPluginRegistrant");
Method method = clz.getDeclaredMethod("registerWith", PluginRegistry.class); Method method = clz.getDeclaredMethod("registerWith", PluginRegistry.class);
...@@ -330,8 +327,6 @@ public class NewFlutterBoost { ...@@ -330,8 +327,6 @@ public class NewFlutterBoost {
if(mPlatform.lifecycleListener!=null){ if(mPlatform.lifecycleListener!=null){
mPlatform.lifecycleListener.onPluginsRegistered(); mPlatform.lifecycleListener.onPluginsRegistered();
} }
hasRegistry=true;
}
} }
......
...@@ -134,7 +134,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine ...@@ -134,7 +134,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
host.getActivity(), host.getActivity(),
host.getLifecycle() host.getLifecycle()
); );
NewFlutterBoost.instance().registerPlugins();
mSyncer = NewFlutterBoost.instance().containerManager().generateSyncer(this); mSyncer = NewFlutterBoost.instance().containerManager().generateSyncer(this);
......
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