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
8f0e8cda
Commit
8f0e8cda
authored
Nov 19, 2020
by
justin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
ddc22af1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
32 deletions
+38
-32
android/src/main/java/com/idlefish/flutterboost/containers/FlutterActivityAndFragmentDelegate.java
...rboost/containers/FlutterActivityAndFragmentDelegate.java
+27
-28
example/android/app/src/main/AndroidManifest.xml
example/android/app/src/main/AndroidManifest.xml
+2
-2
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
...om/taobao/idlefish/flutterboostexample/MyApplication.java
+9
-2
No files found.
android/src/main/java/com/idlefish/flutterboost/containers/FlutterActivityAndFragmentDelegate.java
View file @
8f0e8cda
...
@@ -5,6 +5,7 @@ import android.app.Activity;
...
@@ -5,6 +5,7 @@ import android.app.Activity;
import
androidx.lifecycle.Lifecycle
;
import
androidx.lifecycle.Lifecycle
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.graphics.Color
;
import
android.graphics.PixelFormat
;
import
android.graphics.PixelFormat
;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Bundle
;
...
@@ -98,6 +99,22 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
...
@@ -98,6 +99,22 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
host
.
configureFlutterEngine
(
flutterEngine
);
host
.
configureFlutterEngine
(
flutterEngine
);
host
.
getActivity
().
getWindow
().
setFormat
(
PixelFormat
.
TRANSLUCENT
);
host
.
getActivity
().
getWindow
().
setFormat
(
PixelFormat
.
TRANSLUCENT
);
if
(
host
.
shouldAttachEngineToActivity
())
{
// Notify any plugins that are currently attached to our FlutterEngine that they
// are now attached to an Activity.
//
// Passing this Fragment's Lifecycle should be sufficient because as long as this Fragment
// is attached to its Activity, the lifecycles should be in sync. Once this Fragment is
// detached from its Activity, that Activity will be detached from the FlutterEngine, too,
// which means there shouldn't be any possibility for the Fragment Lifecycle to get out of
// sync with the Activity. We use the Fragment's Lifecycle because it is possible that the
// attached Activity is not a LifecycleOwner.
Log
.
v
(
TAG
,
"Attaching FlutterEngine to the Activity that owns this Fragment."
);
flutterEngine
.
getActivityControlSurface
()
.
attachToActivity
(
host
.
getActivity
(),
host
.
getLifecycle
());
}
}
}
...
@@ -133,6 +150,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
...
@@ -133,6 +150,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
flutterSplashView
=
new
FlutterSplashView
(
host
.
getContext
());
flutterSplashView
=
new
FlutterSplashView
(
host
.
getContext
());
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR1
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR1
)
{
flutterSplashView
.
setId
(
View
.
generateViewId
());
flutterSplashView
.
setId
(
View
.
generateViewId
());
}
else
{
}
else
{
...
@@ -168,18 +186,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
...
@@ -168,18 +186,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
Log
.
v
(
TAG
,
"onResume()"
);
Log
.
v
(
TAG
,
"onResume()"
);
ensureAlive
();
ensureAlive
();
flutterEngine
.
getLifecycleChannel
().
appIsResumed
();
flutterEngine
.
getLifecycleChannel
().
appIsResumed
();
if
(
ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE
==
0
||
ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE
!=
this
.
host
.
getActivity
().
hashCode
()){
flutterEngine
.
getActivityControlSurface
().
detachFromActivityForConfigChanges
();
flutterEngine
.
getActivityControlSurface
().
attachToActivity
(
host
.
getActivity
(),
host
.
getLifecycle
()
);
ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE
=
this
.
host
.
getActivity
().
hashCode
();
}
}
}
...
@@ -219,8 +225,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
...
@@ -219,8 +225,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
mSyncer
.
onDestroy
();
mSyncer
.
onDestroy
();
ensureAlive
();
ensureAlive
();
// flutterView.release();
}
}
...
@@ -231,31 +235,26 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
...
@@ -231,31 +235,26 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
platformPlugin
.
destroy
();
platformPlugin
.
destroy
();
platformPlugin
=
null
;
platformPlugin
=
null
;
}
}
if
(
ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE
!=
0
&&
ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE
==
this
.
host
.
getActivity
().
hashCode
()){
if
(
host
.
shouldAttachEngineToActivity
())
{
// Notify plugins that they are no longer attached to an Activity.
Log
.
v
(
TAG
,
"Detaching FlutterEngine from the Activity that owns this Fragment."
);
if
(
host
.
getActivity
().
isChangingConfigurations
())
{
flutterEngine
.
getActivityControlSurface
().
detachFromActivityForConfigChanges
();
flutterEngine
.
getActivityControlSurface
().
detachFromActivityForConfigChanges
();
}
else
{
flutterEngine
.
getActivityControlSurface
().
detachFromActivity
();
}
}
}
Utils
.
fixInputMethodManagerLeak
(
host
.
getActivity
());
Utils
.
fixInputMethodManagerLeak
(
host
.
getActivity
());
}
}
// public void onBackPressed() {
// ensureAlive();
// if (flutterEngine != null) {
// Log.v(TAG, "Forwarding onBackPressed() to FlutterEngine.");
// flutterEngine.getNavigationChannel().popRoute();
// } else {
// Log.w(TAG, "Invoked onBackPressed() before FlutterFragment was attached to an Activity.");
// }
// }
public
void
onBackPressed
()
{
public
void
onBackPressed
()
{
mSyncer
.
onBackPressed
();
mSyncer
.
onBackPressed
();
ensureAlive
();
ensureAlive
();
}
}
...
...
example/android/app/src/main/AndroidManifest.xml
View file @
8f0e8cda
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
android:configChanges=
"orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:configChanges=
"orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated=
"true"
android:hardwareAccelerated=
"true"
android:windowSoftInputMode=
"adjustResize"
>
android:windowSoftInputMode=
"adjustResize"
>
<meta-data
android:name=
"io.flutter.embedding.android.SplashScreenDrawable"
android:resource=
"@drawable/
page_loading
"
/>
<meta-data
android:name=
"io.flutter.embedding.android.SplashScreenDrawable"
android:resource=
"@drawable/
launch_background
"
/>
</activity>
</activity>
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
android:configChanges=
"orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:configChanges=
"orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated=
"true"
android:hardwareAccelerated=
"true"
android:windowSoftInputMode=
"adjustResize"
>
android:windowSoftInputMode=
"adjustResize"
>
<meta-data
android:name=
"io.flutter.embedding.android.SplashScreenDrawable"
android:resource=
"@drawable/
page_loading
"
/>
<meta-data
android:name=
"io.flutter.embedding.android.SplashScreenDrawable"
android:resource=
"@drawable/
launch_background
"
/>
</activity>
</activity>
...
...
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
View file @
8f0e8cda
...
@@ -13,6 +13,8 @@ import io.flutter.embedding.android.FlutterView;
...
@@ -13,6 +13,8 @@ import io.flutter.embedding.android.FlutterView;
import
io.flutter.embedding.engine.plugins.FlutterPlugin
;
import
io.flutter.embedding.engine.plugins.FlutterPlugin
;
import
io.flutter.plugin.common.MethodChannel
;
import
io.flutter.plugin.common.MethodChannel
;
import
io.flutter.plugin.common.PluginRegistry
;
import
io.flutter.plugin.common.PluginRegistry
;
import
io.flutter.plugin.common.StandardMessageCodec
;
import
io.flutter.plugin.platform.PlatformViewRegistry
;
import
io.flutter.plugins.GeneratedPluginRegistrant
;
import
io.flutter.plugins.GeneratedPluginRegistrant
;
public
class
MyApplication
extends
Application
{
public
class
MyApplication
extends
Application
{
...
@@ -71,13 +73,18 @@ public class MyApplication extends Application {
...
@@ -71,13 +73,18 @@ public class MyApplication extends Application {
Platform
platform
=
new
FlutterBoost
Platform
platform
=
new
FlutterBoost
.
ConfigBuilder
(
this
,
router
)
.
ConfigBuilder
(
this
,
router
)
.
isDebug
(
true
)
.
isDebug
(
true
)
.
whenEngineStart
(
FlutterBoost
.
ConfigBuilder
.
ANY_ACTIVITY_CREATED
)
.
whenEngineStart
(
FlutterBoost
.
ConfigBuilder
.
IMMEDIATELY
)
.
renderMode
(
FlutterView
.
RenderMode
.
texture
)
.
renderMode
(
FlutterView
.
RenderMode
.
texture
)
.
lifecycleListener
(
boostLifecycleListener
)
.
lifecycleListener
(
boostLifecycleListener
)
.
build
();
.
build
();
FlutterBoost
.
instance
().
init
(
platform
);
FlutterBoost
.
instance
().
init
(
platform
);
// whenEngineStart(FlutterBoost.ConfigBuilder.IMMEDIATELY) 时候,engine才初始化好。
if
(
FlutterBoost
.
instance
().
engineProvider
()!=
null
){
PlatformViewRegistry
registry
=
FlutterBoost
.
instance
().
engineProvider
().
getPlatformViewsController
().
getRegistry
();
registry
.
registerViewFactory
(
"plugins.test/view"
,
new
TextPlatformViewFactory
(
StandardMessageCodec
.
INSTANCE
));
}
}
}
}
}
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