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
6433ecc8
Commit
6433ecc8
authored
May 22, 2019
by
Jidong Chen
Committed by
GitHub
May 22, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'no_query' into result_mediator
parents
be587178
7aed07fe
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
52 deletions
+74
-52
android/src/main/java/com/taobao/idlefish/flutterboost/BoostFlutterNativeView.java
.../taobao/idlefish/flutterboost/BoostFlutterNativeView.java
+4
-1
android/src/main/java/com/taobao/idlefish/flutterboost/ContainerRecord.java
...ava/com/taobao/idlefish/flutterboost/ContainerRecord.java
+9
-1
android/src/main/java/com/taobao/idlefish/flutterboost/FlutterBoostPlugin.java
.../com/taobao/idlefish/flutterboost/FlutterBoostPlugin.java
+50
-33
android/src/main/java/com/taobao/idlefish/flutterboost/NavigationService/NavigationService_openPage.java
...erboost/NavigationService/NavigationService_openPage.java
+3
-13
android/src/main/java/com/taobao/idlefish/flutterboost/containers/FlutterViewStub.java
...bao/idlefish/flutterboost/containers/FlutterViewStub.java
+3
-3
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
...om/taobao/idlefish/flutterboostexample/MyApplication.java
+5
-1
No files found.
android/src/main/java/com/taobao/idlefish/flutterboost/BoostFlutterNativeView.java
View file @
6433ecc8
...
...
@@ -33,7 +33,10 @@ public class BoostFlutterNativeView extends FlutterNativeView {
super
(
context
);
}
@Override
public
void
detachFromFlutterView
()
{
//do nothing...
}
public
void
detach
()
{
//do nothing...
}
...
...
android/src/main/java/com/taobao/idlefish/flutterboost/ContainerRecord.java
View file @
6433ecc8
...
...
@@ -23,6 +23,8 @@
*/
package
com.taobao.idlefish.flutterboost
;
import
android.os.Handler
;
import
com.taobao.idlefish.flutterboost.NavigationService.NavigationService
;
import
com.taobao.idlefish.flutterboost.interfaces.IContainerManager
;
import
com.taobao.idlefish.flutterboost.interfaces.IContainerRecord
;
...
...
@@ -36,6 +38,7 @@ public class ContainerRecord implements IContainerRecord {
private
final
IContainerManager
mManager
;
private
final
IFlutterViewContainer
mContainer
;
private
final
String
mUniqueId
;
private
final
Handler
mHandler
=
new
Handler
();
private
int
mState
=
STATE_UNKNOW
;
private
MethodChannelProxy
mProxy
=
new
MethodChannelProxy
();
...
...
@@ -85,8 +88,13 @@ public class ContainerRecord implements IContainerRecord {
* If current container is finishing, we should call destroy flutter page early.
*/
if
(
mContainer
.
isFinishing
())
{
mHandler
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
mProxy
.
destroy
();
}
});
}
}
@Override
...
...
android/src/main/java/com/taobao/idlefish/flutterboost/FlutterBoostPlugin.java
View file @
6433ecc8
...
...
@@ -28,6 +28,7 @@ import android.app.Application;
import
android.content.Context
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Bundle
;
import
com.alibaba.fastjson.JSON
;
...
...
@@ -49,6 +50,7 @@ import fleamarket.taobao.com.xservicekit.handler.MessageResult;
import
io.flutter.plugin.common.MethodCall
;
import
io.flutter.plugin.common.MethodChannel
;
import
io.flutter.plugin.common.PluginRegistry
;
import
io.flutter.view.FlutterView
;
public
class
FlutterBoostPlugin
implements
MethodChannel
.
MethodCallHandler
,
Application
.
ActivityLifecycleCallbacks
{
...
...
@@ -116,7 +118,7 @@ public class FlutterBoostPlugin implements MethodChannel.MethodCallHandler, Appl
mMediator
=
new
PageResultMediator
();
}
public
IFlutterViewContainer
findContainerById
(
String
id
){
public
IFlutterViewContainer
findContainerById
(
String
id
)
{
return
mManager
.
findContainerById
(
id
);
}
...
...
@@ -148,8 +150,6 @@ public class FlutterBoostPlugin implements MethodChannel.MethodCallHandler, Appl
}
sInstance
.
mPlatform
.
startActivity
(
ctx
,
concatUrl
(
url
,
params
),
requestCode
);
onPageResult
(
"result_id_100"
,
new
HashMap
(),
new
HashMap
());
}
public
static
void
openPage
(
Context
context
,
String
url
,
final
Map
params
,
int
requestCode
,
PageResultHandler
handler
)
{
...
...
@@ -168,8 +168,6 @@ public class FlutterBoostPlugin implements MethodChannel.MethodCallHandler, Appl
return
"result_id_"
+
kRid
;
}
public
static
void
onPageResult
(
String
key
,
Map
resultData
,
Map
params
){
if
(
sInstance
==
null
)
{
...
...
@@ -179,15 +177,15 @@ public class FlutterBoostPlugin implements MethodChannel.MethodCallHandler, Appl
sInstance
.
mMediator
.
onPageResult
(
key
,
resultData
,
params
);
}
public
static
void
setHandler
(
String
key
,
PageResultHandler
handler
)
{
public
static
void
setHandler
(
String
key
,
PageResultHandler
handler
)
{
if
(
sInstance
==
null
)
{
throw
new
RuntimeException
(
"FlutterBoostPlugin not init yet!"
);
}
sInstance
.
mMediator
.
setHandler
(
key
,
handler
);
sInstance
.
mMediator
.
setHandler
(
key
,
handler
);
}
public
static
void
removeHandler
(
String
key
)
{
public
static
void
removeHandler
(
String
key
)
{
if
(
sInstance
==
null
)
{
throw
new
RuntimeException
(
"FlutterBoostPlugin not init yet!"
);
}
...
...
@@ -229,10 +227,12 @@ public class FlutterBoostPlugin implements MethodChannel.MethodCallHandler, Appl
if
(
mCurrentActiveActivity
==
null
)
{
Debuger
.
log
(
"Application entry foreground"
);
if
(
mViewProvider
.
tryGetFlutterView
()
!=
null
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"type"
,
"foreground"
);
NavigationService
.
getService
().
emitEvent
(
map
);
}
}
mCurrentActiveActivity
=
activity
;
}
...
...
@@ -251,9 +251,11 @@ public class FlutterBoostPlugin implements MethodChannel.MethodCallHandler, Appl
if
(
mCurrentActiveActivity
==
activity
)
{
Debuger
.
log
(
"Application entry background"
);
if
(
mViewProvider
.
tryGetFlutterView
()
!=
null
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"type"
,
"background"
);
NavigationService
.
getService
().
emitEvent
(
map
);
}
mCurrentActiveActivity
=
null
;
}
}
...
...
@@ -268,29 +270,44 @@ public class FlutterBoostPlugin implements MethodChannel.MethodCallHandler, Appl
if
(
mCurrentActiveActivity
==
activity
)
{
Debuger
.
log
(
"Application entry background"
);
if
(
mViewProvider
.
tryGetFlutterView
()
!=
null
)
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"type"
,
"background"
);
NavigationService
.
getService
().
emitEvent
(
map
);
}
mCurrentActiveActivity
=
null
;
}
//reset view provider when single instance context is destroyed
// final FlutterView flutterView = mViewProvider.tryGetFlutterView();
// if(flutterView != null) {
// Activity ctxActivity = (Activity)flutterView.getContext();
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
// if((ctxActivity.isDestroyed() || ctxActivity == activity) &&
// mManager.getLastRecord() == null) {
// mViewProvider.reset();
// }
// }
// }
}
public
static
void
setBoostResult
(
Activity
activity
,
HashMap
result
){
public
static
void
setBoostResult
(
Activity
activity
,
HashMap
result
)
{
Intent
intent
=
new
Intent
();
if
(
result
!=
null
)
{
if
(
result
!=
null
)
{
intent
.
putExtra
(
IFlutterViewContainer
.
RESULT_KEY
,
result
);
}
activity
.
setResult
(
Activity
.
RESULT_OK
,
intent
);
activity
.
setResult
(
Activity
.
RESULT_OK
,
intent
);
}
public
static
void
onBoostResult
(
IFlutterViewContainer
container
,
int
requestCode
,
int
resultCode
,
Intent
intent
)
{
public
static
void
onBoostResult
(
IFlutterViewContainer
container
,
int
requestCode
,
int
resultCode
,
Intent
intent
)
{
Map
map
=
new
HashMap
();
if
(
intent
!=
null
)
{
map
.
put
(
"result"
,
intent
.
getSerializableExtra
(
IFlutterViewContainer
.
RESULT_KEY
));
if
(
intent
!=
null
)
{
map
.
put
(
"result"
,
intent
.
getSerializableExtra
(
IFlutterViewContainer
.
RESULT_KEY
));
}
map
.
put
(
"requestCode"
,
requestCode
);
map
.
put
(
"responseCode"
,
resultCode
);
containerManager
().
onContainerResult
(
container
,
map
);
map
.
put
(
"requestCode"
,
requestCode
);
map
.
put
(
"responseCode"
,
resultCode
);
containerManager
().
onContainerResult
(
container
,
map
);
}
}
...
...
android/src/main/java/com/taobao/idlefish/flutterboost/NavigationService/NavigationService_openPage.java
View file @
6433ecc8
...
...
@@ -38,20 +38,10 @@
private
boolean
onCall
(
MessageResult
<
Boolean
>
result
,
String
pageName
,
Map
params
,
Boolean
animated
){
Map
pageParams
=
null
;
int
requestCode
=
0
;
if
(
params
!=
null
&&
params
.
get
(
"query"
)
!=
null
)
{
pageParams
=
(
Map
)
params
.
get
(
"query"
);
}
if
(
params
!=
null
&&
params
.
get
(
"requestCode"
)
!=
null
)
{
requestCode
=
(
int
)
params
.
get
(
"requestCode"
);
}
FlutterBoostPlugin
.
openPage
(
null
,
pageName
,
pageParams
,
requestCode
);
FlutterBoostPlugin
.
openPage
(
null
,
pageName
,
params
,
0
);
if
(
result
!=
null
){
result
.
success
(
true
);
}
return
true
;
}
...
...
android/src/main/java/com/taobao/idlefish/flutterboost/containers/FlutterViewStub.java
View file @
6433ecc8
...
...
@@ -144,12 +144,11 @@ abstract public class FlutterViewStub extends FrameLayout {
if
(
flutterView
==
null
)
return
;
Debuger
.
log
(
"detachFlutterView"
);
if
(
mSnapshot
.
getParent
()
==
null
)
{
mBitmap
=
flutterView
.
getBitmap
();
if
(
mBitmap
!=
null
&&
!
mBitmap
.
isRecycled
())
{
mSnapshot
.
setImageBitmap
(
mBitmap
);
Debuger
.
log
(
"snapshot view"
);
addView
(
mSnapshot
);
}
}
...
...
@@ -160,11 +159,12 @@ abstract public class FlutterViewStub extends FrameLayout {
@Override
public
void
run
()
{
if
(
flutterView
.
getParent
()
!=
null
&&
flutterView
.
getParent
()
==
mStub
)
{
Debuger
.
log
(
"detachFlutterView"
);
mStub
.
removeView
(
flutterView
);
}
}
};
sHandler
.
sendMessage
(
msg
);
sHandler
.
sendMessage
Delayed
(
msg
,
18
);
}
public
void
destroy
()
{
...
...
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
View file @
6433ecc8
...
...
@@ -31,9 +31,13 @@ public class MyApplication extends FlutterApplication {
*/
@Override
public
Activity
getMainActivity
()
{
if
(
MainActivity
.
sRef
!=
null
)
{
return
MainActivity
.
sRef
.
get
();
}
return
null
;
}
@Override
public
boolean
isDebug
()
{
return
true
;
...
...
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