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
1
Merge Requests
1
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
f0aa4aec
Commit
f0aa4aec
authored
Oct 30, 2019
by
yangwu.jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决registerPlugins 时候,必须attach activity
parent
08956ada
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
23 deletions
+40
-23
android/src/main/java/com/idlefish/flutterboost/NewFlutterBoost.java
.../main/java/com/idlefish/flutterboost/NewFlutterBoost.java
+24
-10
android/src/main/java/com/idlefish/flutterboost/Platform.java
...oid/src/main/java/com/idlefish/flutterboost/Platform.java
+1
-9
android/src/main/java/com/idlefish/flutterboost/containers/FlutterActivityAndFragmentDelegate.java
...rboost/containers/FlutterActivityAndFragmentDelegate.java
+15
-4
No files found.
android/src/main/java/com/idlefish/flutterboost/NewFlutterBoost.java
View file @
f0aa4aec
...
...
@@ -12,10 +12,12 @@ import io.flutter.embedding.android.FlutterView;
import
io.flutter.embedding.engine.FlutterEngine
;
import
io.flutter.embedding.engine.FlutterShellArgs
;
import
io.flutter.embedding.engine.dart.DartExecutor
;
import
io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
;
import
io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry
;
import
io.flutter.plugin.common.PluginRegistry
;
import
io.flutter.view.FlutterMain
;
import
java.lang.reflect.Method
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -27,8 +29,9 @@ public class NewFlutterBoost {
private
FlutterEngine
mEngine
;
private
Activity
mCurrentActiveActivity
;
private
PluginRegistry
mRegistry
;
static
NewFlutterBoost
sInstance
=
null
;
private
boolean
hasRegistry
=
false
;
static
NewFlutterBoost
sInstance
=
null
;
public
static
NewFlutterBoost
instance
()
{
if
(
sInstance
==
null
)
{
...
...
@@ -154,19 +157,11 @@ public class NewFlutterBoost {
FlutterMain
.
findAppBundlePath
(),
"main"
);
flutterEngine
.
getDartExecutor
().
executeDartEntrypoint
(
entrypoint
);
mRegistry
=
new
BoostPluginRegistry
(
createEngine
());
// ((BoostPluginRegistry) mRegistry).currentActivity(mCurrentActiveActivity);
mPlatform
.
registerPlugins
(
mRegistry
);
if
(
mPlatform
.
lifecycleListener
!=
null
){
mPlatform
.
lifecycleListener
.
onPluginsRegistered
();
}
}
...
...
@@ -322,6 +317,25 @@ public class NewFlutterBoost {
}
public
void
registerPlugins
()
{
if
(!
hasRegistry
&&
mRegistry
!=
null
){
try
{
Class
clz
=
Class
.
forName
(
"io.flutter.plugins.GeneratedPluginRegistrant"
);
Method
method
=
clz
.
getDeclaredMethod
(
"registerWith"
,
PluginRegistry
.
class
);
method
.
invoke
(
null
,
mRegistry
);
}
catch
(
Throwable
t
)
{
throw
new
RuntimeException
(
t
);
}
if
(
mPlatform
.
lifecycleListener
!=
null
){
mPlatform
.
lifecycleListener
.
onPluginsRegistered
();
}
hasRegistry
=
true
;
}
}
public
FlutterEngine
engineProvider
()
{
return
mEngine
;
}
...
...
android/src/main/java/com/idlefish/flutterboost/Platform.java
View file @
f0aa4aec
...
...
@@ -34,15 +34,7 @@ public abstract class Platform {
}
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
);
}
}
}
android/src/main/java/com/idlefish/flutterboost/containers/FlutterActivityAndFragmentDelegate.java
View file @
f0aa4aec
...
...
@@ -130,6 +130,12 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
@NonNull
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
Log
.
v
(
TAG
,
"Creating FlutterView."
);
flutterEngine
.
getActivityControlSurface
().
attachToActivity
(
host
.
getActivity
(),
host
.
getLifecycle
()
);
NewFlutterBoost
.
instance
().
registerPlugins
();
mSyncer
=
NewFlutterBoost
.
instance
().
containerManager
().
generateSyncer
(
this
);
...
...
@@ -173,10 +179,15 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
ensureAlive
();
flutterEngine
.
getLifecycleChannel
().
appIsResumed
();
flutterEngine
.
getActivityControlSurface
().
attachToActivity
(
host
.
getActivity
(),
host
.
getLifecycle
()
);
BoostPluginRegistry
registry
=
(
BoostPluginRegistry
)
NewFlutterBoost
.
instance
().
getPluginRegistry
();
ActivityPluginBinding
binding
=
registry
.
getRegistrarAggregate
().
getActivityPluginBinding
();
if
(
binding
!=
null
&&(
binding
.
getActivity
()!=
this
.
host
.
getActivity
())){
flutterEngine
.
getActivityControlSurface
().
attachToActivity
(
host
.
getActivity
(),
host
.
getLifecycle
()
);
}
}
...
...
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