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

注册时机修改

parent f0aa4aec
......@@ -43,7 +43,13 @@ class BoostRegistrar implements Registrar, FlutterPlugin, ActivityAware {
}
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() {
......
......@@ -29,8 +29,6 @@ public class NewFlutterBoost {
private FlutterEngine mEngine;
private Activity mCurrentActiveActivity;
private PluginRegistry mRegistry;
private boolean hasRegistry=false;
static NewFlutterBoost sInstance = null;
public static NewFlutterBoost instance() {
......@@ -159,8 +157,8 @@ public class NewFlutterBoost {
);
flutterEngine.getDartExecutor().executeDartEntrypoint(entrypoint);
mRegistry = new BoostPluginRegistry(createEngine());
registerPlugins();
}
......@@ -317,20 +315,17 @@ public class NewFlutterBoost {
}
public void registerPlugins() {
if(!hasRegistry&&mRegistry!=null){
try {
Class clz = Class.forName("io.flutter.plugins.GeneratedPluginRegistrant");
Method method = clz.getDeclaredMethod("registerWith", PluginRegistry.class);
method.invoke(null, mRegistry);
} catch (Throwable t) {
throw new RuntimeException(t);
}
private void registerPlugins() {
try {
Class clz = Class.forName("io.flutter.plugins.GeneratedPluginRegistrant");
Method method = clz.getDeclaredMethod("registerWith", PluginRegistry.class);
method.invoke(null, mRegistry);
} catch (Throwable t) {
throw new RuntimeException(t);
}
if(mPlatform.lifecycleListener!=null){
mPlatform.lifecycleListener.onPluginsRegistered();
}
hasRegistry=true;
if(mPlatform.lifecycleListener!=null){
mPlatform.lifecycleListener.onPluginsRegistered();
}
......
......@@ -134,7 +134,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
host.getActivity(),
host.getLifecycle()
);
NewFlutterBoost.instance().registerPlugins();
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