Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
flutter_boost_1.22.4
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢冠章
flutter_boost_1.22.4
Commits
0a4d2767
Commit
0a4d2767
authored
Jun 27, 2019
by
Yacumima
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve
parent
8d103553
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
104 additions
and
27 deletions
+104
-27
android/src/main/java/com/idlefish/flutterboost/BoostEngineProvider.java
...n/java/com/idlefish/flutterboost/BoostEngineProvider.java
+6
-3
android/src/main/java/com/idlefish/flutterboost/BoostFlutterEngine.java
...in/java/com/idlefish/flutterboost/BoostFlutterEngine.java
+31
-7
android/src/main/java/com/idlefish/flutterboost/BoostFlutterView.java
...main/java/com/idlefish/flutterboost/BoostFlutterView.java
+1
-1
android/src/main/java/com/idlefish/flutterboost/FlutterBoost.java
...src/main/java/com/idlefish/flutterboost/FlutterBoost.java
+8
-3
android/src/main/java/com/idlefish/flutterboost/Platform.java
...oid/src/main/java/com/idlefish/flutterboost/Platform.java
+25
-0
android/src/main/java/com/idlefish/flutterboost/containers/BoostFlutterActivity.java
...dlefish/flutterboost/containers/BoostFlutterActivity.java
+1
-1
android/src/main/java/com/idlefish/flutterboost/containers/BoostFlutterFragment.java
...dlefish/flutterboost/containers/BoostFlutterFragment.java
+1
-1
android/src/main/java/com/idlefish/flutterboost/interfaces/IFlutterEngineProvider.java
...efish/flutterboost/interfaces/IFlutterEngineProvider.java
+7
-0
android/src/main/java/com/idlefish/flutterboost/interfaces/IPlatform.java
.../java/com/idlefish/flutterboost/interfaces/IPlatform.java
+2
-0
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
...om/taobao/idlefish/flutterboostexample/MyApplication.java
+17
-9
example/ios/Runner/GeneratedPluginRegistrant.m
example/ios/Runner/GeneratedPluginRegistrant.m
+0
-2
example/lib/main.dart
example/lib/main.dart
+5
-0
No files found.
android/src/main/java/com/idlefish/flutterboost/BoostEngineProvider.java
View file @
0a4d2767
...
@@ -35,12 +35,15 @@ public class BoostEngineProvider implements IFlutterEngineProvider {
...
@@ -35,12 +35,15 @@ public class BoostEngineProvider implements IFlutterEngineProvider {
private
BoostFlutterEngine
mEngine
=
null
;
private
BoostFlutterEngine
mEngine
=
null
;
BoostEngineProvider
()
{
public
BoostEngineProvider
()
{}
}
@Override
@Override
public
BoostFlutterEngine
createEngine
(
Context
context
)
{
public
BoostFlutterEngine
createEngine
(
Context
context
)
{
return
new
BoostFlutterEngine
(
context
.
getApplicationContext
());
}
@Override
public
BoostFlutterEngine
provideEngine
(
Context
context
)
{
Utils
.
assertCallOnMainThread
();
Utils
.
assertCallOnMainThread
();
if
(
mEngine
==
null
)
{
if
(
mEngine
==
null
)
{
...
@@ -48,7 +51,7 @@ public class BoostEngineProvider implements IFlutterEngineProvider {
...
@@ -48,7 +51,7 @@ public class BoostEngineProvider implements IFlutterEngineProvider {
FlutterMain
.
ensureInitializationComplete
(
FlutterMain
.
ensureInitializationComplete
(
context
.
getApplicationContext
(),
flutterShellArgs
.
toArray
());
context
.
getApplicationContext
(),
flutterShellArgs
.
toArray
());
mEngine
=
new
BoostFlutter
Engine
(
context
.
getApplicationContext
());
mEngine
=
create
Engine
(
context
.
getApplicationContext
());
final
IStateListener
stateListener
=
FlutterBoost
.
sInstance
.
mStateListener
;
final
IStateListener
stateListener
=
FlutterBoost
.
sInstance
.
mStateListener
;
if
(
stateListener
!=
null
)
{
if
(
stateListener
!=
null
)
{
...
...
android/src/main/java/com/idlefish/flutterboost/BoostFlutterEngine.java
View file @
0a4d2767
...
@@ -23,13 +23,31 @@ import io.flutter.view.TextureRegistry;
...
@@ -23,13 +23,31 @@ import io.flutter.view.TextureRegistry;
public
class
BoostFlutterEngine
extends
FlutterEngine
{
public
class
BoostFlutterEngine
extends
FlutterEngine
{
protected
final
Context
mContext
;
protected
final
Context
mContext
;
protected
final
BoostPluginRegistry
mBoostPluginRegistry
;
protected
final
BoostPluginRegistry
mBoostPluginRegistry
;
protected
final
DartExecutor
.
DartEntrypoint
mEntrypoint
;
protected
final
String
mInitRoute
;
protected
WeakReference
<
Activity
>
mCurrentActivityRef
;
protected
WeakReference
<
Activity
>
mCurrentActivityRef
;
public
BoostFlutterEngine
(
@NonNull
Context
context
)
{
public
BoostFlutterEngine
(
@NonNull
Context
context
)
{
this
(
context
,
null
,
null
);
}
public
BoostFlutterEngine
(
@NonNull
Context
context
,
DartExecutor
.
DartEntrypoint
entrypoint
,
String
initRoute
)
{
super
(
context
);
super
(
context
);
mContext
=
context
.
getApplicationContext
();
mContext
=
context
.
getApplicationContext
();
mBoostPluginRegistry
=
new
BoostPluginRegistry
(
this
,
context
);
mBoostPluginRegistry
=
new
BoostPluginRegistry
(
this
,
context
);
if
(
entrypoint
!=
null
)
{
mEntrypoint
=
entrypoint
;
}
else
{
mEntrypoint
=
defaultDartEntrypoint
(
context
);
}
if
(
initRoute
!=
null
)
{
mInitRoute
=
initRoute
;
}
else
{
mInitRoute
=
defaultInitialRoute
(
context
);
}
}
}
public
void
startRun
(
@Nullable
Activity
activity
)
{
public
void
startRun
(
@Nullable
Activity
activity
)
{
...
@@ -39,13 +57,8 @@ public class BoostFlutterEngine extends FlutterEngine {
...
@@ -39,13 +57,8 @@ public class BoostFlutterEngine extends FlutterEngine {
Debuger
.
log
(
"engine start running..."
);
Debuger
.
log
(
"engine start running..."
);
getNavigationChannel
().
setInitialRoute
(
"/"
);
getNavigationChannel
().
setInitialRoute
(
mInitRoute
);
getDartExecutor
().
executeDartEntrypoint
(
mEntrypoint
);
DartExecutor
.
DartEntrypoint
entryPoint
=
new
DartExecutor
.
DartEntrypoint
(
mContext
.
getResources
().
getAssets
(),
FlutterMain
.
findAppBundlePath
(
mContext
),
"main"
);
getDartExecutor
().
executeDartEntrypoint
(
entryPoint
);
final
IStateListener
stateListener
=
FlutterBoost
.
sInstance
.
mStateListener
;
final
IStateListener
stateListener
=
FlutterBoost
.
sInstance
.
mStateListener
;
if
(
stateListener
!=
null
)
{
if
(
stateListener
!=
null
)
{
...
@@ -56,6 +69,17 @@ public class BoostFlutterEngine extends FlutterEngine {
...
@@ -56,6 +69,17 @@ public class BoostFlutterEngine extends FlutterEngine {
}
}
}
}
protected
DartExecutor
.
DartEntrypoint
defaultDartEntrypoint
(
Context
context
){
return
new
DartExecutor
.
DartEntrypoint
(
context
.
getResources
().
getAssets
(),
FlutterMain
.
findAppBundlePath
(
context
),
"main"
);
}
protected
String
defaultInitialRoute
(
Context
context
){
return
"/"
;
}
public
BoostPluginRegistry
getBoostPluginRegistry
(){
public
BoostPluginRegistry
getBoostPluginRegistry
(){
return
mBoostPluginRegistry
;
return
mBoostPluginRegistry
;
}
}
...
...
android/src/main/java/com/idlefish/flutterboost/BoostFlutterView.java
View file @
0a4d2767
...
@@ -167,7 +167,7 @@ public class BoostFlutterView extends FrameLayout {
...
@@ -167,7 +167,7 @@ public class BoostFlutterView extends FrameLayout {
}
}
protected
BoostFlutterEngine
createFlutterEngine
(
Context
context
)
{
protected
BoostFlutterEngine
createFlutterEngine
(
Context
context
)
{
return
FlutterBoost
.
singleton
().
engineProvider
().
creat
eEngine
(
context
);
return
FlutterBoost
.
singleton
().
engineProvider
().
provid
eEngine
(
context
);
}
}
public
void
addFirstFrameRendered
(
OnFirstFrameRenderedListener
listener
)
{
public
void
addFirstFrameRendered
(
OnFirstFrameRenderedListener
listener
)
{
...
...
android/src/main/java/com/idlefish/flutterboost/FlutterBoost.java
View file @
0a4d2767
...
@@ -53,7 +53,7 @@ public class FlutterBoost {
...
@@ -53,7 +53,7 @@ public class FlutterBoost {
if
(
platform
.
whenEngineStart
()
==
IPlatform
.
IMMEDIATELY
)
{
if
(
platform
.
whenEngineStart
()
==
IPlatform
.
IMMEDIATELY
)
{
sInstance
.
mEngineProvider
sInstance
.
mEngineProvider
.
creat
eEngine
(
platform
.
getApplication
())
.
provid
eEngine
(
platform
.
getApplication
())
.
startRun
(
null
);
.
startRun
(
null
);
}
}
}
}
...
@@ -76,7 +76,12 @@ public class FlutterBoost {
...
@@ -76,7 +76,12 @@ public class FlutterBoost {
private
FlutterBoost
(
IPlatform
platform
)
{
private
FlutterBoost
(
IPlatform
platform
)
{
mPlatform
=
platform
;
mPlatform
=
platform
;
mManager
=
new
FlutterViewContainerManager
();
mManager
=
new
FlutterViewContainerManager
();
mEngineProvider
=
new
BoostEngineProvider
();
IFlutterEngineProvider
provider
=
platform
.
engineProvider
();
if
(
provider
==
null
)
{
provider
=
new
BoostEngineProvider
();
}
mEngineProvider
=
provider
;
platform
.
getApplication
().
registerActivityLifecycleCallbacks
(
new
ActivityLifecycleCallbacks
());
platform
.
getApplication
().
registerActivityLifecycleCallbacks
(
new
ActivityLifecycleCallbacks
());
BoostChannel
.
addActionAfterRegistered
(
new
BoostChannel
.
ActionAfterRegistered
()
{
BoostChannel
.
addActionAfterRegistered
(
new
BoostChannel
.
ActionAfterRegistered
()
{
...
@@ -120,7 +125,7 @@ public class FlutterBoost {
...
@@ -120,7 +125,7 @@ public class FlutterBoost {
public
void
onActivityCreated
(
Activity
activity
,
Bundle
savedInstanceState
)
{
public
void
onActivityCreated
(
Activity
activity
,
Bundle
savedInstanceState
)
{
if
(
platform
().
whenEngineStart
()
==
IPlatform
.
ANY_ACTIVITY_CREATED
)
{
if
(
platform
().
whenEngineStart
()
==
IPlatform
.
ANY_ACTIVITY_CREATED
)
{
sInstance
.
mEngineProvider
sInstance
.
mEngineProvider
.
creat
eEngine
(
activity
)
.
provid
eEngine
(
activity
)
.
startRun
(
activity
);
.
startRun
(
activity
);
}
}
}
}
...
...
android/src/main/java/com/idlefish/flutterboost/Platform.java
View file @
0a4d2767
package
com.idlefish.flutterboost
;
package
com.idlefish.flutterboost
;
import
com.idlefish.flutterboost.interfaces.IContainerRecord
;
import
com.idlefish.flutterboost.interfaces.IContainerRecord
;
import
com.idlefish.flutterboost.interfaces.IFlutterEngineProvider
;
import
com.idlefish.flutterboost.interfaces.IPlatform
;
import
com.idlefish.flutterboost.interfaces.IPlatform
;
import
java.lang.reflect.Method
;
import
java.util.Map
;
import
java.util.Map
;
import
io.flutter.plugin.common.PluginRegistry
;
public
abstract
class
Platform
implements
IPlatform
{
public
abstract
class
Platform
implements
IPlatform
{
@Override
public
boolean
isDebug
()
{
return
false
;
}
@Override
@Override
public
void
closeContainer
(
IContainerRecord
record
,
Map
<
String
,
Object
>
result
,
Map
<
String
,
Object
>
exts
)
{
public
void
closeContainer
(
IContainerRecord
record
,
Map
<
String
,
Object
>
result
,
Map
<
String
,
Object
>
exts
)
{
if
(
record
==
null
)
return
;
if
(
record
==
null
)
return
;
...
@@ -14,6 +23,22 @@ public abstract class Platform implements IPlatform {
...
@@ -14,6 +23,22 @@ public abstract class Platform implements IPlatform {
record
.
getContainer
().
finishContainer
(
result
);
record
.
getContainer
().
finishContainer
(
result
);
}
}
@Override
public
IFlutterEngineProvider
engineProvider
()
{
return
new
BoostEngineProvider
();
}
@Override
public
void
registerPlugins
(
PluginRegistry
registry
)
{
try
{
Class
clz
=
Class
.
forName
(
"io.flutter.plugins.GeneratedPluginRegistrant"
);
Method
method
=
clz
.
getDeclaredMethod
(
"registerWith"
,
PluginRegistry
.
class
);
method
.
invoke
(
null
,
registry
);
}
catch
(
Throwable
t
){
throw
new
RuntimeException
(
t
);
}
}
@Override
@Override
public
int
whenEngineStart
()
{
public
int
whenEngineStart
()
{
return
ANY_ACTIVITY_CREATED
;
return
ANY_ACTIVITY_CREATED
;
...
...
android/src/main/java/com/idlefish/flutterboost/containers/BoostFlutterActivity.java
View file @
0a4d2767
...
@@ -98,7 +98,7 @@ public abstract class BoostFlutterActivity extends Activity implements IFlutterV
...
@@ -98,7 +98,7 @@ public abstract class BoostFlutterActivity extends Activity implements IFlutterV
}
}
protected
BoostFlutterEngine
createFlutterEngine
(){
protected
BoostFlutterEngine
createFlutterEngine
(){
return
FlutterBoost
.
singleton
().
engineProvider
().
creat
eEngine
(
this
);
return
FlutterBoost
.
singleton
().
engineProvider
().
provid
eEngine
(
this
);
}
}
protected
BoostFlutterView
createFlutterView
(
BoostFlutterEngine
engine
){
protected
BoostFlutterView
createFlutterView
(
BoostFlutterEngine
engine
){
...
...
android/src/main/java/com/idlefish/flutterboost/containers/BoostFlutterFragment.java
View file @
0a4d2767
...
@@ -62,7 +62,7 @@ abstract public class BoostFlutterFragment extends Fragment implements IFlutterV
...
@@ -62,7 +62,7 @@ abstract public class BoostFlutterFragment extends Fragment implements IFlutterV
}
}
protected
BoostFlutterEngine
createFlutterEngine
(){
protected
BoostFlutterEngine
createFlutterEngine
(){
return
FlutterBoost
.
singleton
().
engineProvider
().
creat
eEngine
(
getContext
());
return
FlutterBoost
.
singleton
().
engineProvider
().
provid
eEngine
(
getContext
());
}
}
protected
BoostFlutterView
createFlutterView
(
BoostFlutterEngine
engine
){
protected
BoostFlutterView
createFlutterView
(
BoostFlutterEngine
engine
){
...
...
android/src/main/java/com/idlefish/flutterboost/interfaces/IFlutterEngineProvider.java
View file @
0a4d2767
...
@@ -38,6 +38,13 @@ public interface IFlutterEngineProvider {
...
@@ -38,6 +38,13 @@ public interface IFlutterEngineProvider {
*/
*/
BoostFlutterEngine
createEngine
(
Context
context
);
BoostFlutterEngine
createEngine
(
Context
context
);
/**
* provide a flutter engine
* @param context
* @return
*/
BoostFlutterEngine
provideEngine
(
Context
context
);
/**
/**
* may return null
* may return null
* @return
* @return
...
...
android/src/main/java/com/idlefish/flutterboost/interfaces/IPlatform.java
View file @
0a4d2767
...
@@ -63,6 +63,8 @@ public interface IPlatform {
...
@@ -63,6 +63,8 @@ public interface IPlatform {
void
closeContainer
(
IContainerRecord
record
,
Map
<
String
,
Object
>
result
,
Map
<
String
,
Object
>
exts
);
void
closeContainer
(
IContainerRecord
record
,
Map
<
String
,
Object
>
result
,
Map
<
String
,
Object
>
exts
);
IFlutterEngineProvider
engineProvider
();
/**
/**
* @return
* @return
*
*
...
...
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
View file @
0a4d2767
...
@@ -3,14 +3,19 @@ package com.taobao.idlefish.flutterboostexample;
...
@@ -3,14 +3,19 @@ package com.taobao.idlefish.flutterboostexample;
import
android.app.Application
;
import
android.app.Application
;
import
android.content.Context
;
import
android.content.Context
;
import
com.idlefish.flutterboost.BoostEngineProvider
;
import
com.idlefish.flutterboost.BoostFlutterEngine
;
import
com.idlefish.flutterboost.FlutterBoost
;
import
com.idlefish.flutterboost.FlutterBoost
;
import
com.idlefish.flutterboost.Platform
;
import
com.idlefish.flutterboost.Platform
;
import
com.idlefish.flutterboost.interfaces.IFlutterEngineProvider
;
import
java.util.Map
;
import
java.util.Map
;
import
io.flutter.app.FlutterApplication
;
import
io.flutter.app.FlutterApplication
;
import
io.flutter.embedding.engine.dart.DartExecutor
;
import
io.flutter.plugin.common.PluginRegistry
;
import
io.flutter.plugin.common.PluginRegistry
;
import
io.flutter.plugins.GeneratedPluginRegistrant
;
import
io.flutter.plugins.GeneratedPluginRegistrant
;
import
io.flutter.view.FlutterMain
;
public
class
MyApplication
extends
FlutterApplication
{
public
class
MyApplication
extends
FlutterApplication
{
@Override
@Override
...
@@ -25,18 +30,21 @@ public class MyApplication extends FlutterApplication {
...
@@ -25,18 +30,21 @@ public class MyApplication extends FlutterApplication {
}
}
@Override
@Override
public
boolean
isDebug
(
)
{
public
void
openContainer
(
Context
context
,
String
url
,
Map
<
String
,
Object
>
urlParams
,
int
requestCode
,
Map
<
String
,
Object
>
exts
)
{
return
true
;
PageRouter
.
openPageByUrl
(
context
,
url
,
urlParams
,
requestCode
)
;
}
}
@Override
@Override
public
void
registerPlugins
(
PluginRegistry
registry
)
{
public
IFlutterEngineProvider
engineProvider
()
{
GeneratedPluginRegistrant
.
registerWith
(
registry
);
return
new
BoostEngineProvider
(){
}
@Override
@Override
public
void
openContainer
(
Context
context
,
String
url
,
Map
<
String
,
Object
>
urlParams
,
int
requestCode
,
Map
<
String
,
Object
>
exts
)
{
public
BoostFlutterEngine
createEngine
(
Context
context
)
{
PageRouter
.
openPageByUrl
(
context
,
url
,
urlParams
,
requestCode
);
return
new
BoostFlutterEngine
(
context
,
new
DartExecutor
.
DartEntrypoint
(
context
.
getResources
().
getAssets
(),
FlutterMain
.
findAppBundlePath
(
context
),
"main2"
),
"/"
);
}
};
}
}
@Override
@Override
...
...
example/ios/Runner/GeneratedPluginRegistrant.m
View file @
0a4d2767
...
@@ -4,13 +4,11 @@
...
@@ -4,13 +4,11 @@
#import "GeneratedPluginRegistrant.h"
#import "GeneratedPluginRegistrant.h"
#import <flutter_boost/BoostChannel.h>
#import <flutter_boost/BoostChannel.h>
#import <xservice_kit/XserviceKitPlugin.h>
@implementation
GeneratedPluginRegistrant
@implementation
GeneratedPluginRegistrant
+
(
void
)
registerWithRegistry
:(
NSObject
<
FlutterPluginRegistry
>*
)
registry
{
+
(
void
)
registerWithRegistry
:(
NSObject
<
FlutterPluginRegistry
>*
)
registry
{
[
BoostChannel
registerWithRegistrar
:[
registry
registrarForPlugin
:
@"BoostChannel"
]];
[
BoostChannel
registerWithRegistrar
:[
registry
registrarForPlugin
:
@"BoostChannel"
]];
[
XserviceKitPlugin
registerWithRegistrar
:[
registry
registrarForPlugin
:
@"XserviceKitPlugin"
]];
}
}
@end
@end
example/lib/main.dart
View file @
0a4d2767
...
@@ -6,6 +6,11 @@ void main() {
...
@@ -6,6 +6,11 @@ void main() {
runApp
(
MyApp
());
runApp
(
MyApp
());
}
}
void
main2
(
)
{
print
(
"terry run main2"
);
runApp
(
MyApp
());
}
class
MyApp
extends
StatefulWidget
{
class
MyApp
extends
StatefulWidget
{
@override
@override
_MyAppState
createState
()
=>
_MyAppState
();
_MyAppState
createState
()
=>
_MyAppState
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment