Commit e0374167 authored by ColdPaleLight's avatar ColdPaleLight

platform can provide custom flutter engine now

parent 253f2d67
...@@ -9,6 +9,8 @@ import android.os.Bundle; ...@@ -9,6 +9,8 @@ import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import com.idlefish.flutterboost.interfaces.*; import com.idlefish.flutterboost.interfaces.*;
import io.flutter.embedding.android.FlutterEngineProvider;
import io.flutter.embedding.android.FlutterView; import io.flutter.embedding.android.FlutterView;
import io.flutter.embedding.engine.FlutterEngine; import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.FlutterJNI; import io.flutter.embedding.engine.FlutterJNI;
...@@ -216,6 +218,8 @@ public class FlutterBoost { ...@@ -216,6 +218,8 @@ public class FlutterBoost {
private BoostLifecycleListener lifecycleListener; private BoostLifecycleListener lifecycleListener;
private FlutterEngineProvider flutterEngineProvider = null;
...@@ -255,6 +259,11 @@ public class FlutterBoost { ...@@ -255,6 +259,11 @@ public class FlutterBoost {
return this; return this;
} }
public ConfigBuilder flutterEngineProvider(FlutterEngineProvider flutterEngineProvider) {
this.flutterEngineProvider = flutterEngineProvider;
return this;
}
public Platform build() { public Platform build() {
Platform platform = new Platform() { Platform platform = new Platform() {
...@@ -286,11 +295,14 @@ public class FlutterBoost { ...@@ -286,11 +295,14 @@ public class FlutterBoost {
public FlutterView.RenderMode renderMode() { public FlutterView.RenderMode renderMode() {
return ConfigBuilder.this.renderMode; return ConfigBuilder.this.renderMode;
} }
public FlutterEngineProvider flutterEngineProvider() {
return flutterEngineProvider;
}
}; };
platform.lifecycleListener = this.lifecycleListener; platform.lifecycleListener = this.lifecycleListener;
return platform; return platform;
} }
} }
...@@ -323,8 +335,14 @@ public class FlutterBoost { ...@@ -323,8 +335,14 @@ public class FlutterBoost {
FlutterShellArgs flutterShellArgs = new FlutterShellArgs(new String[0]); FlutterShellArgs flutterShellArgs = new FlutterShellArgs(new String[0]);
FlutterMain.ensureInitializationComplete( FlutterMain.ensureInitializationComplete(
mPlatform.getApplication().getApplicationContext(), flutterShellArgs.toArray()); mPlatform.getApplication().getApplicationContext(), flutterShellArgs.toArray());
if (mPlatform.flutterEngineProvider() != null) {
mEngine = mPlatform.flutterEngineProvider().provideFlutterEngine(mPlatform.getApplication().getApplicationContext());
}
if (mEngine == null) {
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()); mRegistry = new BoostPluginRegistry(createEngine());
mPlatform.registerPlugins(mRegistry); mPlatform.registerPlugins(mRegistry);
......
...@@ -8,7 +8,9 @@ import com.idlefish.flutterboost.interfaces.IContainerRecord; ...@@ -8,7 +8,9 @@ import com.idlefish.flutterboost.interfaces.IContainerRecord;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Map; import java.util.Map;
import io.flutter.embedding.android.FlutterEngineProvider;
import io.flutter.embedding.android.FlutterView; import io.flutter.embedding.android.FlutterView;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugin.common.PluginRegistry; import io.flutter.plugin.common.PluginRegistry;
/** /**
...@@ -59,4 +61,8 @@ public abstract class Platform { ...@@ -59,4 +61,8 @@ public abstract class Platform {
Log.i("flutterboost.platform",t.toString()); Log.i("flutterboost.platform",t.toString());
} }
} }
public FlutterEngineProvider flutterEngineProvider() {
return null;
}
} }
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