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
01ab95a8
Commit
01ab95a8
authored
Oct 23, 2019
by
yangwu.jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
engine初始化和Registry初始化优化
parent
76beb384
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
35 deletions
+45
-35
android/src/main/AndroidManifest.xml
android/src/main/AndroidManifest.xml
+1
-3
android/src/main/java/com/idlefish/flutterboost/NewFlutterBoost.java
.../main/java/com/idlefish/flutterboost/NewFlutterBoost.java
+17
-14
android/src/main/java/com/idlefish/flutterboost/Platform.java
...oid/src/main/java/com/idlefish/flutterboost/Platform.java
+21
-13
android/src/main/java/com/idlefish/flutterboost/Utils.java
android/src/main/java/com/idlefish/flutterboost/Utils.java
+2
-2
android/src/main/java/com/idlefish/flutterboost/containers/FlutterActivityAndFragmentDelegate.java
...rboost/containers/FlutterActivityAndFragmentDelegate.java
+2
-1
android/src/main/java/com/idlefish/flutterboost/containers/NewFlutterFragment.java
.../idlefish/flutterboost/containers/NewFlutterFragment.java
+1
-1
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
...om/taobao/idlefish/flutterboostexample/MyApplication.java
+1
-1
No files found.
android/src/main/AndroidManifest.xml
View file @
01ab95a8
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.idlefish.flutterboost"
>
<application>
<activity
android:name=
"com.idlefish.flutterboost.containers.BoostFlutterDefaultActivity"
/>
</application>
</manifest>
android/src/main/java/com/idlefish/flutterboost/NewFlutterBoost.java
View file @
01ab95a8
...
...
@@ -11,6 +11,8 @@ import io.flutter.Log;
import
io.flutter.embedding.android.FlutterView
;
import
io.flutter.embedding.engine.FlutterEngine
;
import
io.flutter.embedding.engine.dart.DartExecutor
;
import
io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry
;
import
io.flutter.plugin.common.PluginRegistry
;
import
io.flutter.view.FlutterMain
;
import
java.util.HashMap
;
...
...
@@ -23,7 +25,7 @@ public class NewFlutterBoost {
private
FlutterViewContainerManager
mManager
;
private
Activity
mCurrentActiveActivity
;
private
Boost
PluginRegistry
mRegistry
;
private
PluginRegistry
mRegistry
;
static
NewFlutterBoost
sInstance
=
null
;
...
...
@@ -41,19 +43,18 @@ public class NewFlutterBoost {
mManager
=
new
FlutterViewContainerManager
();
mRegistry
=
new
BoostPluginRegistry
(
this
.
engineProvider
(),
mPlatform
.
getApplication
());
platform
.
getApplication
().
registerActivityLifecycleCallbacks
(
new
Application
.
ActivityLifecycleCallbacks
()
{
@Override
public
void
onActivityCreated
(
Activity
activity
,
Bundle
savedInstanceState
)
{
Log
.
e
(
"bbbb1"
,
"xxxxx"
);
mCurrentActiveActivity
=
activity
;
if
(
mPlatform
.
whenEngineStart
()
==
ConfigBuilder
.
ANY_ACTIVITY_CREATED
)
{
Log
.
e
(
"bbbb2"
,
"xxxxx"
);
mRegistry
.
currentActivity
(
activity
);
doInitialFlutterViewRun
(
mPlatform
,
mRegistry
);
doInitialFlutter
(
mPlatform
);
}
}
...
...
@@ -117,18 +118,18 @@ public class NewFlutterBoost {
if
(
mPlatform
.
whenEngineStart
()
==
ConfigBuilder
.
IMMEDIATELY
)
{
doInitialFlutter
ViewRun
(
mPlatform
,
mRegistry
);
doInitialFlutter
(
mPlatform
);
}
}
private
void
doInitialFlutter
ViewRun
(
Platform
platform
,
BoostPluginRegistry
registry
)
{
// Don't attempt to start a FlutterEngine if we're using a cached FlutterEngine.
// if (host.getCachedEngineId() != null) {
//
return;
// }
private
void
doInitialFlutter
(
Platform
platform
)
{
if
(
platform
.
getEngine
()!=
null
)
return
;
FlutterEngine
flutterEngine
=
platform
.
engineProvider
();
if
(
flutterEngine
.
getDartExecutor
().
isExecutingDart
())
{
...
...
@@ -137,7 +138,9 @@ public class NewFlutterBoost {
// So this is expected behavior in many cases.
return
;
}
platform
.
registerPlugins
(
registry
);
mRegistry
=
new
ShimPluginRegistry
(
mPlatform
.
engineProvider
());
// The engine needs to receive the Flutter app's initial route before executing any
// Dart code to ensure that the initial route arrives in time to be applied.
...
...
@@ -268,7 +271,7 @@ public class NewFlutterBoost {
return
mManager
.
findContainerById
(
id
);
}
public
Boost
PluginRegistry
getPluginRegistry
(){
public
PluginRegistry
getPluginRegistry
(){
return
mRegistry
;
}
}
android/src/main/java/com/idlefish/flutterboost/Platform.java
View file @
01ab95a8
...
...
@@ -16,46 +16,54 @@ import io.flutter.view.FlutterMain;
public
abstract
class
Platform
{
p
ublic
FlutterEngine
mEngine
;
p
rivate
FlutterEngine
mEngine
;
public
abstract
Application
getApplication
();
public
abstract
void
openContainer
(
Context
context
,
String
url
,
Map
<
String
,
Object
>
urlParams
,
int
requestCode
,
Map
<
String
,
Object
>
exts
);
public
abstract
void
openContainer
(
Context
context
,
String
url
,
Map
<
String
,
Object
>
urlParams
,
int
requestCode
,
Map
<
String
,
Object
>
exts
);
public
abstract
int
whenEngineStart
()
;
public
abstract
int
whenEngineStart
()
;
public
abstract
FlutterView
.
RenderMode
renderMode
();
public
abstract
boolean
isDebug
()
;
public
abstract
boolean
isDebug
();
public
abstract
String
initialRoute
();
public
void
closeContainer
(
IContainerRecord
record
,
Map
<
String
,
Object
>
result
,
Map
<
String
,
Object
>
exts
)
{
if
(
record
==
null
)
return
;
if
(
record
==
null
)
return
;
record
.
getContainer
().
finishContainer
(
result
);
}
public
FlutterEngine
engineProvider
()
{
if
(
mEngine
==
null
)
{
FlutterMain
.
startInitialization
(
getApplication
());
FlutterShellArgs
flutterShellArgs
=
new
FlutterShellArgs
(
new
String
[
0
]);
FlutterMain
.
ensureInitializationComplete
(
getApplication
().
getApplicationContext
(),
flutterShellArgs
.
toArray
());
mEngine
=
new
FlutterEngine
(
getApplication
().
getApplicationContext
());
mEngine
=
new
FlutterEngine
(
getApplication
().
getApplicationContext
());
}
return
mEngine
;
}
public
FlutterEngine
getEngine
()
{
return
mEngine
;
}
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
)
{
Method
method
=
clz
.
getDeclaredMethod
(
"registerWith"
,
PluginRegistry
.
class
);
method
.
invoke
(
null
,
registry
);
}
catch
(
Throwable
t
)
{
throw
new
RuntimeException
(
t
);
}
}
...
...
android/src/main/java/com/idlefish/flutterboost/Utils.java
View file @
01ab95a8
...
...
@@ -263,7 +263,7 @@ public class Utils {
return
;
}
String
[]
arr
=
new
String
[]{
"mServedView"
,
"mNextServedView"
};
String
[]
arr
=
new
String
[]{
"m
LastSrvView"
,
"m
ServedView"
,
"mNextServedView"
};
Field
f
=
null
;
Object
obj_get
=
null
;
for
(
int
i
=
0
;
i
<
arr
.
length
;
i
++)
{
...
...
@@ -283,7 +283,7 @@ public class Utils {
}
}
}
catch
(
Throwable
t
){
t
.
printStackTrace
();
//
t.printStackTrace();
}
}
}
...
...
android/src/main/java/com/idlefish/flutterboost/containers/FlutterActivityAndFragmentDelegate.java
View file @
01ab95a8
...
...
@@ -109,6 +109,8 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
host
.
getActivity
(),
host
.
getLifecycle
()
);
NewFlutterBoost
.
instance
().
platform
().
registerPlugins
(
NewFlutterBoost
.
instance
().
getPluginRegistry
());
}
host
.
configureFlutterEngine
(
flutterEngine
);
...
...
@@ -147,7 +149,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
// FlutterView.
Log
.
d
(
TAG
,
"No preferred FlutterEngine was provided. Creating a new FlutterEngine for"
+
" this NewFlutterFragment."
);
flutterEngine
=
new
FlutterEngine
(
host
.
getContext
());
isFlutterEngineFromHost
=
false
;
}
...
...
android/src/main/java/com/idlefish/flutterboost/containers/NewFlutterFragment.java
View file @
01ab95a8
...
...
@@ -485,7 +485,7 @@ public class NewFlutterFragment extends Fragment implements FlutterActivityAndFr
*/
@Override
public
boolean
shouldAttachEngineToActivity
()
{
return
getArguments
().
getBoolean
(
ARG_SHOULD_ATTACH_ENGINE_TO_ACTIVITY
)
;
return
true
;
}
...
...
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
View file @
01ab95a8
...
...
@@ -11,7 +11,7 @@ import java.util.Map;
import
com.idlefish.flutterboost.interfaces.INativeRouter
;
import
io.flutter.app.FlutterApplication
;
public
class
MyApplication
extends
Flutter
Application
{
public
class
MyApplication
extends
Application
{
@Override
public
void
onCreate
()
{
super
.
onCreate
();
...
...
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