Commit 6c01fb3b authored by yangwu.jia's avatar yangwu.jia

兼容新插件注册方式

parent 96b82a70
...@@ -200,7 +200,6 @@ public class FlutterBoost { ...@@ -200,7 +200,6 @@ public class FlutterBoost {
private BoostLifecycleListener lifecycleListener; private BoostLifecycleListener lifecycleListener;
private BoostPluginsRegister boostPluginsRegister;
...@@ -235,15 +234,11 @@ public class FlutterBoost { ...@@ -235,15 +234,11 @@ public class FlutterBoost {
} }
public ConfigBuilder lifecycleListener(BoostLifecycleListener lifecycleListener) { public ConfigBuilder lifecycleListener(BoostLifecycleListener lifecycleListener) {
this.lifecycleListener = lifecycleListener; this.lifecycleListener = lifecycleListener;
return this; return this;
} }
public ConfigBuilder pluginsRegister(BoostPluginsRegister boostPluginsRegister) {
this.boostPluginsRegister = boostPluginsRegister;
return this;
}
public Platform build() { public Platform build() {
Platform platform = new Platform() { Platform platform = new Platform() {
...@@ -278,7 +273,6 @@ public class FlutterBoost { ...@@ -278,7 +273,6 @@ public class FlutterBoost {
}; };
platform.lifecycleListener = this.lifecycleListener; platform.lifecycleListener = this.lifecycleListener;
platform.pluginsRegister=this.boostPluginsRegister;
return platform; return platform;
} }
......
...@@ -30,21 +30,40 @@ public class MyApplication extends Application { ...@@ -30,21 +30,40 @@ public class MyApplication extends Application {
}; };
FlutterBoost.BoostPluginsRegister pluginsRegister= new FlutterBoost.BoostPluginsRegister(){ FlutterBoost.BoostLifecycleListener boostLifecycleListener= new FlutterBoost.BoostLifecycleListener(){
@Override @Override
public void registerPlugins(PluginRegistry mRegistry) { public void onEngineCreated() {
GeneratedPluginRegistrant.registerWith(mRegistry);
TextPlatformViewPlugin.register(mRegistry.registrarFor("TextPlatformViewPlugin")); }
@Override
public void onPluginsRegistered() {
} }
@Override
public void onEngineDestroy() {
}
}; };
//
// AndroidManifest.xml 中必须要添加 flutterEmbedding 版本设置
//
// <meta-data android:name="flutterEmbedding"
// android:value="2">
// </meta-data>
// GeneratedPluginRegistrant 会自动生成 新的插件方式 
//
//
Platform platform= new FlutterBoost Platform platform= new FlutterBoost
.ConfigBuilder(this,router) .ConfigBuilder(this,router)
.isDebug(true) .isDebug(true)
.whenEngineStart(FlutterBoost.ConfigBuilder.ANY_ACTIVITY_CREATED) .whenEngineStart(FlutterBoost.ConfigBuilder.ANY_ACTIVITY_CREATED)
.renderMode(FlutterView.RenderMode.texture) .renderMode(FlutterView.RenderMode.texture)
.pluginsRegister(pluginsRegister) .lifecycleListener(boostLifecycleListener)
.build(); .build();
FlutterBoost.instance().init(platform); FlutterBoost.instance().init(platform);
......
...@@ -7,8 +7,11 @@ ...@@ -7,8 +7,11 @@
#import <Flutter/Flutter.h> #import <Flutter/Flutter.h>
NS_ASSUME_NONNULL_BEGIN
@interface GeneratedPluginRegistrant : NSObject @interface GeneratedPluginRegistrant : NSObject
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry; + (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry;
@end @end
NS_ASSUME_NONNULL_END
#endif /* GeneratedPluginRegistrant_h */ #endif /* GeneratedPluginRegistrant_h */
...@@ -3,7 +3,12 @@ ...@@ -3,7 +3,12 @@
// //
#import "GeneratedPluginRegistrant.h" #import "GeneratedPluginRegistrant.h"
#if __has_include(<flutter_boost/FlutterBoostPlugin.h>)
#import <flutter_boost/FlutterBoostPlugin.h> #import <flutter_boost/FlutterBoostPlugin.h>
#else
@import flutter_boost;
#endif
@implementation GeneratedPluginRegistrant @implementation GeneratedPluginRegistrant
......
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