Commit 973ccd97 authored by justin's avatar justin

回滚 注册方式

parent 7a6ee43a
...@@ -52,7 +52,7 @@ class BoostRegistrar implements Registrar, FlutterPlugin, ActivityAware { ...@@ -52,7 +52,7 @@ class BoostRegistrar implements Registrar, FlutterPlugin, ActivityAware {
} }
public Context context() { public Context context() {
return this.pluginBinding != null ? this.pluginBinding.getApplicationContext() : null; return this.pluginBinding != null ? this.pluginBinding.getApplicationContext() : FlutterBoost.instance().platform().getApplication();
} }
public Context activeContext() { public Context activeContext() {
......
...@@ -15,6 +15,7 @@ import io.flutter.embedding.engine.FlutterJNI; ...@@ -15,6 +15,7 @@ import io.flutter.embedding.engine.FlutterJNI;
import io.flutter.embedding.engine.FlutterShellArgs; import io.flutter.embedding.engine.FlutterShellArgs;
import io.flutter.embedding.engine.dart.DartExecutor; import io.flutter.embedding.engine.dart.DartExecutor;
import io.flutter.embedding.engine.loader.FlutterLoader; import io.flutter.embedding.engine.loader.FlutterLoader;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.view.FlutterMain; import io.flutter.view.FlutterMain;
import java.lang.reflect.Method; import java.lang.reflect.Method;
...@@ -33,6 +34,7 @@ public class FlutterBoost { ...@@ -33,6 +34,7 @@ public class FlutterBoost {
private long FlutterPostFrameCallTime = 0; private long FlutterPostFrameCallTime = 0;
private Application.ActivityLifecycleCallbacks mActivityLifecycleCallbacks; private Application.ActivityLifecycleCallbacks mActivityLifecycleCallbacks;
private PluginRegistry mRegistry;
public long getFlutterPostFrameCallTime() { public long getFlutterPostFrameCallTime() {
return FlutterPostFrameCallTime; return FlutterPostFrameCallTime;
...@@ -323,8 +325,9 @@ public class FlutterBoost { ...@@ -323,8 +325,9 @@ public class FlutterBoost {
mPlatform.getApplication().getApplicationContext(), flutterShellArgs.toArray()); mPlatform.getApplication().getApplicationContext(), flutterShellArgs.toArray());
mEngine = new FlutterEngine(mPlatform.getApplication().getApplicationContext(),FlutterLoader.getInstance(),new FlutterJNI(),null,false); mEngine = new FlutterEngine(mPlatform.getApplication().getApplicationContext(),FlutterLoader.getInstance(),new FlutterJNI(),null,false);
registerPlugins(mEngine); // registerPlugins(mEngine);
mRegistry = new BoostPluginRegistry(createEngine());
mPlatform.registerPlugins(mRegistry);
} }
return mEngine; return mEngine;
......
...@@ -49,5 +49,14 @@ public abstract class Platform { ...@@ -49,5 +49,14 @@ public abstract class Platform {
record.getContainer().finishContainer(result); record.getContainer().finishContainer(result);
} }
public void registerPlugins(PluginRegistry mRegistry) {
try {
Class clz = Class.forName("io.flutter.plugins.GeneratedPluginRegistrant");
Method method = clz.getDeclaredMethod("registerWith", PluginRegistry.class);
method.invoke(null, mRegistry);
} catch (Throwable t) {
Log.i("flutterboost.platform",t.toString());
}
}
} }
...@@ -60,8 +60,8 @@ ...@@ -60,8 +60,8 @@
android:theme="@style/Theme.AppCompat" android:theme="@style/Theme.AppCompat"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:windowSoftInputMode="adjustResize"/> android:windowSoftInputMode="adjustResize"/>
<meta-data android:name="flutterEmbedding" <!--<meta-data android:name="flutterEmbedding"-->
android:value="2"> <!--android:value="2">-->
</meta-data> <!--</meta-data>-->
</application> </application>
</manifest> </manifest>
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