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
50baf018
You need to sign in or sign up before continuing.
Commit
50baf018
authored
Nov 13, 2019
by
yangwu.jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code fomat
parent
903b9f7a
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
78 additions
and
222 deletions
+78
-222
android/src/main/java/com/idlefish/flutterboost/FlutterBoost.java
...src/main/java/com/idlefish/flutterboost/FlutterBoost.java
+28
-39
android/src/main/java/com/idlefish/flutterboost/FlutterBoostPlugin.java
...in/java/com/idlefish/flutterboost/FlutterBoostPlugin.java
+0
-7
android/src/main/java/com/idlefish/flutterboost/Platform.java
...oid/src/main/java/com/idlefish/flutterboost/Platform.java
+1
-3
android/src/main/java/com/idlefish/flutterboost/containers/BoostFlutterActivity.java
...dlefish/flutterboost/containers/BoostFlutterActivity.java
+9
-17
android/src/main/java/com/idlefish/flutterboost/containers/FlutterActivityAndFragmentDelegate.java
...rboost/containers/FlutterActivityAndFragmentDelegate.java
+25
-34
android/src/main/java/com/idlefish/flutterboost/containers/FlutterFragment.java
...com/idlefish/flutterboost/containers/FlutterFragment.java
+8
-9
android/src/main/java/com/idlefish/flutterboost/containers/FlutterSplashView.java
...m/idlefish/flutterboost/containers/FlutterSplashView.java
+7
-113
android/src/main/java/com/taobao/idlefish/flutterboost/ContainerRecord.java
...ava/com/taobao/idlefish/flutterboost/ContainerRecord.java
+0
-0
android/src/main/java/com/taobao/idlefish/flutterboost/containers/FlutterViewStub.java
...bao/idlefish/flutterboost/containers/FlutterViewStub.java
+0
-0
No files found.
android/src/main/java/com/idlefish/flutterboost/FlutterBoost.java
View file @
50baf018
...
@@ -7,7 +7,6 @@ import android.content.Context;
...
@@ -7,7 +7,6 @@ import android.content.Context;
import
android.os.Bundle
;
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.Log
;
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.FlutterShellArgs
;
import
io.flutter.embedding.engine.FlutterShellArgs
;
...
@@ -29,15 +28,16 @@ public class FlutterBoost {
...
@@ -29,15 +28,16 @@ public class FlutterBoost {
private
PluginRegistry
mRegistry
;
private
PluginRegistry
mRegistry
;
static
FlutterBoost
sInstance
=
null
;
static
FlutterBoost
sInstance
=
null
;
private
long
FlutterPostFrameCallTime
=
0
;
private
long
FlutterPostFrameCallTime
=
0
;
public
long
getFlutterPostFrameCallTime
(){
public
long
getFlutterPostFrameCallTime
()
{
return
FlutterPostFrameCallTime
;
return
FlutterPostFrameCallTime
;
}
}
public
void
setFlutterPostFrameCallTime
(
long
FlutterPostFrameCallTime
){
public
void
setFlutterPostFrameCallTime
(
long
FlutterPostFrameCallTime
)
{
this
.
FlutterPostFrameCallTime
=
FlutterPostFrameCallTime
;
this
.
FlutterPostFrameCallTime
=
FlutterPostFrameCallTime
;
}
}
public
static
FlutterBoost
instance
()
{
public
static
FlutterBoost
instance
()
{
if
(
sInstance
==
null
)
{
if
(
sInstance
==
null
)
{
sInstance
=
new
FlutterBoost
();
sInstance
=
new
FlutterBoost
();
...
@@ -51,19 +51,13 @@ public class FlutterBoost {
...
@@ -51,19 +51,13 @@ public class FlutterBoost {
mPlatform
=
platform
;
mPlatform
=
platform
;
mManager
=
new
FlutterViewContainerManager
();
mManager
=
new
FlutterViewContainerManager
();
platform
.
getApplication
().
registerActivityLifecycleCallbacks
(
new
Application
.
ActivityLifecycleCallbacks
()
{
platform
.
getApplication
().
registerActivityLifecycleCallbacks
(
new
Application
.
ActivityLifecycleCallbacks
()
{
@Override
@Override
public
void
onActivityCreated
(
Activity
activity
,
Bundle
savedInstanceState
)
{
public
void
onActivityCreated
(
Activity
activity
,
Bundle
savedInstanceState
)
{
Log
.
e
(
"bbbb1"
,
"xxxxx"
);
mCurrentActiveActivity
=
activity
;
mCurrentActiveActivity
=
activity
;
if
(
mPlatform
.
whenEngineStart
()
==
ConfigBuilder
.
ANY_ACTIVITY_CREATED
)
{
if
(
mPlatform
.
whenEngineStart
()
==
ConfigBuilder
.
ANY_ACTIVITY_CREATED
)
{
Log
.
e
(
"bbbb2"
,
"xxxxx"
);
doInitialFlutter
();
doInitialFlutter
();
}
}
}
}
...
@@ -131,33 +125,24 @@ public class FlutterBoost {
...
@@ -131,33 +125,24 @@ public class FlutterBoost {
}
}
}
}
public
void
doInitialFlutter
()
{
public
void
doInitialFlutter
()
{
if
(
mEngine
!=
null
)
return
;
if
(
mEngine
!=
null
)
return
;
FlutterEngine
flutterEngine
=
createEngine
();
FlutterEngine
flutterEngine
=
createEngine
();
if
(
mPlatform
.
lifecycleListener
!=
null
)
{
if
(
mPlatform
.
lifecycleListener
!=
null
)
{
mPlatform
.
lifecycleListener
.
onEngineCreated
();
mPlatform
.
lifecycleListener
.
onEngineCreated
();
}
}
if
(
flutterEngine
.
getDartExecutor
().
isExecutingDart
())
{
if
(
flutterEngine
.
getDartExecutor
().
isExecutingDart
())
{
// No warning is logged because this situation will happen on every config
// change if the developer does not choose to retain the Fragment instance.
// So this is expected behavior in many cases.
return
;
return
;
}
}
// 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.
if
(
mPlatform
.
initialRoute
()
!=
null
)
{
if
(
mPlatform
.
initialRoute
()
!=
null
)
{
flutterEngine
.
getNavigationChannel
().
setInitialRoute
(
mPlatform
.
initialRoute
());
flutterEngine
.
getNavigationChannel
().
setInitialRoute
(
mPlatform
.
initialRoute
());
}
}
// Configure the Dart entrypoint and execute it.
DartExecutor
.
DartEntrypoint
entrypoint
=
new
DartExecutor
.
DartEntrypoint
(
DartExecutor
.
DartEntrypoint
entrypoint
=
new
DartExecutor
.
DartEntrypoint
(
FlutterMain
.
findAppBundlePath
(),
FlutterMain
.
findAppBundlePath
(),
"main"
"main"
...
@@ -198,7 +183,7 @@ public class FlutterBoost {
...
@@ -198,7 +183,7 @@ public class FlutterBoost {
private
INativeRouter
router
=
null
;
private
INativeRouter
router
=
null
;
private
BoostLifecycleListener
lifecycleListener
;
private
BoostLifecycleListener
lifecycleListener
;
public
ConfigBuilder
(
Application
app
,
INativeRouter
router
)
{
public
ConfigBuilder
(
Application
app
,
INativeRouter
router
)
{
this
.
router
=
router
;
this
.
router
=
router
;
...
@@ -225,19 +210,21 @@ public class FlutterBoost {
...
@@ -225,19 +210,21 @@ public class FlutterBoost {
return
this
;
return
this
;
}
}
public
ConfigBuilder
whenEngineStart
(
int
whenEngineStart
)
{
public
ConfigBuilder
whenEngineStart
(
int
whenEngineStart
)
{
this
.
whenEngineStart
=
whenEngineStart
;
this
.
whenEngineStart
=
whenEngineStart
;
return
this
;
return
this
;
}
}
public
ConfigBuilder
whenEngineDestory
(
int
whenEngineDestory
)
{
public
ConfigBuilder
whenEngineDestory
(
int
whenEngineDestory
)
{
this
.
whenEngineDestory
=
whenEngineDestory
;
this
.
whenEngineDestory
=
whenEngineDestory
;
return
this
;
return
this
;
}
}
public
ConfigBuilder
lifecycleListener
(
BoostLifecycleListener
lifecycleListener
)
{
public
ConfigBuilder
lifecycleListener
(
BoostLifecycleListener
lifecycleListener
)
{
this
.
lifecycleListener
=
lifecycleListener
;
this
.
lifecycleListener
=
lifecycleListener
;
return
this
;
return
this
;
}
}
public
Platform
build
()
{
public
Platform
build
()
{
Platform
platform
=
new
Platform
()
{
Platform
platform
=
new
Platform
()
{
...
@@ -275,7 +262,7 @@ public class FlutterBoost {
...
@@ -275,7 +262,7 @@ public class FlutterBoost {
}
}
};
};
platform
.
lifecycleListener
=
this
.
lifecycleListener
;
platform
.
lifecycleListener
=
this
.
lifecycleListener
;
return
platform
;
return
platform
;
...
@@ -303,11 +290,11 @@ public class FlutterBoost {
...
@@ -303,11 +290,11 @@ public class FlutterBoost {
return
mManager
.
findContainerById
(
id
);
return
mManager
.
findContainerById
(
id
);
}
}
public
PluginRegistry
getPluginRegistry
(){
public
PluginRegistry
getPluginRegistry
()
{
return
mRegistry
;
return
mRegistry
;
}
}
private
FlutterEngine
createEngine
(){
private
FlutterEngine
createEngine
()
{
if
(
mEngine
==
null
)
{
if
(
mEngine
==
null
)
{
FlutterMain
.
startInitialization
(
mPlatform
.
getApplication
());
FlutterMain
.
startInitialization
(
mPlatform
.
getApplication
());
...
@@ -331,7 +318,7 @@ public class FlutterBoost {
...
@@ -331,7 +318,7 @@ public class FlutterBoost {
throw
new
RuntimeException
(
t
);
throw
new
RuntimeException
(
t
);
}
}
if
(
mPlatform
.
lifecycleListener
!=
null
)
{
if
(
mPlatform
.
lifecycleListener
!=
null
)
{
mPlatform
.
lifecycleListener
.
onPluginsRegistered
();
mPlatform
.
lifecycleListener
.
onPluginsRegistered
();
}
}
...
@@ -339,26 +326,28 @@ public class FlutterBoost {
...
@@ -339,26 +326,28 @@ public class FlutterBoost {
}
}
public
FlutterEngine
engineProvider
()
{
public
FlutterEngine
engineProvider
()
{
return
mEngine
;
return
mEngine
;
}
}
public
void
boostDestroy
(){
public
void
boostDestroy
()
{
if
(
mEngine
!=
null
)
{
if
(
mEngine
!=
null
)
{
mEngine
.
destroy
();
mEngine
.
destroy
();
}
}
if
(
mPlatform
.
lifecycleListener
!=
null
)
{
if
(
mPlatform
.
lifecycleListener
!=
null
)
{
mPlatform
.
lifecycleListener
.
onEngineDestroy
();
mPlatform
.
lifecycleListener
.
onEngineDestroy
();
}
}
mEngine
=
null
;
mEngine
=
null
;
mRegistry
=
null
;
mRegistry
=
null
;
mCurrentActiveActivity
=
null
;
mCurrentActiveActivity
=
null
;
}
}
public
interface
BoostLifecycleListener
{
public
interface
BoostLifecycleListener
{
void
onEngineCreated
();
void
onEngineCreated
();
void
onPluginsRegistered
();
void
onPluginsRegistered
();
void
onEngineDestroy
();
void
onEngineDestroy
();
}
}
...
...
android/src/main/java/com/idlefish/flutterboost/FlutterBoostPlugin.java
View file @
50baf018
...
@@ -46,13 +46,6 @@ public class FlutterBoostPlugin {
...
@@ -46,13 +46,6 @@ public class FlutterBoostPlugin {
a
.
onChannelRegistered
(
sInstance
);
a
.
onChannelRegistered
(
sInstance
);
}
}
// if (NewFlutterBoost.instance() != null) {
// final IStateListener stateListener = NewFlutterBoost.instance().mStateListener;
// if (stateListener != null) {
// stateListener.onChannelRegistered(registrar, sInstance);
// }
// }
sActions
.
clear
();
sActions
.
clear
();
}
}
...
...
android/src/main/java/com/idlefish/flutterboost/Platform.java
View file @
50baf018
...
@@ -15,6 +15,7 @@ public abstract class Platform {
...
@@ -15,6 +15,7 @@ public abstract class Platform {
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
int
whenEngineDestroy
();
public
abstract
int
whenEngineDestroy
();
public
abstract
FlutterView
.
RenderMode
renderMode
();
public
abstract
FlutterView
.
RenderMode
renderMode
();
...
@@ -32,7 +33,4 @@ public abstract class Platform {
...
@@ -32,7 +33,4 @@ public abstract class Platform {
}
}
}
}
android/src/main/java/com/idlefish/flutterboost/containers/BoostFlutterActivity.java
View file @
50baf018
...
@@ -73,27 +73,23 @@ public class BoostFlutterActivity extends Activity
...
@@ -73,27 +73,23 @@ public class BoostFlutterActivity extends Activity
private
Map
params
=
new
HashMap
();
private
Map
params
=
new
HashMap
();
protected
NewEngineIntentBuilder
(
@NonNull
Class
<?
extends
BoostFlutterActivity
>
activityClass
)
{
protected
NewEngineIntentBuilder
(
@NonNull
Class
<?
extends
BoostFlutterActivity
>
activityClass
)
{
this
.
activityClass
=
activityClass
;
this
.
activityClass
=
activityClass
;
}
}
public
NewEngineIntentBuilder
url
(
@NonNull
String
url
)
{
public
NewEngineIntentBuilder
url
(
@NonNull
String
url
)
{
this
.
url
=
url
;
this
.
url
=
url
;
return
this
;
return
this
;
}
}
public
NewEngineIntentBuilder
params
(
@NonNull
Map
params
)
{
public
NewEngineIntentBuilder
params
(
@NonNull
Map
params
)
{
this
.
params
=
params
;
this
.
params
=
params
;
return
this
;
return
this
;
}
}
public
NewEngineIntentBuilder
backgroundMode
(
@NonNull
BackgroundMode
backgroundMode
)
{
public
NewEngineIntentBuilder
backgroundMode
(
@NonNull
BackgroundMode
backgroundMode
)
{
this
.
backgroundMode
=
backgroundMode
.
name
();
this
.
backgroundMode
=
backgroundMode
.
name
();
return
this
;
return
this
;
...
@@ -102,7 +98,7 @@ public class BoostFlutterActivity extends Activity
...
@@ -102,7 +98,7 @@ public class BoostFlutterActivity extends Activity
public
Intent
build
(
@NonNull
Context
context
)
{
public
Intent
build
(
@NonNull
Context
context
)
{
SerializableMap
serializableMap
=
new
SerializableMap
();
SerializableMap
serializableMap
=
new
SerializableMap
();
serializableMap
.
setMap
(
params
);
serializableMap
.
setMap
(
params
);
return
new
Intent
(
context
,
activityClass
)
return
new
Intent
(
context
,
activityClass
)
...
@@ -115,7 +111,7 @@ public class BoostFlutterActivity extends Activity
...
@@ -115,7 +111,7 @@ public class BoostFlutterActivity extends Activity
public
static
class
SerializableMap
implements
Serializable
{
public
static
class
SerializableMap
implements
Serializable
{
private
Map
<
String
,
Object
>
map
;
private
Map
<
String
,
Object
>
map
;
public
Map
<
String
,
Object
>
getMap
()
{
public
Map
<
String
,
Object
>
getMap
()
{
return
map
;
return
map
;
...
@@ -173,7 +169,7 @@ public class BoostFlutterActivity extends Activity
...
@@ -173,7 +169,7 @@ public class BoostFlutterActivity extends Activity
public
SplashScreen
provideSplashScreen
()
{
public
SplashScreen
provideSplashScreen
()
{
Drawable
manifestSplashDrawable
=
getSplashScreenFromManifest
();
Drawable
manifestSplashDrawable
=
getSplashScreenFromManifest
();
if
(
manifestSplashDrawable
!=
null
)
{
if
(
manifestSplashDrawable
!=
null
)
{
return
new
DrawableSplashScreen
(
manifestSplashDrawable
,
ImageView
.
ScaleType
.
CENTER
,
500L
);
return
new
DrawableSplashScreen
(
manifestSplashDrawable
,
ImageView
.
ScaleType
.
CENTER
,
500L
);
}
else
{
}
else
{
return
null
;
return
null
;
}
}
...
@@ -244,8 +240,8 @@ public class BoostFlutterActivity extends Activity
...
@@ -244,8 +240,8 @@ public class BoostFlutterActivity extends Activity
}
}
protected
XFlutterView
getFlutterView
(){
protected
XFlutterView
getFlutterView
()
{
return
delegate
.
getFlutterView
();
return
delegate
.
getFlutterView
();
}
}
@Override
@Override
...
@@ -370,7 +366,6 @@ public class BoostFlutterActivity extends Activity
...
@@ -370,7 +366,6 @@ public class BoostFlutterActivity extends Activity
}
}
/**
/**
* Returns true if Flutter is running in "debug mode", and false otherwise.
* Returns true if Flutter is running in "debug mode", and false otherwise.
* <p>
* <p>
...
@@ -470,9 +465,6 @@ public class BoostFlutterActivity extends Activity
...
@@ -470,9 +465,6 @@ public class BoostFlutterActivity extends Activity
}
}
@Override
@Override
public
String
getContainerUrl
()
{
public
String
getContainerUrl
()
{
if
(
getIntent
().
hasExtra
(
EXTRA_URL
))
{
if
(
getIntent
().
hasExtra
(
EXTRA_URL
))
{
...
@@ -486,11 +478,11 @@ public class BoostFlutterActivity extends Activity
...
@@ -486,11 +478,11 @@ public class BoostFlutterActivity extends Activity
public
Map
getContainerUrlParams
()
{
public
Map
getContainerUrlParams
()
{
if
(
getIntent
().
hasExtra
(
EXTRA_PARAMS
))
{
if
(
getIntent
().
hasExtra
(
EXTRA_PARAMS
))
{
SerializableMap
serializableMap
=
(
SerializableMap
)
getIntent
().
getSerializableExtra
(
EXTRA_PARAMS
);
SerializableMap
serializableMap
=
(
SerializableMap
)
getIntent
().
getSerializableExtra
(
EXTRA_PARAMS
);
return
serializableMap
.
getMap
();
return
serializableMap
.
getMap
();
}
}
Map
<
String
,
String
>
params
=
new
HashMap
<>();
Map
<
String
,
String
>
params
=
new
HashMap
<>();
return
params
;
return
params
;
}
}
...
...
android/src/main/java/com/idlefish/flutterboost/containers/FlutterActivityAndFragmentDelegate.java
View file @
50baf018
...
@@ -36,7 +36,7 @@ import io.flutter.plugin.platform.PlatformPlugin;
...
@@ -36,7 +36,7 @@ import io.flutter.plugin.platform.PlatformPlugin;
import
static
android
.
content
.
ComponentCallbacks2
.
TRIM_MEMORY_RUNNING_LOW
;
import
static
android
.
content
.
ComponentCallbacks2
.
TRIM_MEMORY_RUNNING_LOW
;
public
class
FlutterActivityAndFragmentDelegate
implements
IFlutterViewContainer
{
public
class
FlutterActivityAndFragmentDelegate
implements
IFlutterViewContainer
{
private
static
final
String
TAG
=
"FlutterActivityAndFragmentDelegate"
;
private
static
final
String
TAG
=
"FlutterActivityAndFragmentDelegate"
;
...
@@ -58,8 +58,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
...
@@ -58,8 +58,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
protected
IOperateSyncer
mSyncer
;
protected
IOperateSyncer
mSyncer
;
FlutterActivityAndFragmentDelegate
(
@NonNull
Host
host
)
{
FlutterActivityAndFragmentDelegate
(
@NonNull
Host
host
)
{
this
.
host
=
host
;
this
.
host
=
host
;
}
}
...
@@ -77,8 +75,8 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
...
@@ -77,8 +75,8 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
return
flutterEngine
;
return
flutterEngine
;
}
}
XFlutterView
getFlutterView
(){
XFlutterView
getFlutterView
()
{
return
flutterView
;
return
flutterView
;
}
}
void
onAttach
(
@NonNull
Context
context
)
{
void
onAttach
(
@NonNull
Context
context
)
{
...
@@ -107,8 +105,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
...
@@ -107,8 +105,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
}
}
private
void
setupFlutterEngine
()
{
private
void
setupFlutterEngine
()
{
Log
.
d
(
TAG
,
"Setting up FlutterEngine."
);
Log
.
d
(
TAG
,
"Setting up FlutterEngine."
);
...
@@ -172,7 +168,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
...
@@ -172,7 +168,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
}
}
void
onResume
()
{
void
onResume
()
{
mSyncer
.
onAppear
();
mSyncer
.
onAppear
();
...
@@ -180,9 +175,9 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
...
@@ -180,9 +175,9 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
ensureAlive
();
ensureAlive
();
flutterEngine
.
getLifecycleChannel
().
appIsResumed
();
flutterEngine
.
getLifecycleChannel
().
appIsResumed
();
BoostPluginRegistry
registry
=
(
BoostPluginRegistry
)
FlutterBoost
.
instance
().
getPluginRegistry
();
BoostPluginRegistry
registry
=
(
BoostPluginRegistry
)
FlutterBoost
.
instance
().
getPluginRegistry
();
ActivityPluginBinding
binding
=
registry
.
getRegistrarAggregate
().
getActivityPluginBinding
();
ActivityPluginBinding
binding
=
registry
.
getRegistrarAggregate
().
getActivityPluginBinding
();
if
(
binding
!=
null
&&(
binding
.
getActivity
()!=
this
.
host
.
getActivity
()))
{
if
(
binding
!=
null
&&
(
binding
.
getActivity
()
!=
this
.
host
.
getActivity
()))
{
flutterEngine
.
getActivityControlSurface
().
attachToActivity
(
flutterEngine
.
getActivityControlSurface
().
attachToActivity
(
host
.
getActivity
(),
host
.
getActivity
(),
host
.
getLifecycle
()
host
.
getLifecycle
()
...
@@ -195,7 +190,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
...
@@ -195,7 +190,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
void
onPostResume
()
{
void
onPostResume
()
{
Log
.
v
(
TAG
,
"onPostResume()"
);
Log
.
v
(
TAG
,
"onPostResume()"
);
ensureAlive
();
ensureAlive
();
Utils
.
setStatusBarLightMode
(
host
.
getActivity
(),
true
);
Utils
.
setStatusBarLightMode
(
host
.
getActivity
(),
true
);
}
}
...
@@ -221,9 +216,9 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
...
@@ -221,9 +216,9 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
mSyncer
.
onDestroy
();
mSyncer
.
onDestroy
();
ensureAlive
();
ensureAlive
();
BoostPluginRegistry
registry
=
(
BoostPluginRegistry
)
FlutterBoost
.
instance
().
getPluginRegistry
();
BoostPluginRegistry
registry
=
(
BoostPluginRegistry
)
FlutterBoost
.
instance
().
getPluginRegistry
();
ActivityPluginBinding
binding
=
registry
.
getRegistrarAggregate
().
getActivityPluginBinding
();
ActivityPluginBinding
binding
=
registry
.
getRegistrarAggregate
().
getActivityPluginBinding
();
if
(
binding
!=
null
&&(
binding
.
getActivity
()==
this
.
host
.
getActivity
()))
{
if
(
binding
!=
null
&&
(
binding
.
getActivity
()
==
this
.
host
.
getActivity
()))
{
registry
.
getRegistrarAggregate
().
onDetachedFromActivityForConfigChanges
();
registry
.
getRegistrarAggregate
().
onDetachedFromActivityForConfigChanges
();
flutterEngine
.
getActivityControlSurface
().
detachFromActivityForConfigChanges
();
flutterEngine
.
getActivityControlSurface
().
detachFromActivityForConfigChanges
();
...
@@ -237,7 +232,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
...
@@ -237,7 +232,6 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
ensureAlive
();
ensureAlive
();
// Null out the platformPlugin to avoid a possible retain cycle between the plugin, this Fragment,
// Null out the platformPlugin to avoid a possible retain cycle between the plugin, this Fragment,
// and this Fragment's Activity.
// and this Fragment's Activity.
if
(
platformPlugin
!=
null
)
{
if
(
platformPlugin
!=
null
)
{
...
@@ -287,16 +281,16 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
...
@@ -287,16 +281,16 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
mSyncer
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
mSyncer
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
Map
<
String
,
Object
>
result
=
null
;
Map
<
String
,
Object
>
result
=
null
;
if
(
data
!=
null
)
{
if
(
data
!=
null
)
{
Serializable
rlt
=
data
.
getSerializableExtra
(
RESULT_KEY
);
Serializable
rlt
=
data
.
getSerializableExtra
(
RESULT_KEY
);
if
(
rlt
instanceof
Map
)
{
if
(
rlt
instanceof
Map
)
{
result
=
(
Map
<
String
,
Object
>)
rlt
;
result
=
(
Map
<
String
,
Object
>)
rlt
;
}
}
}
}
mSyncer
.
onContainerResult
(
requestCode
,
resultCode
,
result
);
mSyncer
.
onContainerResult
(
requestCode
,
resultCode
,
result
);
ensureAlive
();
ensureAlive
();
...
@@ -360,7 +354,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
...
@@ -360,7 +354,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
@Override
@Override
public
Activity
getContextActivity
()
{
public
Activity
getContextActivity
()
{
return
(
Activity
)
this
.
host
.
getActivity
();
return
(
Activity
)
this
.
host
.
getActivity
();
}
}
@Override
@Override
...
@@ -371,10 +365,10 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
...
@@ -371,10 +365,10 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
@Override
@Override
public
void
finishContainer
(
Map
<
String
,
Object
>
result
)
{
public
void
finishContainer
(
Map
<
String
,
Object
>
result
)
{
if
(
result
!=
null
)
{
if
(
result
!=
null
)
{
setBoostResult
(
this
.
host
.
getActivity
(),
new
HashMap
<>(
result
));
setBoostResult
(
this
.
host
.
getActivity
(),
new
HashMap
<>(
result
));
this
.
host
.
getActivity
().
finish
();
this
.
host
.
getActivity
().
finish
();
}
else
{
}
else
{
this
.
host
.
getActivity
().
finish
();
this
.
host
.
getActivity
().
finish
();
}
}
...
@@ -382,17 +376,17 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
...
@@ -382,17 +376,17 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
}
}
public
void
setBoostResult
(
Activity
activity
,
HashMap
result
)
{
public
void
setBoostResult
(
Activity
activity
,
HashMap
result
)
{
Intent
intent
=
new
Intent
();
Intent
intent
=
new
Intent
();
if
(
result
!=
null
)
{
if
(
result
!=
null
)
{
intent
.
putExtra
(
IFlutterViewContainer
.
RESULT_KEY
,
result
);
intent
.
putExtra
(
IFlutterViewContainer
.
RESULT_KEY
,
result
);
}
}
activity
.
setResult
(
Activity
.
RESULT_OK
,
intent
);
activity
.
setResult
(
Activity
.
RESULT_OK
,
intent
);
}
}
@Override
@Override
public
String
getContainerUrl
()
{
public
String
getContainerUrl
()
{
return
this
.
host
.
getContainerUrl
();
return
this
.
host
.
getContainerUrl
();
}
}
@Override
@Override
...
@@ -486,12 +480,9 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
...
@@ -486,12 +480,9 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContaine
boolean
shouldAttachEngineToActivity
();
boolean
shouldAttachEngineToActivity
();
String
getContainerUrl
();
Map
getContainerUrlParams
();
String
getContainerUrl
()
;
Map
getContainerUrlParams
()
;
}
}
...
...
android/src/main/java/com/idlefish/flutterboost/containers/FlutterFragment.java
View file @
50baf018
...
@@ -115,6 +115,7 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
...
@@ -115,6 +115,7 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
private
boolean
shouldAttachEngineToActivity
=
true
;
private
boolean
shouldAttachEngineToActivity
=
true
;
private
String
url
=
""
;
private
String
url
=
""
;
private
Map
params
=
new
HashMap
();
private
Map
params
=
new
HashMap
();
/**
/**
* Constructs a {@code NewEngineFragmentBuilder} that is configured to construct an instance of
* Constructs a {@code NewEngineFragmentBuilder} that is configured to construct an instance of
* {@code NewFlutterFragment}.
* {@code NewFlutterFragment}.
...
@@ -132,7 +133,6 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
...
@@ -132,7 +133,6 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
}
}
/**
/**
* Any special configuration arguments for the Flutter engine
* Any special configuration arguments for the Flutter engine
*/
*/
...
@@ -155,16 +155,18 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
...
@@ -155,16 +155,18 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
this
.
renderMode
=
renderMode
;
this
.
renderMode
=
renderMode
;
return
this
;
return
this
;
}
}
public
NewEngineFragmentBuilder
url
(
@NonNull
String
url
)
{
public
NewEngineFragmentBuilder
url
(
@NonNull
String
url
)
{
this
.
url
=
url
;
this
.
url
=
url
;
return
this
;
return
this
;
}
}
public
NewEngineFragmentBuilder
params
(
@NonNull
Map
params
)
{
public
NewEngineFragmentBuilder
params
(
@NonNull
Map
params
)
{
this
.
params
=
params
;
this
.
params
=
params
;
return
this
;
return
this
;
}
}
/**
/**
* Support a {@link FlutterView.TransparencyMode#transparent} background within {@link FlutterView},
* Support a {@link FlutterView.TransparencyMode#transparent} background within {@link FlutterView},
* or force an {@link FlutterView.TransparencyMode#opaque} background.
* or force an {@link FlutterView.TransparencyMode#opaque} background.
...
@@ -178,7 +180,6 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
...
@@ -178,7 +180,6 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
}
}
@NonNull
@NonNull
protected
Bundle
createArgs
()
{
protected
Bundle
createArgs
()
{
Bundle
args
=
new
Bundle
();
Bundle
args
=
new
Bundle
();
...
@@ -188,7 +189,7 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
...
@@ -188,7 +189,7 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
args
.
putStringArray
(
ARG_FLUTTER_INITIALIZATION_ARGS
,
shellArgs
.
toArray
());
args
.
putStringArray
(
ARG_FLUTTER_INITIALIZATION_ARGS
,
shellArgs
.
toArray
());
}
}
BoostFlutterActivity
.
SerializableMap
serializableMap
=
new
BoostFlutterActivity
.
SerializableMap
();
BoostFlutterActivity
.
SerializableMap
serializableMap
=
new
BoostFlutterActivity
.
SerializableMap
();
serializableMap
.
setMap
(
params
);
serializableMap
.
setMap
(
params
);
args
.
putString
(
EXTRA_URL
,
url
);
args
.
putString
(
EXTRA_URL
,
url
);
...
@@ -232,7 +233,7 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
...
@@ -232,7 +233,7 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
private
FlutterActivityAndFragmentDelegate
delegate
;
private
FlutterActivityAndFragmentDelegate
delegate
;
protected
XFlutterView
getFlutterView
(){
protected
XFlutterView
getFlutterView
()
{
return
delegate
.
getFlutterView
();
return
delegate
.
getFlutterView
();
}
}
...
@@ -492,8 +493,6 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
...
@@ -492,8 +493,6 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
}
}
@Override
@Override
public
String
getContainerUrl
()
{
public
String
getContainerUrl
()
{
...
@@ -505,7 +504,7 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
...
@@ -505,7 +504,7 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
@Override
@Override
public
Map
getContainerUrlParams
()
{
public
Map
getContainerUrlParams
()
{
BoostFlutterActivity
.
SerializableMap
serializableMap
=
(
BoostFlutterActivity
.
SerializableMap
)
getArguments
().
getSerializable
(
EXTRA_PARAMS
);
BoostFlutterActivity
.
SerializableMap
serializableMap
=
(
BoostFlutterActivity
.
SerializableMap
)
getArguments
().
getSerializable
(
EXTRA_PARAMS
);
return
serializableMap
.
getMap
();
return
serializableMap
.
getMap
();
}
}
...
...
android/src/main/java/com/idlefish/flutterboost/containers/FlutterSplashView.java
View file @
50baf018
...
@@ -49,8 +49,6 @@ public class FlutterSplashView extends FrameLayout {
...
@@ -49,8 +49,6 @@ public class FlutterSplashView extends FrameLayout {
@Override
@Override
public
void
onFlutterEngineAttachedToFlutterView
(
@NonNull
FlutterEngine
engine
)
{
public
void
onFlutterEngineAttachedToFlutterView
(
@NonNull
FlutterEngine
engine
)
{
flutterView
.
removeFlutterEngineAttachmentListener
(
this
);
flutterView
.
removeFlutterEngineAttachmentListener
(
this
);
// displayFlutterViewWithSplash(flutterView, splashScreen);
// splashScreenTransitionNeededNow();
}
}
@Override
@Override
...
@@ -60,15 +58,16 @@ public class FlutterSplashView extends FrameLayout {
...
@@ -60,15 +58,16 @@ public class FlutterSplashView extends FrameLayout {
@NonNull
@NonNull
private
final
OnFirstFrameRenderedListener
onFirstFrameRenderedListener
=
new
OnFirstFrameRenderedListener
()
{
private
final
OnFirstFrameRenderedListener
onFirstFrameRenderedListener
=
new
OnFirstFrameRenderedListener
()
{
int
i
=
0
;
int
i
=
0
;
@Override
@Override
public
void
onFirstFrameRendered
()
{
public
void
onFirstFrameRendered
()
{
if
(
FlutterBoost
.
instance
().
platform
().
whenEngineStart
()==
FlutterBoost
.
ConfigBuilder
.
FLUTTER_ACTIVITY_CREATED
)
{
if
(
FlutterBoost
.
instance
().
platform
().
whenEngineStart
()
==
FlutterBoost
.
ConfigBuilder
.
FLUTTER_ACTIVITY_CREATED
)
{
long
now
=
new
Date
().
getTime
();
long
now
=
new
Date
().
getTime
();
long
flutterPostFrameCallTime
=
FlutterBoost
.
instance
().
getFlutterPostFrameCallTime
();
long
flutterPostFrameCallTime
=
FlutterBoost
.
instance
().
getFlutterPostFrameCallTime
();
if
(
flutterPostFrameCallTime
!=
0
&&
(
now
-
flutterPostFrameCallTime
)>
800
)
{
if
(
flutterPostFrameCallTime
!=
0
&&
(
now
-
flutterPostFrameCallTime
)
>
800
)
{
if
(
splashScreen
!=
null
)
{
if
(
splashScreen
!=
null
)
{
transitionToFlutter
();
transitionToFlutter
();
}
}
...
@@ -83,17 +82,13 @@ public class FlutterSplashView extends FrameLayout {
...
@@ -83,17 +82,13 @@ public class FlutterSplashView extends FrameLayout {
},
200
);
},
200
);
}
else
{
}
else
{
if
(
splashScreen
!=
null
)
{
if
(
splashScreen
!=
null
)
{
transitionToFlutter
();
transitionToFlutter
();
}
}
}
}
}
}
};
};
...
@@ -155,80 +150,10 @@ public class FlutterSplashView extends FrameLayout {
...
@@ -155,80 +150,10 @@ public class FlutterSplashView extends FrameLayout {
splashScreenView
.
setBackgroundColor
(
Color
.
WHITE
);
splashScreenView
.
setBackgroundColor
(
Color
.
WHITE
);
addView
(
this
.
splashScreenView
);
addView
(
this
.
splashScreenView
);
flutterView
.
addOnFirstFrameRenderedListener
(
onFirstFrameRenderedListener
);
flutterView
.
addOnFirstFrameRenderedListener
(
onFirstFrameRenderedListener
);
// if (splashScreen != null) {
// if (this.isSplashScreenNeededNow()) {
// Log.v(TAG, "Showing splash screen UI.");
// this.splashScreenView = splashScreen.createSplashView(this.getContext(), this.splashScreenState);
// this.addView(this.splashScreenView);
// flutterView.addOnFirstFrameRenderedListener(this.onFirstFrameRenderedListener);
// } else if (this.isSplashScreenTransitionNeededNow()) {
// Log.v(TAG, "Showing an immediate splash transition to Flutter due to previously interrupted transition.");
// this.splashScreenView = splashScreen.createSplashView(this.getContext(), this.splashScreenState);
// this.addView(this.splashScreenView);
// this.transitionToFlutter();
// } else if (!flutterView.isAttachedToFlutterEngine()) {
// Log.v(TAG, "FlutterView is not yet attached to a FlutterEngine. Showing nothing until a FlutterEngine is attached.");
// flutterView.addFlutterEngineAttachmentListener(this.flutterEngineAttachmentListener);
// }
// }
}
}
}
}
/**
* Returns true if current conditions require a splash UI to be displayed.
* <p>
* This method does not evaluate whether a previously interrupted splash transition needs
* to resume. See {@link #isSplashScreenTransitionNeededNow()} to answer that question.
*/
private
boolean
isSplashScreenNeededNow
()
{
return
flutterView
!=
null
&&
flutterView
.
isAttachedToFlutterEngine
()
&&
!
flutterView
.
hasRenderedFirstFrame
()
&&
!
hasSplashCompleted
();
}
/**
* Returns true if a previous splash transition was interrupted by recreation, e.g., an
* orientation change, and that previous transition should be resumed.
* <p>
* Not all splash screens are capable of remembering their transition progress. In those
* cases, this method will return false even if a previous visual transition was
* interrupted.
*/
private
boolean
isSplashScreenTransitionNeededNow
()
{
return
flutterView
!=
null
&&
flutterView
.
isAttachedToFlutterEngine
()
&&
splashScreen
!=
null
&&
splashScreen
.
doesSplashViewRememberItsTransition
()
&&
wasPreviousSplashTransitionInterrupted
();
}
/**
* Returns true if a splash screen was transitioning to a Flutter experience and was then
* interrupted, e.g., by an Android configuration change. Returns false otherwise.
* <p>
* Invoking this method expects that a {@code flutterView} exists and it is attached to a
* {@code FlutterEngine}.
*/
private
boolean
wasPreviousSplashTransitionInterrupted
()
{
if
(
flutterView
==
null
)
{
throw
new
IllegalStateException
(
"Cannot determine if previous splash transition was "
+
"interrupted when no FlutterView is set."
);
}
if
(!
flutterView
.
isAttachedToFlutterEngine
())
{
throw
new
IllegalStateException
(
"Cannot determine if previous splash transition was "
+
"interrupted when no FlutterEngine is attached to our FlutterView. This question "
+
"depends on an isolate ID to differentiate Flutter experiences."
);
}
return
flutterView
.
hasRenderedFirstFrame
()
&&
!
hasSplashCompleted
();
}
/**
/**
* Returns true if a splash UI for a specific Flutter experience has already completed.
* Returns true if a splash UI for a specific Flutter experience has already completed.
* <p>
* <p>
...
@@ -271,37 +196,6 @@ public class FlutterSplashView extends FrameLayout {
...
@@ -271,37 +196,6 @@ public class FlutterSplashView extends FrameLayout {
splashScreen
.
transitionToFlutter
(
onTransitionComplete
);
splashScreen
.
transitionToFlutter
(
onTransitionComplete
);
}
}
public
static
class
SavedState
extends
BaseSavedState
{
public
static
Creator
CREATOR
=
new
Creator
()
{
public
FlutterSplashView
.
SavedState
createFromParcel
(
Parcel
source
)
{
return
new
FlutterSplashView
.
SavedState
(
source
);
}
public
FlutterSplashView
.
SavedState
[]
newArray
(
int
size
)
{
return
new
FlutterSplashView
.
SavedState
[
size
];
}
};
private
String
previousCompletedSplashIsolate
;
private
Bundle
splashScreenState
;
SavedState
(
Parcelable
superState
)
{
super
(
superState
);
}
SavedState
(
Parcel
source
)
{
super
(
source
);
this
.
previousCompletedSplashIsolate
=
source
.
readString
();
this
.
splashScreenState
=
source
.
readBundle
(
this
.
getClass
().
getClassLoader
());
}
public
void
writeToParcel
(
Parcel
out
,
int
flags
)
{
super
.
writeToParcel
(
out
,
flags
);
out
.
writeString
(
this
.
previousCompletedSplashIsolate
);
out
.
writeBundle
(
this
.
splashScreenState
);
}
}
@Override
@Override
protected
void
onDetachedFromWindow
()
{
protected
void
onDetachedFromWindow
()
{
super
.
onDetachedFromWindow
();
super
.
onDetachedFromWindow
();
...
...
android/src/main/java/com/taobao/idlefish/flutterboost/ContainerRecord.java
100755 → 100644
View file @
50baf018
File mode changed from 100755 to 100644
android/src/main/java/com/taobao/idlefish/flutterboost/containers/FlutterViewStub.java
deleted
100755 → 0
View file @
903b9f7a
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