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
786e5617
Commit
786e5617
authored
Jun 25, 2019
by
Yacumima
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve
parent
d284055d
Changes
31
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
387 additions
and
1147 deletions
+387
-1147
android/src/main/java/com/taobao/idlefish/flutterboost/BoostChannel.java
...n/java/com/taobao/idlefish/flutterboost/BoostChannel.java
+113
-0
android/src/main/java/com/taobao/idlefish/flutterboost/BoostFlutterEngine.java
.../com/taobao/idlefish/flutterboost/BoostFlutterEngine.java
+1
-1
android/src/main/java/com/taobao/idlefish/flutterboost/BoostFlutterView.java
...va/com/taobao/idlefish/flutterboost/BoostFlutterView.java
+7
-8
android/src/main/java/com/taobao/idlefish/flutterboost/ContainerRecord.java
...ava/com/taobao/idlefish/flutterboost/ContainerRecord.java
+34
-39
android/src/main/java/com/taobao/idlefish/flutterboost/FlutterBoostPlugin.java
.../com/taobao/idlefish/flutterboost/FlutterBoostPlugin.java
+109
-41
android/src/main/java/com/taobao/idlefish/flutterboost/FlutterViewContainerManager.java
...ao/idlefish/flutterboost/FlutterViewContainerManager.java
+46
-8
android/src/main/java/com/taobao/idlefish/flutterboost/Platform.java
.../main/java/com/taobao/idlefish/flutterboost/Platform.java
+21
-0
android/src/main/java/com/taobao/idlefish/flutterboost/containers/BoostFlutterActivity.java
...dlefish/flutterboost/containers/BoostFlutterActivity.java
+18
-9
android/src/main/java/com/taobao/idlefish/flutterboost/containers/BoostFlutterFragment.java
...dlefish/flutterboost/containers/BoostFlutterFragment.java
+3
-10
android/src/main/java/com/taobao/idlefish/flutterboost/interfaces/IContainerManager.java
...o/idlefish/flutterboost/interfaces/IContainerManager.java
+8
-2
android/src/main/java/com/taobao/idlefish/flutterboost/interfaces/IFlutterViewContainer.java
...lefish/flutterboost/interfaces/IFlutterViewContainer.java
+5
-13
android/src/main/java/com/taobao/idlefish/flutterboost/interfaces/IOperateSyncer.java
...obao/idlefish/flutterboost/interfaces/IOperateSyncer.java
+4
-0
android/src/main/java/com/taobao/idlefish/flutterboost/interfaces/IPlatform.java
...om/taobao/idlefish/flutterboost/interfaces/IPlatform.java
+5
-9
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/NavigationService.java
...o/idlefish/flutterboost/messageing/NavigationService.java
+0
-255
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/Broadcastor.java
...ao/idlefish/flutterboost/messageing/base/Broadcastor.java
+0
-117
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/EvenListener.java
...o/idlefish/flutterboost/messageing/base/EvenListener.java
+0
-30
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/Message.java
...taobao/idlefish/flutterboost/messageing/base/Message.java
+0
-32
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageDispatcher.java
...efish/flutterboost/messageing/base/MessageDispatcher.java
+0
-30
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageDispatcherImp.java
...sh/flutterboost/messageing/base/MessageDispatcherImp.java
+0
-73
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageHandler.java
...idlefish/flutterboost/messageing/base/MessageHandler.java
+0
-32
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageImp.java
...bao/idlefish/flutterboost/messageing/base/MessageImp.java
+0
-46
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageResult.java
.../idlefish/flutterboost/messageing/base/MessageResult.java
+0
-30
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/ClosePageHandler.java
...sh/flutterboost/messageing/handlers/ClosePageHandler.java
+0
-60
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/OnFlutterPageResultHandler.java
...boost/messageing/handlers/OnFlutterPageResultHandler.java
+0
-59
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/OnShownContainerChangedHandler.java
...t/messageing/handlers/OnShownContainerChangedHandler.java
+0
-59
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/OpenPageHandler.java
...ish/flutterboost/messageing/handlers/OpenPageHandler.java
+0
-72
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/PageOnStartHandler.java
.../flutterboost/messageing/handlers/PageOnStartHandler.java
+0
-77
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/FlutterFragment.java
.../taobao/idlefish/flutterboostexample/FlutterFragment.java
+2
-2
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/FlutterPageActivity.java
...bao/idlefish/flutterboostexample/FlutterPageActivity.java
+2
-2
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
...om/taobao/idlefish/flutterboostexample/MyApplication.java
+7
-30
lib/flutter_boost.dart
lib/flutter_boost.dart
+2
-1
No files found.
android/src/main/java/com/taobao/idlefish/flutterboost/BoostChannel.java
0 → 100644
View file @
786e5617
package
com.taobao.idlefish.flutterboost
;
import
android.support.annotation.Nullable
;
import
java.io.Serializable
;
import
java.util.HashSet
;
import
java.util.Set
;
import
io.flutter.plugin.common.EventChannel
;
import
io.flutter.plugin.common.MethodCall
;
import
io.flutter.plugin.common.MethodChannel
;
public
class
BoostChannel
{
private
final
MethodChannel
mMethodChannel
;
private
final
EventChannel
mEventChannel
;
private
final
Set
<
MethodChannel
.
MethodCallHandler
>
mMethodCallHandlers
=
new
HashSet
<>();
private
EventChannel
.
EventSink
mEventSink
;
BoostChannel
(
MethodChannel
methodChannel
,
EventChannel
eventChannel
){
mMethodChannel
=
methodChannel
;
mEventChannel
=
eventChannel
;
mMethodChannel
.
setMethodCallHandler
(
new
MethodChannel
.
MethodCallHandler
()
{
@Override
public
void
onMethodCall
(
MethodCall
methodCall
,
MethodChannel
.
Result
result
)
{
Object
[]
handlers
;
synchronized
(
mMethodCallHandlers
)
{
handlers
=
mMethodCallHandlers
.
toArray
();
}
for
(
Object
o:
handlers
)
{
((
MethodChannel
.
MethodCallHandler
)
o
).
onMethodCall
(
methodCall
,
result
);
}
}
});
mEventChannel
.
setStreamHandler
(
new
EventChannel
.
StreamHandler
(){
@Override
public
void
onListen
(
Object
o
,
EventChannel
.
EventSink
eventSink
)
{
mEventSink
=
eventSink
;
}
@Override
public
void
onCancel
(
Object
o
)
{
}
});
}
public
void
invokeMethodUnsafe
(
final
String
name
,
Serializable
args
){
invokeMethod
(
name
,
args
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
@Nullable
Object
o
)
{
//every thing ok...
}
@Override
public
void
error
(
String
s
,
@Nullable
String
s1
,
@Nullable
Object
o
)
{
Debuger
.
log
(
"invoke method "
+
name
+
" error:"
+
s
+
" | "
+
s1
);
}
@Override
public
void
notImplemented
()
{
Debuger
.
log
(
"invoke method "
+
name
+
" notImplemented"
);
}
});
}
public
void
invokeMethod
(
final
String
name
,
Serializable
args
){
invokeMethod
(
name
,
args
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
@Nullable
Object
o
)
{
//every thing ok...
}
@Override
public
void
error
(
String
s
,
@Nullable
String
s1
,
@Nullable
Object
o
)
{
Debuger
.
exception
(
"invoke method "
+
name
+
" error:"
+
s
+
" | "
+
s1
);
}
@Override
public
void
notImplemented
()
{
Debuger
.
exception
(
"invoke method "
+
name
+
" notImplemented"
);
}
});
}
public
void
invokeMethod
(
final
String
name
,
Serializable
args
,
MethodChannel
.
Result
result
){
mMethodChannel
.
invokeMethod
(
name
,
args
,
result
);
}
public
void
addMethodCallHandler
(
MethodChannel
.
MethodCallHandler
handler
)
{
synchronized
(
mMethodCallHandlers
){
mMethodCallHandlers
.
add
(
handler
);
}
}
public
void
removeMethodCallHandler
(
MethodChannel
.
MethodCallHandler
handler
)
{
synchronized
(
mMethodCallHandlers
)
{
mMethodCallHandlers
.
remove
(
handler
);
}
}
public
void
sendEvent
(
Serializable
event
){
if
(
mEventSink
==
null
)
{
Debuger
.
exception
(
"event stream not listen yet!"
);
}
mEventSink
.
success
(
event
);
}
}
android/src/main/java/com/taobao/idlefish/flutterboost/BoostFlutterEngine.java
View file @
786e5617
...
@@ -52,7 +52,7 @@ public class BoostFlutterEngine extends FlutterEngine {
...
@@ -52,7 +52,7 @@ public class BoostFlutterEngine extends FlutterEngine {
stateListener
.
onEngineStarted
(
this
);
stateListener
.
onEngineStarted
(
this
);
}
}
FlutterBoostPlugin
.
singleton
().
platform
().
onR
egisterPlugins
(
mBoostPluginRegistry
);
FlutterBoostPlugin
.
singleton
().
platform
().
r
egisterPlugins
(
mBoostPluginRegistry
);
}
}
}
}
...
...
android/src/main/java/com/taobao/idlefish/flutterboost/BoostFlutterView.java
View file @
786e5617
...
@@ -270,11 +270,11 @@ public class BoostFlutterView extends FrameLayout {
...
@@ -270,11 +270,11 @@ public class BoostFlutterView extends FrameLayout {
}
}
public
void
onBackPressed
()
{
public
void
onBackPressed
()
{
Log
.
d
(
"FlutterFragment"
,
"onBackPressed()"
);
Debuger
.
log
(
"onBackPressed()"
);
if
(
mFlutterEngine
!=
null
)
{
if
(
mFlutterEngine
!=
null
)
{
mFlutterEngine
.
getNavigationChannel
().
popRoute
();
mFlutterEngine
.
getNavigationChannel
().
popRoute
();
}
else
{
}
else
{
Log
.
w
(
"FlutterFragment"
,
"Invoked onBackPressed() before FlutterFragment
was attached to an Activity."
);
Debuger
.
log
(
"Invoked onBackPressed() before BoostFlutterView
was attached to an Activity."
);
}
}
}
}
...
@@ -283,7 +283,7 @@ public class BoostFlutterView extends FrameLayout {
...
@@ -283,7 +283,7 @@ public class BoostFlutterView extends FrameLayout {
if
(
mFlutterEngine
!=
null
)
{
if
(
mFlutterEngine
!=
null
)
{
mFlutterEngine
.
getPluginRegistry
().
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
mFlutterEngine
.
getPluginRegistry
().
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
}
else
{
}
else
{
Log
.
w
(
"FlutterFragment"
,
"onRequestPermissionResult() invoked before FlutterFragment
was attached to an Activity."
);
Debuger
.
log
(
"onRequestPermissionResult() invoked before BoostFlutterView
was attached to an Activity."
);
}
}
}
}
...
@@ -292,7 +292,7 @@ public class BoostFlutterView extends FrameLayout {
...
@@ -292,7 +292,7 @@ public class BoostFlutterView extends FrameLayout {
if
(
mFlutterEngine
!=
null
)
{
if
(
mFlutterEngine
!=
null
)
{
mFlutterEngine
.
getPluginRegistry
().
onNewIntent
(
intent
);
mFlutterEngine
.
getPluginRegistry
().
onNewIntent
(
intent
);
}
else
{
}
else
{
Log
.
w
(
"FlutterFragment"
,
"onNewIntent() invoked before FlutterFragment
was attached to an Activity."
);
Debuger
.
log
(
"onNewIntent() invoked before BoostFlutterView
was attached to an Activity."
);
}
}
}
}
...
@@ -301,16 +301,15 @@ public class BoostFlutterView extends FrameLayout {
...
@@ -301,16 +301,15 @@ public class BoostFlutterView extends FrameLayout {
if
(
mFlutterEngine
!=
null
)
{
if
(
mFlutterEngine
!=
null
)
{
mFlutterEngine
.
getPluginRegistry
().
onActivityResult
(
requestCode
,
resultCode
,
data
);
mFlutterEngine
.
getPluginRegistry
().
onActivityResult
(
requestCode
,
resultCode
,
data
);
}
else
{
}
else
{
Log
.
w
(
"FlutterFragment"
,
"onActivityResult() invoked before FlutterFragment
was attached to an Activity."
);
Debuger
.
log
(
"onActivityResult() invoked before BoostFlutterView
was attached to an Activity."
);
}
}
}
}
public
void
onUserLeaveHint
()
{
public
void
onUserLeaveHint
()
{
if
(
mFlutterEngine
!=
null
)
{
if
(
mFlutterEngine
!=
null
)
{
mFlutterEngine
.
getPluginRegistry
().
onUserLeaveHint
();
mFlutterEngine
.
getPluginRegistry
().
onUserLeaveHint
();
}
else
{
}
else
{
Log
.
w
(
"FlutterFragment"
,
"onUserLeaveHint() invoked before FlutterFragment
was attached to an Activity."
);
Debuger
.
log
(
"onUserLeaveHint() invoked before BoostFlutterView
was attached to an Activity."
);
}
}
}
}
...
@@ -321,7 +320,7 @@ public class BoostFlutterView extends FrameLayout {
...
@@ -321,7 +320,7 @@ public class BoostFlutterView extends FrameLayout {
mFlutterEngine
.
getSystemChannel
().
sendMemoryPressureWarning
();
mFlutterEngine
.
getSystemChannel
().
sendMemoryPressureWarning
();
}
}
}
else
{
}
else
{
Log
.
w
(
"FlutterFragment"
,
"onTrimMemory() invoked before FlutterFragment
was attached to an Activity."
);
Debuger
.
log
(
"onTrimMemory() invoked before BoostFlutterView
was attached to an Activity."
);
}
}
}
}
...
...
android/src/main/java/com/taobao/idlefish/flutterboost/ContainerRecord.java
View file @
786e5617
...
@@ -25,8 +25,6 @@ package com.taobao.idlefish.flutterboost;
...
@@ -25,8 +25,6 @@ package com.taobao.idlefish.flutterboost;
import
android.content.Intent
;
import
android.content.Intent
;
import
com.taobao.idlefish.flutterboost.messageing.NavigationService
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageResult
;
import
com.taobao.idlefish.flutterboost.interfaces.IContainerRecord
;
import
com.taobao.idlefish.flutterboost.interfaces.IContainerRecord
;
import
com.taobao.idlefish.flutterboost.interfaces.IFlutterViewContainer
;
import
com.taobao.idlefish.flutterboost.interfaces.IFlutterViewContainer
;
...
@@ -138,12 +136,12 @@ public class ContainerRecord implements IContainerRecord {
...
@@ -138,12 +136,12 @@ public class ContainerRecord implements IContainerRecord {
Debuger
.
exception
(
"state error"
);
Debuger
.
exception
(
"state error"
);
}
}
Map
<
String
,
String
>
map
=
new
HashMap
<>();
Hash
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"type"
,
"backPressedCallback"
);
map
.
put
(
"type"
,
"backPressedCallback"
);
map
.
put
(
"name"
,
mContainer
.
getContainer
Name
());
map
.
put
(
"name"
,
mContainer
.
getContainer
Url
());
map
.
put
(
"uniqueId"
,
mUniqueId
);
map
.
put
(
"uniqueId"
,
mUniqueId
);
FlutterBoostPlugin
.
getInstance
().
sendEvent
(
"lifecycle"
,
map
);
FlutterBoostPlugin
.
singleton
().
channel
().
sendEvent
(
map
);
mContainer
.
getBoostFlutterView
().
onBackPressed
();
mContainer
.
getBoostFlutterView
().
onBackPressed
();
}
}
...
@@ -163,6 +161,11 @@ public class ContainerRecord implements IContainerRecord {
...
@@ -163,6 +161,11 @@ public class ContainerRecord implements IContainerRecord {
mContainer
.
getBoostFlutterView
().
onActivityResult
(
requestCode
,
resultCode
,
data
);
mContainer
.
getBoostFlutterView
().
onActivityResult
(
requestCode
,
resultCode
,
data
);
}
}
@Override
public
void
onContainerResult
(
int
requestCode
,
Map
<
String
,
Object
>
result
)
{
mManager
.
setContainerResult
(
this
,
requestCode
,
result
);
}
@Override
@Override
public
void
onUserLeaveHint
()
{
public
void
onUserLeaveHint
()
{
mContainer
.
getBoostFlutterView
().
onUserLeaveHint
();
mContainer
.
getBoostFlutterView
().
onUserLeaveHint
();
...
@@ -184,10 +187,9 @@ public class ContainerRecord implements IContainerRecord {
...
@@ -184,10 +187,9 @@ public class ContainerRecord implements IContainerRecord {
private
void
create
()
{
private
void
create
()
{
if
(
mState
==
STATE_UNKNOW
)
{
if
(
mState
==
STATE_UNKNOW
)
{
NavigationService
.
didInitPageContainer
(
invokeChannelUnsafe
(
genResult
(
"didInitPageContainer"
),
mContainer
.
getContainerUrl
(),
mContainer
.
getContainerName
(),
mContainer
.
getContainerUrlParams
(),
mContainer
.
getContainerParams
(),
mUniqueId
mUniqueId
);
);
//Debuger.log("didInitPageContainer");
//Debuger.log("didInitPageContainer");
...
@@ -196,10 +198,9 @@ public class ContainerRecord implements IContainerRecord {
...
@@ -196,10 +198,9 @@ public class ContainerRecord implements IContainerRecord {
}
}
private
void
appear
()
{
private
void
appear
()
{
NavigationService
.
didShowPageContainer
(
invokeChannelUnsafe
(
genResult
(
"didShowPageContainer"
),
mContainer
.
getContainerUrl
(),
mContainer
.
getContainerName
(),
mContainer
.
getContainerUrlParams
(),
mContainer
.
getContainerParams
(),
mUniqueId
mUniqueId
);
);
//Debuger.log("didShowPageContainer");
//Debuger.log("didShowPageContainer");
...
@@ -209,10 +210,9 @@ public class ContainerRecord implements IContainerRecord {
...
@@ -209,10 +210,9 @@ public class ContainerRecord implements IContainerRecord {
private
void
disappear
()
{
private
void
disappear
()
{
if
(
mState
<
STATE_DISAPPEAR
)
{
if
(
mState
<
STATE_DISAPPEAR
)
{
NavigationService
.
didDisappearPageContainer
(
invokeChannel
(
genResult
(
"didDisappearPageContainer"
),
mContainer
.
getContainerUrl
(),
mContainer
.
getContainerName
(),
mContainer
.
getContainerUrlParams
(),
mContainer
.
getContainerParams
(),
mUniqueId
mUniqueId
);
);
//Debuger.log("didDisappearPageContainer");
//Debuger.log("didDisappearPageContainer");
...
@@ -223,10 +223,9 @@ public class ContainerRecord implements IContainerRecord {
...
@@ -223,10 +223,9 @@ public class ContainerRecord implements IContainerRecord {
private
void
destroy
()
{
private
void
destroy
()
{
if
(
mState
<
STATE_DESTROYED
)
{
if
(
mState
<
STATE_DESTROYED
)
{
NavigationService
.
willDeallocPageContainer
(
invokeChannel
(
genResult
(
"willDeallocPageContainer"
),
mContainer
.
getContainerUrl
(),
mContainer
.
getContainerName
(),
mContainer
.
getContainerUrlParams
(),
mContainer
.
getContainerParams
(),
mUniqueId
mUniqueId
);
);
//Debuger.log("willDeallocPageContainer");
//Debuger.log("willDeallocPageContainer");
...
@@ -234,25 +233,21 @@ public class ContainerRecord implements IContainerRecord {
...
@@ -234,25 +233,21 @@ public class ContainerRecord implements IContainerRecord {
mState
=
STATE_DESTROYED
;
mState
=
STATE_DESTROYED
;
}
}
}
}
}
private
MessageResult
<
Boolean
>
genResult
(
final
String
name
)
{
return
new
MessageResult
<
Boolean
>()
{
@Override
public
void
success
(
Boolean
var1
)
{
//Debuger.log(name + " call success");
}
@Override
public
void
invokeChannel
(
String
pageName
,
Map
params
,
String
uniqueId
)
{
public
void
error
(
String
var1
,
String
var2
,
Object
var3
)
{
HashMap
<
String
,
Object
>
args
=
new
HashMap
<>();
Debuger
.
log
(
name
+
" call error"
);
args
.
put
(
"pageName"
,
pageName
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
FlutterBoostPlugin
.
singleton
().
channel
().
invokeMethod
(
"didInitPageContainer"
,
args
);
}
}
@Override
public
void
invokeChannelUnsafe
(
String
pageName
,
Map
params
,
String
uniqueId
)
{
public
void
notImplemented
()
{
HashMap
<
String
,
Object
>
args
=
new
HashMap
<>();
Debuger
.
log
(
name
+
" call not Impelemented"
);
args
.
put
(
"pageName"
,
pageName
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
FlutterBoostPlugin
.
singleton
().
channel
().
invokeMethodUnsafe
(
"didInitPageContainer"
,
args
);
}
}
};
}
}
}
}
android/src/main/java/com/taobao/idlefish/flutterboost/FlutterBoostPlugin.java
View file @
786e5617
This diff is collapsed.
Click to expand it.
android/src/main/java/com/taobao/idlefish/flutterboost/FlutterViewContainerManager.java
View file @
786e5617
...
@@ -23,7 +23,9 @@
...
@@ -23,7 +23,9 @@
*/
*/
package
com.taobao.idlefish.flutterboost
;
package
com.taobao.idlefish.flutterboost
;
import
android.content.Context
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.util.SparseArray
;
import
com.taobao.idlefish.flutterboost.interfaces.IContainerManager
;
import
com.taobao.idlefish.flutterboost.interfaces.IContainerManager
;
import
com.taobao.idlefish.flutterboost.interfaces.IContainerRecord
;
import
com.taobao.idlefish.flutterboost.interfaces.IContainerRecord
;
...
@@ -33,11 +35,13 @@ import com.taobao.idlefish.flutterboost.interfaces.IOperateSyncer;
...
@@ -33,11 +35,13 @@ import com.taobao.idlefish.flutterboost.interfaces.IOperateSyncer;
import
java.lang.ref.WeakReference
;
import
java.lang.ref.WeakReference
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.Stack
;
import
java.util.Stack
;
import
java.util.concurrent.atomic.AtomicInteger
;
public
class
FlutterViewContainerManager
implements
IContainerManager
{
public
class
FlutterViewContainerManager
implements
IContainerManager
{
...
@@ -45,8 +49,10 @@ public class FlutterViewContainerManager implements IContainerManager {
...
@@ -45,8 +49,10 @@ public class FlutterViewContainerManager implements IContainerManager {
private
final
Set
<
ContainerRef
>
mRefs
=
new
HashSet
<>();
private
final
Set
<
ContainerRef
>
mRefs
=
new
HashSet
<>();
private
final
Stack
<
IContainerRecord
>
mRecordStack
=
new
Stack
<>();
private
final
Stack
<
IContainerRecord
>
mRecordStack
=
new
Stack
<>();
FlutterViewContainerManager
()
{}
private
final
AtomicInteger
mRequestCode
=
new
AtomicInteger
(
0
);
private
final
SparseArray
<
OnResult
>
mOnResults
=
new
SparseArray
<>();
FlutterViewContainerManager
()
{}
@Override
@Override
public
IOperateSyncer
generateSyncer
(
IFlutterViewContainer
container
)
{
public
IOperateSyncer
generateSyncer
(
IFlutterViewContainer
container
)
{
...
@@ -54,7 +60,7 @@ public class FlutterViewContainerManager implements IContainerManager {
...
@@ -54,7 +60,7 @@ public class FlutterViewContainerManager implements IContainerManager {
ContainerRecord
record
=
new
ContainerRecord
(
this
,
container
);
ContainerRecord
record
=
new
ContainerRecord
(
this
,
container
);
if
(
mRecordMap
.
put
(
container
,
record
)
!=
null
)
{
if
(
mRecordMap
.
put
(
container
,
record
)
!=
null
)
{
Debuger
.
exception
(
"container:"
+
container
.
getContainer
Name
()
+
" already exists!"
);
Debuger
.
exception
(
"container:"
+
container
.
getContainer
Url
()
+
" already exists!"
);
}
}
mRefs
.
add
(
new
ContainerRef
(
record
.
uniqueId
(),
container
));
mRefs
.
add
(
new
ContainerRef
(
record
.
uniqueId
(),
container
));
...
@@ -81,18 +87,51 @@ public class FlutterViewContainerManager implements IContainerManager {
...
@@ -81,18 +87,51 @@ public class FlutterViewContainerManager implements IContainerManager {
mRecordMap
.
remove
(
record
.
getContainer
());
mRecordMap
.
remove
(
record
.
getContainer
());
}
}
void
setContainerResult
(
IContainerRecord
record
,
int
requestCode
,
Map
<
String
,
Object
>
result
)
{
IFlutterViewContainer
target
=
findContainerById
(
record
.
uniqueId
());
if
(
target
==
null
)
{
Debuger
.
exception
(
"setContainerResult error, url="
+
record
.
getContainer
().
getContainerUrl
());
}
OnResult
onResult
=
mOnResults
.
get
(
requestCode
);
if
(
onResult
!=
null
)
{
onResult
.
onResult
(
result
);
}
mOnResults
.
remove
(
requestCode
);
}
@Override
public
void
openContainer
(
String
url
,
Map
<
String
,
Object
>
urlParams
,
Map
<
String
,
Object
>
exts
,
OnResult
onResult
)
{
Context
context
=
FlutterBoostPlugin
.
singleton
().
currentActivity
();
if
(
context
==
null
)
{
context
=
FlutterBoostPlugin
.
singleton
().
platform
().
getApplication
();
}
int
requestCode
=
mRequestCode
.
addAndGet
(
3
);
if
(
onResult
!=
null
)
{
mOnResults
.
put
(
requestCode
,
onResult
);
}
FlutterBoostPlugin
.
singleton
().
platform
().
openContainer
(
context
,
url
,
urlParams
,
requestCode
,
exts
);
}
@Override
@Override
public
IFlutterViewContainer
closeContainer
(
String
uniqueId
,
Map
<
String
,
Object
>
result
)
{
public
IContainerRecord
closeContainer
(
String
uniqueId
,
Map
<
String
,
Object
>
result
,
Map
<
String
,
Object
>
exts
)
{
IContainerRecord
targetRecord
=
null
;
for
(
Map
.
Entry
<
IFlutterViewContainer
,
IContainerRecord
>
entry
:
mRecordMap
.
entrySet
())
{
for
(
Map
.
Entry
<
IFlutterViewContainer
,
IContainerRecord
>
entry
:
mRecordMap
.
entrySet
())
{
if
(
TextUtils
.
equals
(
uniqueId
,
entry
.
getValue
().
uniqueId
()))
{
if
(
TextUtils
.
equals
(
uniqueId
,
entry
.
getValue
().
uniqueId
()))
{
entry
.
getKey
().
finishContainer
();
targetRecord
=
entry
.
getValue
();
return
entry
.
getKey
()
;
break
;
}
}
}
}
if
(
targetRecord
==
null
)
{
Debuger
.
exception
(
"closeContainer can not find uniqueId:"
+
uniqueId
);
Debuger
.
exception
(
"closeContainer can not find uniqueId:"
+
uniqueId
);
}
return
null
;
FlutterBoostPlugin
.
singleton
().
platform
().
closeContainer
(
targetRecord
,
result
,
exts
);
return
targetRecord
;
}
}
@Override
@Override
...
@@ -173,7 +212,6 @@ public class FlutterViewContainerManager implements IContainerManager {
...
@@ -173,7 +212,6 @@ public class FlutterViewContainerManager implements IContainerManager {
return
false
;
return
false
;
}
}
public
static
class
ContainerRef
{
public
static
class
ContainerRef
{
public
final
String
uniqueId
;
public
final
String
uniqueId
;
public
final
WeakReference
<
IFlutterViewContainer
>
container
;
public
final
WeakReference
<
IFlutterViewContainer
>
container
;
...
...
android/src/main/java/com/taobao/idlefish/flutterboost/Platform.java
0 → 100644
View file @
786e5617
package
com.taobao.idlefish.flutterboost
;
import
com.taobao.idlefish.flutterboost.interfaces.IContainerRecord
;
import
com.taobao.idlefish.flutterboost.interfaces.IPlatform
;
import
java.util.Map
;
public
abstract
class
Platform
implements
IPlatform
{
@Override
public
void
closeContainer
(
IContainerRecord
record
,
Map
<
String
,
Object
>
result
,
Map
<
String
,
Object
>
exts
)
{
if
(
record
==
null
)
return
;
record
.
getContainer
().
finishContainer
(
result
);
}
@Override
public
int
whenEngineStart
()
{
return
ANY_ACTIVITY_CREATED
;
}
}
android/src/main/java/com/taobao/idlefish/flutterboost/containers/BoostFlutterActivity.java
View file @
786e5617
...
@@ -46,7 +46,9 @@ import com.taobao.idlefish.flutterboost.FlutterBoostPlugin;
...
@@ -46,7 +46,9 @@ import com.taobao.idlefish.flutterboost.FlutterBoostPlugin;
import
com.taobao.idlefish.flutterboost.interfaces.IFlutterViewContainer
;
import
com.taobao.idlefish.flutterboost.interfaces.IFlutterViewContainer
;
import
com.taobao.idlefish.flutterboost.interfaces.IOperateSyncer
;
import
com.taobao.idlefish.flutterboost.interfaces.IOperateSyncer
;
import
java.io.Serializable
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
io.flutter.embedding.android.FlutterView
;
import
io.flutter.embedding.android.FlutterView
;
import
io.flutter.plugin.platform.PlatformPlugin
;
import
io.flutter.plugin.platform.PlatformPlugin
;
...
@@ -180,6 +182,16 @@ public abstract class BoostFlutterActivity extends Activity implements IFlutterV
...
@@ -180,6 +182,16 @@ public abstract class BoostFlutterActivity extends Activity implements IFlutterV
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
mSyncer
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
mSyncer
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
Map
<
String
,
Object
>
result
=
null
;
if
(
data
!=
null
)
{
Serializable
rlt
=
data
.
getSerializableExtra
(
RESULT_KEY
);
if
(
rlt
instanceof
Map
)
{
result
=
(
Map
<
String
,
Object
>)
rlt
;
}
}
mSyncer
.
onContainerResult
(
requestCode
,
result
);
}
}
@Override
@Override
...
@@ -217,8 +229,12 @@ public abstract class BoostFlutterActivity extends Activity implements IFlutterV
...
@@ -217,8 +229,12 @@ public abstract class BoostFlutterActivity extends Activity implements IFlutterV
}
}
@Override
@Override
public
void
finishContainer
()
{
public
void
finishContainer
(
Map
<
String
,
Object
>
result
)
{
finish
();
Intent
intent
=
new
Intent
();
if
(
result
!=
null
)
{
intent
.
putExtra
(
RESULT_KEY
,
new
HashMap
<>(
result
));
}
setResult
(
Activity
.
RESULT_OK
,
intent
);
}
}
@Override
@Override
...
@@ -226,11 +242,4 @@ public abstract class BoostFlutterActivity extends Activity implements IFlutterV
...
@@ -226,11 +242,4 @@ public abstract class BoostFlutterActivity extends Activity implements IFlutterV
@Override
@Override
public
void
onContainerHidden
()
{}
public
void
onContainerHidden
()
{}
@Override
public
void
setBoostResult
(
HashMap
result
)
{
Intent
data
=
new
Intent
();
data
.
putExtra
(
RESULT_KEY
,
result
);
setResult
(
RESULT_OK
,
data
);
}
}
}
android/src/main/java/com/taobao/idlefish/flutterboost/containers/BoostFlutterFragment.java
View file @
786e5617
...
@@ -38,7 +38,7 @@ import com.taobao.idlefish.flutterboost.FlutterBoostPlugin;
...
@@ -38,7 +38,7 @@ import com.taobao.idlefish.flutterboost.FlutterBoostPlugin;
import
com.taobao.idlefish.flutterboost.interfaces.IFlutterViewContainer
;
import
com.taobao.idlefish.flutterboost.interfaces.IFlutterViewContainer
;
import
com.taobao.idlefish.flutterboost.interfaces.IOperateSyncer
;
import
com.taobao.idlefish.flutterboost.interfaces.IOperateSyncer
;
import
java.util.
Hash
Map
;
import
java.util.Map
;
import
io.flutter.embedding.android.FlutterView
;
import
io.flutter.embedding.android.FlutterView
;
...
@@ -137,8 +137,8 @@ abstract public class BoostFlutterFragment extends Fragment implements IFlutterV
...
@@ -137,8 +137,8 @@ abstract public class BoostFlutterFragment extends Fragment implements IFlutterV
}
}
@Override
@Override
public
void
finishContainer
()
{
public
void
finishContainer
(
Map
<
String
,
Object
>
result
)
{
get
Activity
().
finish
();
get
FragmentManager
().
popBackStack
();
}
}
@Override
@Override
...
@@ -146,11 +146,4 @@ abstract public class BoostFlutterFragment extends Fragment implements IFlutterV
...
@@ -146,11 +146,4 @@ abstract public class BoostFlutterFragment extends Fragment implements IFlutterV
@Override
@Override
public
void
onContainerHidden
()
{}
public
void
onContainerHidden
()
{}
@Override
public
void
setBoostResult
(
HashMap
result
)
{
Intent
data
=
new
Intent
();
data
.
putExtra
(
RESULT_KEY
,
result
);
getActivity
().
setResult
(
Activity
.
RESULT_OK
,
data
);
}
}
}
android/src/main/java/com/taobao/idlefish/flutterboost/interfaces/IContainerManager.java
View file @
786e5617
...
@@ -29,7 +29,9 @@ public interface IContainerManager {
...
@@ -29,7 +29,9 @@ public interface IContainerManager {
IOperateSyncer
generateSyncer
(
IFlutterViewContainer
container
);
IOperateSyncer
generateSyncer
(
IFlutterViewContainer
container
);
IFlutterViewContainer
closeContainer
(
String
uniqueId
,
Map
<
String
,
Object
>
result
);
void
openContainer
(
String
url
,
Map
<
String
,
Object
>
urlParams
,
Map
<
String
,
Object
>
exts
,
OnResult
onResult
);
IContainerRecord
closeContainer
(
String
uniqueId
,
Map
<
String
,
Object
>
result
,
Map
<
String
,
Object
>
exts
);
IContainerRecord
getCurrentTopRecord
();
IContainerRecord
getCurrentTopRecord
();
...
@@ -40,4 +42,8 @@ public interface IContainerManager {
...
@@ -40,4 +42,8 @@ public interface IContainerManager {
void
onShownContainerChanged
(
String
oldUniqueId
,
String
nowUniqueId
);
void
onShownContainerChanged
(
String
oldUniqueId
,
String
nowUniqueId
);
boolean
hasContainerAppear
();
boolean
hasContainerAppear
();
interface
OnResult
{
void
onResult
(
Map
<
String
,
Object
>
result
);
}
}
}
\ No newline at end of file
android/src/main/java/com/taobao/idlefish/flutterboost/interfaces/IFlutterViewContainer.java
View file @
786e5617
...
@@ -24,12 +24,10 @@
...
@@ -24,12 +24,10 @@
package
com.taobao.idlefish.flutterboost.interfaces
;
package
com.taobao.idlefish.flutterboost.interfaces
;
import
android.app.Activity
;
import
android.app.Activity
;
import
com.taobao.idlefish.flutterboost.BoostFlutterView
;
import
com.taobao.idlefish.flutterboost.BoostFlutterView
;
import
java.io.Serializable
;
import
java.util.HashMap
;
import
java.util.Map
;
import
io.flutter.plugin.common.PluginRegistry
;
import
java.util.Map
;
/**
/**
* a container which contains the flutter view
* a container which contains the flutter view
...
@@ -48,19 +46,19 @@ public interface IFlutterViewContainer {
...
@@ -48,19 +46,19 @@ public interface IFlutterViewContainer {
/**
/**
* call to destroy the container
* call to destroy the container
*/
*/
void
finishContainer
();
void
finishContainer
(
Map
<
String
,
Object
>
result
);
/**
/**
* container name
* container name
* @return
* @return
*/
*/
String
getContainer
Name
();
String
getContainer
Url
();
/**
/**
* container params
* container params
* @return
* @return
*/
*/
Map
getContainerParams
();
Map
getContainer
Url
Params
();
/**
/**
* callback when container shown
* callback when container shown
...
@@ -71,10 +69,4 @@ public interface IFlutterViewContainer {
...
@@ -71,10 +69,4 @@ public interface IFlutterViewContainer {
* callback when container hidden
* callback when container hidden
*/
*/
void
onContainerHidden
();
void
onContainerHidden
();
/**
* call by flutter side to set result
* @param result
*/
void
setBoostResult
(
HashMap
result
);
}
}
android/src/main/java/com/taobao/idlefish/flutterboost/interfaces/IOperateSyncer.java
View file @
786e5617
...
@@ -2,6 +2,8 @@ package com.taobao.idlefish.flutterboost.interfaces;
...
@@ -2,6 +2,8 @@ package com.taobao.idlefish.flutterboost.interfaces;
import
android.content.Intent
;
import
android.content.Intent
;
import
java.util.Map
;
public
interface
IOperateSyncer
{
public
interface
IOperateSyncer
{
void
onCreate
();
void
onCreate
();
...
@@ -20,6 +22,8 @@ public interface IOperateSyncer {
...
@@ -20,6 +22,8 @@ public interface IOperateSyncer {
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
);
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
);
void
onContainerResult
(
int
requestCode
,
Map
<
String
,
Object
>
result
);
void
onUserLeaveHint
();
void
onUserLeaveHint
();
void
onTrimMemory
(
int
level
);
void
onTrimMemory
(
int
level
);
...
...
android/src/main/java/com/taobao/idlefish/flutterboost/interfaces/IPlatform.java
View file @
786e5617
...
@@ -55,17 +55,13 @@ public interface IPlatform {
...
@@ -55,17 +55,13 @@ public interface IPlatform {
* register plugins
* register plugins
* @return
* @return
*/
*/
void
onRegisterPlugins
(
PluginRegistry
registry
);
void
registerPlugins
(
PluginRegistry
registry
);
void
openContainer
(
Context
context
,
String
url
,
Map
<
String
,
Object
>
urlParams
,
int
requestCode
,
Map
<
String
,
Object
>
exts
);
/**
* start a new activity from flutter page, you may need a page router with url
* @param context
* @param url
* @param requestCode
* @return
*/
boolean
startActivity
(
Context
context
,
String
url
,
Map
params
,
int
requestCode
);
void
closeContainer
(
IContainerRecord
record
,
Map
<
String
,
Object
>
result
,
Map
<
String
,
Object
>
exts
);
/**
/**
* @return
* @return
...
...
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/NavigationService.java
deleted
100755 → 0
View file @
d284055d
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.messageing
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageResult
;
import
java.util.HashMap
;
import
java.util.Map
;
import
io.flutter.plugin.common.MethodChannel
;
public
class
NavigationService
{
public
static
MethodChannel
methodChannel
=
null
;
public
static
void
onNativePageResult
(
final
MessageResult
<
Boolean
>
result
,
String
uniqueId
,
String
key
,
Map
resultData
,
Map
params
)
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>();
args
.
put
(
"uniqueId"
,
uniqueId
);
args
.
put
(
"key"
,
key
);
args
.
put
(
"resultData"
,
resultData
);
args
.
put
(
"params"
,
params
);
methodChannel
.
invokeMethod
(
"onNativePageResult"
,
args
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
Object
o
)
{
if
(
o
instanceof
Boolean
)
{
result
.
success
((
Boolean
)
o
);
}
else
{
result
.
error
(
"return type error code dart code"
,
""
,
""
);
}
}
@Override
public
void
error
(
String
s
,
String
s1
,
Object
o
)
{
if
(
result
!=
null
)
{
result
.
error
(
s
,
s1
,
o
);
}
}
@Override
public
void
notImplemented
()
{
if
(
result
!=
null
)
{
result
.
notImplemented
();
}
}
});
}
public
static
void
didShowPageContainer
(
final
MessageResult
<
Boolean
>
result
,
String
pageName
,
Map
params
,
String
uniqueId
)
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>();
args
.
put
(
"pageName"
,
pageName
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
methodChannel
.
invokeMethod
(
"didShowPageContainer"
,
args
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
Object
o
)
{
if
(
o
instanceof
Boolean
)
{
result
.
success
((
Boolean
)
o
);
}
else
{
result
.
error
(
"return type error code dart code"
,
""
,
""
);
}
}
@Override
public
void
error
(
String
s
,
String
s1
,
Object
o
)
{
if
(
result
!=
null
)
{
result
.
error
(
s
,
s1
,
o
);
}
}
@Override
public
void
notImplemented
()
{
if
(
result
!=
null
)
{
result
.
notImplemented
();
}
}
});
}
public
static
void
willShowPageContainer
(
final
MessageResult
<
Boolean
>
result
,
String
pageName
,
Map
params
,
String
uniqueId
)
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>();
args
.
put
(
"pageName"
,
pageName
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
methodChannel
.
invokeMethod
(
"willShowPageContainer"
,
args
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
Object
o
)
{
if
(
o
instanceof
Boolean
)
{
result
.
success
((
Boolean
)
o
);
}
else
{
result
.
error
(
"return type error code dart code"
,
""
,
""
);
}
}
@Override
public
void
error
(
String
s
,
String
s1
,
Object
o
)
{
if
(
result
!=
null
)
{
result
.
error
(
s
,
s1
,
o
);
}
}
@Override
public
void
notImplemented
()
{
if
(
result
!=
null
)
{
result
.
notImplemented
();
}
}
});
}
public
static
void
willDisappearPageContainer
(
final
MessageResult
<
Boolean
>
result
,
String
pageName
,
Map
params
,
String
uniqueId
)
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>();
args
.
put
(
"pageName"
,
pageName
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
methodChannel
.
invokeMethod
(
"willDisappearPageContainer"
,
args
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
Object
o
)
{
if
(
o
instanceof
Boolean
)
{
result
.
success
((
Boolean
)
o
);
}
else
{
result
.
error
(
"return type error code dart code"
,
""
,
""
);
}
}
@Override
public
void
error
(
String
s
,
String
s1
,
Object
o
)
{
if
(
result
!=
null
)
{
result
.
error
(
s
,
s1
,
o
);
}
}
@Override
public
void
notImplemented
()
{
if
(
result
!=
null
)
{
result
.
notImplemented
();
}
}
});
}
public
static
void
didDisappearPageContainer
(
final
MessageResult
<
Boolean
>
result
,
String
pageName
,
Map
params
,
String
uniqueId
)
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>();
args
.
put
(
"pageName"
,
pageName
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
methodChannel
.
invokeMethod
(
"didDisappearPageContainer"
,
args
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
Object
o
)
{
if
(
o
instanceof
Boolean
)
{
result
.
success
((
Boolean
)
o
);
}
else
{
result
.
error
(
"return type error code dart code"
,
""
,
""
);
}
}
@Override
public
void
error
(
String
s
,
String
s1
,
Object
o
)
{
if
(
result
!=
null
)
{
result
.
error
(
s
,
s1
,
o
);
}
}
@Override
public
void
notImplemented
()
{
if
(
result
!=
null
)
{
result
.
notImplemented
();
}
}
});
}
public
static
void
didInitPageContainer
(
final
MessageResult
<
Boolean
>
result
,
String
pageName
,
Map
params
,
String
uniqueId
)
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>();
args
.
put
(
"pageName"
,
pageName
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
methodChannel
.
invokeMethod
(
"didInitPageContainer"
,
args
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
Object
o
)
{
if
(
o
instanceof
Boolean
)
{
result
.
success
((
Boolean
)
o
);
}
else
{
result
.
error
(
"return type error code dart code"
,
""
,
""
);
}
}
@Override
public
void
error
(
String
s
,
String
s1
,
Object
o
)
{
if
(
result
!=
null
)
{
result
.
error
(
s
,
s1
,
o
);
}
}
@Override
public
void
notImplemented
()
{
if
(
result
!=
null
)
{
result
.
notImplemented
();
}
}
});
}
public
static
void
willDeallocPageContainer
(
final
MessageResult
<
Boolean
>
result
,
String
pageName
,
Map
params
,
String
uniqueId
)
{
Map
<
String
,
Object
>
args
=
new
HashMap
<>();
args
.
put
(
"pageName"
,
pageName
);
args
.
put
(
"params"
,
params
);
args
.
put
(
"uniqueId"
,
uniqueId
);
methodChannel
.
invokeMethod
(
"willDeallocPageContainer"
,
args
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
Object
o
)
{
if
(
o
instanceof
Boolean
)
{
result
.
success
((
Boolean
)
o
);
}
else
{
result
.
error
(
"return type error code dart code"
,
""
,
""
);
}
}
@Override
public
void
error
(
String
s
,
String
s1
,
Object
o
)
{
if
(
result
!=
null
)
{
result
.
error
(
s
,
s1
,
o
);
}
}
@Override
public
void
notImplemented
()
{
if
(
result
!=
null
)
{
result
.
notImplemented
();
}
}
});
}
}
\ No newline at end of file
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/Broadcastor.java
deleted
100644 → 0
View file @
d284055d
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.messageing.base
;
import
android.support.annotation.Nullable
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
io.flutter.plugin.common.MethodChannel
;
public
class
Broadcastor
{
private
MethodChannel
channel
=
null
;
private
Map
<
String
,
List
<
EvenListener
>>
lists
=
new
HashMap
<>();
public
Broadcastor
(
MethodChannel
channel
)
{
this
.
channel
=
channel
;
}
public
void
sendEvent
(
String
name
,
Map
arguments
)
{
if
(
name
==
null
)
{
return
;
}
Map
msg
=
new
HashMap
();
msg
.
put
(
"name"
,
name
);
if
(
arguments
!=
null
){
msg
.
put
(
"arguments"
,
arguments
);
}
channel
.
invokeMethod
(
"__event__"
,
msg
,
new
MethodChannel
.
Result
()
{
@Override
public
void
success
(
@Nullable
Object
o
)
{
}
@Override
public
void
error
(
String
s
,
@Nullable
String
s1
,
@Nullable
Object
o
)
{
}
@Override
public
void
notImplemented
()
{
}
});
}
public
void
dispatch
(
String
name
,
Map
arguments
)
{
if
(
name
==
null
||
arguments
==
null
){
return
;
}
String
eventName
=
(
String
)
arguments
.
get
(
"name"
);
Map
eventArguments
=
(
Map
)
arguments
.
get
(
"arguments"
);
List
<
EvenListener
>
list
=
lists
.
get
(
eventName
);
if
(
list
==
null
){
return
;
}
for
(
EvenListener
l
:
list
){
l
.
onEvent
(
eventName
,
eventArguments
);
}
return
;
}
public
void
addEventListener
(
String
name
,
EvenListener
listener
){
if
(
listener
==
null
||
name
==
null
){
return
;
}
List
<
EvenListener
>
list
=
lists
.
get
(
name
);
if
(
list
==
null
){
list
=
new
LinkedList
<>();
lists
.
put
(
name
,
list
);
}
list
.
add
(
listener
);
}
public
void
removeEventListener
(
String
name
,
EvenListener
listener
){
if
(
listener
==
null
||
name
==
null
){
return
;
}
List
<
EvenListener
>
list
=
lists
.
get
(
name
);
if
(
list
!=
null
){
list
.
remove
(
listener
);
}
}
}
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/EvenListener.java
deleted
100644 → 0
View file @
d284055d
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.messageing.base
;
import
java.util.Map
;
public
interface
EvenListener
{
void
onEvent
(
String
eventName
,
Map
arguments
);
}
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/Message.java
deleted
100644 → 0
View file @
d284055d
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.messageing.base
;
import
java.util.Map
;
public
interface
Message
{
String
name
();
Map
arguments
();
}
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageDispatcher.java
deleted
100644 → 0
View file @
d284055d
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.messageing.base
;
public
interface
MessageDispatcher
<
T
>{
boolean
dispatch
(
Message
msg
,
MessageResult
<
T
>
result
);
void
addHandler
(
MessageHandler
<
T
>
handler
);
void
removeHandler
(
MessageHandler
<
T
>
handler
);
}
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageDispatcherImp.java
deleted
100644 → 0
View file @
d284055d
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.messageing.base
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
MessageDispatcherImp
implements
MessageDispatcher
{
private
Map
<
String
,
MessageHandler
>
handlers
=
new
HashMap
<>();
@Override
public
boolean
dispatch
(
Message
msg
,
MessageResult
result
)
{
if
(
msg
==
null
){
return
false
;
}
MessageHandler
h
=
handlers
.
get
(
msg
.
name
());
if
(
h
!=
null
){
return
h
.
onMethodCall
(
msg
.
name
(),
msg
.
arguments
(),
result
);
}
return
false
;
}
@Override
public
void
addHandler
(
MessageHandler
handler
)
{
if
(
handler
==
null
){
return
;
}
List
<
String
>
names
=
handler
.
handleMessageNames
();
for
(
String
name
:
names
){
handlers
.
put
(
name
,
handler
);
}
}
@Override
public
void
removeHandler
(
MessageHandler
handler
)
{
if
(
handler
==
null
){
return
;
}
List
<
String
>
names
=
handler
.
handleMessageNames
();
for
(
String
name
:
names
){
if
(
handler
==
handlers
.
get
(
name
)){
handlers
.
remove
(
name
);
}
}
}
}
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageHandler.java
deleted
100644 → 0
View file @
d284055d
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.messageing.base
;
import
java.util.List
;
import
java.util.Map
;
public
interface
MessageHandler
<
T
>
{
boolean
onMethodCall
(
String
name
,
Map
args
,
MessageResult
<
T
>
result
);
List
<
String
>
handleMessageNames
();
}
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageImp.java
deleted
100644 → 0
View file @
d284055d
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.messageing.base
;
import
java.util.Map
;
public
class
MessageImp
implements
Message
{
private
String
name
;
private
Map
args
;
public
MessageImp
(
String
name
,
Map
args
){
this
.
name
=
name
;
this
.
args
=
args
;
}
@Override
public
String
name
()
{
return
name
;
}
@Override
public
Map
arguments
()
{
return
args
;
}
}
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/base/MessageResult.java
deleted
100644 → 0
View file @
d284055d
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.messageing.base
;
public
interface
MessageResult
<
T
>
{
void
success
(
T
var1
);
void
error
(
String
var1
,
String
var2
,
Object
var3
);
void
notImplemented
();
}
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/ClosePageHandler.java
deleted
100755 → 0
View file @
d284055d
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.messageing.handlers
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
com.taobao.idlefish.flutterboost.FlutterViewContainerManager
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageHandler
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageResult
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
public
class
ClosePageHandler
implements
MessageHandler
<
Boolean
>
{
//==================Do not edit code blow!==============
@Override
public
boolean
onMethodCall
(
String
name
,
Map
args
,
MessageResult
<
Boolean
>
result
)
{
//TODO:接入新的close消息
String
uniqueId
=
(
String
)
args
.
get
(
"uniqueId"
);
Map
resultData
=
(
Map
)
args
.
get
(
"result"
);
Map
exts
=
(
Map
)
args
.
get
(
"exts"
);
FlutterBoostPlugin
.
containerManager
().
closeContainer
(
uniqueId
,
null
);
result
.
success
(
true
);
return
true
;
}
@Override
public
List
<
String
>
handleMessageNames
()
{
List
<
String
>
h
=
new
ArrayList
<>();
h
.
add
(
"closePage"
);
return
h
;
}
}
\ No newline at end of file
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/OnFlutterPageResultHandler.java
deleted
100755 → 0
View file @
d284055d
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.messageing.handlers
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageHandler
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageResult
;
import
com.taobao.idlefish.flutterboost.interfaces.IContainerManager
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
public
class
OnFlutterPageResultHandler
implements
MessageHandler
<
Boolean
>
{
private
boolean
onCall
(
MessageResult
<
Boolean
>
result
,
String
uniqueId
,
String
key
,
Map
resultData
,
Map
params
)
{
result
.
success
(
true
);
return
true
;
}
//==================Do not edit code blow!==============
@Override
public
boolean
onMethodCall
(
String
name
,
Map
args
,
MessageResult
<
Boolean
>
result
)
{
this
.
onCall
(
result
,
(
String
)
args
.
get
(
"uniqueId"
),
(
String
)
args
.
get
(
"key"
),
(
Map
)
args
.
get
(
"resultData"
),
(
Map
)
args
.
get
(
"params"
));
return
true
;
}
@Override
public
List
<
String
>
handleMessageNames
()
{
List
<
String
>
h
=
new
ArrayList
<>();
h
.
add
(
"onFlutterPageResult"
);
return
h
;
}
}
\ No newline at end of file
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/OnShownContainerChangedHandler.java
deleted
100755 → 0
View file @
d284055d
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.messageing.handlers
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageHandler
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageResult
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
public
class
OnShownContainerChangedHandler
implements
MessageHandler
<
Boolean
>
{
private
boolean
onCall
(
MessageResult
<
Boolean
>
result
,
String
now
,
String
old
,
Map
params
)
{
//Add your handler code here.
FlutterBoostPlugin
.
containerManager
().
onShownContainerChanged
(
old
,
now
);
return
true
;
}
//==================Do not edit code blow!==============
@Override
public
boolean
onMethodCall
(
String
name
,
Map
args
,
MessageResult
<
Boolean
>
result
)
{
this
.
onCall
(
result
,
(
String
)
args
.
get
(
"newName"
),
(
String
)
args
.
get
(
"oldName"
),
(
Map
)
args
.
get
(
"params"
));
return
true
;
}
@Override
public
List
<
String
>
handleMessageNames
()
{
List
<
String
>
h
=
new
ArrayList
<>();
h
.
add
(
"onShownContainerChanged"
);
return
h
;
}
}
\ No newline at end of file
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/OpenPageHandler.java
deleted
100755 → 0
View file @
d284055d
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.messageing.handlers
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageHandler
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageResult
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
OpenPageHandler
implements
MessageHandler
<
Map
>
{
@Override
public
boolean
onMethodCall
(
String
name
,
Map
args
,
MessageResult
<
Map
>
result
)
{
//TODO:接入新的open方法,同时兼容老方法
Map
params
=
(
Map
)
args
.
get
(
"urlParams"
);
Map
exts
=
(
Map
)
args
.
get
(
"exts"
);
String
url
=
(
String
)
args
.
get
(
"url"
);
int
requestCode
=
0
;
if
(
params
!=
null
&&
params
.
get
(
"requestCode"
)
!=
null
)
{
requestCode
=
(
int
)
params
.
get
(
"requestCode"
);
}
FlutterBoostPlugin
.
openPage
(
null
,
url
,
params
,
0
);
//TODO: to call future.
if
(
result
!=
null
)
{
result
.
success
(
new
HashMap
());
}
return
true
;
}
@Override
public
List
<
String
>
handleMessageNames
()
{
List
<
String
>
h
=
new
ArrayList
<>();
h
.
add
(
"openPage"
);
return
h
;
}
}
\ No newline at end of file
android/src/main/java/com/taobao/idlefish/flutterboost/messageing/handlers/PageOnStartHandler.java
deleted
100755 → 0
View file @
d284055d
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Alibaba Group
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
com.taobao.idlefish.flutterboost.messageing.handlers
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
com.taobao.idlefish.flutterboost.FlutterViewContainerManager
;
import
com.taobao.idlefish.flutterboost.interfaces.IContainerRecord
;
import
com.taobao.idlefish.flutterboost.interfaces.IFlutterViewContainer
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageHandler
;
import
com.taobao.idlefish.flutterboost.messageing.base.MessageResult
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
PageOnStartHandler
implements
MessageHandler
<
Map
>
{
private
boolean
onCall
(
MessageResult
<
Map
>
result
,
Map
params
)
{
Map
<
String
,
Object
>
pageInfo
=
new
HashMap
<>();
try
{
IContainerRecord
record
=
FlutterBoostPlugin
.
containerManager
().
getCurrentTopRecord
();
if
(
record
==
null
)
{
record
=
FlutterBoostPlugin
.
containerManager
().
getLastGenerateRecord
();
}
pageInfo
.
put
(
"name"
,
record
.
getContainer
().
getContainerName
());
pageInfo
.
put
(
"params"
,
record
.
getContainer
().
getContainerParams
());
pageInfo
.
put
(
"uniqueId"
,
record
.
uniqueId
());
result
.
success
(
pageInfo
);
}
catch
(
Throwable
t
)
{
result
.
success
(
pageInfo
);
}
return
true
;
}
@Override
public
boolean
onMethodCall
(
String
name
,
Map
args
,
MessageResult
<
Map
>
result
)
{
this
.
onCall
(
result
,
(
Map
)
args
.
get
(
"params"
));
return
true
;
}
@Override
public
List
<
String
>
handleMessageNames
()
{
List
<
String
>
h
=
new
ArrayList
<>();
h
.
add
(
"pageOnStart"
);
return
h
;
}
}
\ No newline at end of file
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/FlutterFragment.java
View file @
786e5617
...
@@ -29,12 +29,12 @@ public class FlutterFragment extends BoostFlutterFragment {
...
@@ -29,12 +29,12 @@ public class FlutterFragment extends BoostFlutterFragment {
}
}
@Override
@Override
public
String
getContainer
Name
()
{
public
String
getContainer
Url
()
{
return
"flutterFragment"
;
return
"flutterFragment"
;
}
}
@Override
@Override
public
Map
getContainerParams
()
{
public
Map
getContainer
Url
Params
()
{
Map
<
String
,
String
>
params
=
new
HashMap
<>();
Map
<
String
,
String
>
params
=
new
HashMap
<>();
params
.
put
(
"tag"
,
getArguments
().
getString
(
"tag"
));
params
.
put
(
"tag"
,
getArguments
().
getString
(
"tag"
));
return
params
;
return
params
;
...
...
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/FlutterPageActivity.java
View file @
786e5617
...
@@ -26,7 +26,7 @@ public class FlutterPageActivity extends BoostFlutterActivity {
...
@@ -26,7 +26,7 @@ public class FlutterPageActivity extends BoostFlutterActivity {
* @return
* @return
*/
*/
@Override
@Override
public
String
getContainer
Name
()
{
public
String
getContainer
Url
()
{
return
"flutterPage"
;
return
"flutterPage"
;
}
}
...
@@ -45,7 +45,7 @@ public class FlutterPageActivity extends BoostFlutterActivity {
...
@@ -45,7 +45,7 @@ public class FlutterPageActivity extends BoostFlutterActivity {
* @return
* @return
*/
*/
@Override
@Override
public
Map
getContainerParams
()
{
public
Map
getContainer
Url
Params
()
{
Map
<
String
,
String
>
params
=
new
HashMap
<>();
Map
<
String
,
String
>
params
=
new
HashMap
<>();
params
.
put
(
"aaa"
,
"bbb"
);
params
.
put
(
"aaa"
,
"bbb"
);
return
params
;
return
params
;
...
...
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
View file @
786e5617
...
@@ -3,13 +3,8 @@ package com.taobao.idlefish.flutterboostexample;
...
@@ -3,13 +3,8 @@ package com.taobao.idlefish.flutterboostexample;
import
android.app.Application
;
import
android.app.Application
;
import
android.content.Context
;
import
android.content.Context
;
import
com.taobao.idlefish.flutterboost.BoostFlutterEngine
;
import
com.taobao.idlefish.flutterboost.BoostFlutterView
;
import
com.taobao.idlefish.flutterboost.Debuger
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
com.taobao.idlefish.flutterboost.FlutterBoostPlugin
;
import
com.taobao.idlefish.flutterboost.StateListener
;
import
com.taobao.idlefish.flutterboost.Platform
;
import
com.taobao.idlefish.flutterboost.interfaces.IPlatform
;
import
com.taobao.idlefish.flutterboost.interfaces.IStateListener
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -22,44 +17,26 @@ public class MyApplication extends FlutterApplication {
...
@@ -22,44 +17,26 @@ public class MyApplication extends FlutterApplication {
public
void
onCreate
()
{
public
void
onCreate
()
{
super
.
onCreate
();
super
.
onCreate
();
FlutterBoostPlugin
.
init
(
new
IPlatform
()
{
FlutterBoostPlugin
.
init
(
new
Platform
()
{
@Override
@Override
public
Application
getApplication
()
{
public
Application
getApplication
()
{
return
MyApplication
.
this
;
return
MyApplication
.
this
;
}
}
@Override
public
void
onRegisterPlugins
(
PluginRegistry
registry
)
{
GeneratedPluginRegistrant
.
registerWith
(
registry
);
}
@Override
@Override
public
boolean
isDebug
()
{
public
boolean
isDebug
()
{
return
true
;
return
true
;
}
}
/**
* 如果flutter想打开一个本地页面,将会回调这个方法,页面参数将会拼接在url中
*
* 例如:sample://nativePage?aaa=bbb
*
* 参数就是类似 aaa=bbb 这样的键值对
*
* @param context
* @param url
* @param requestCode
* @return
*/
@Override
@Override
public
boolean
startActivity
(
Context
context
,
String
url
,
Map
params
,
int
requestCode
)
{
public
void
registerPlugins
(
PluginRegistry
registry
)
{
Debuger
.
log
(
"startActivity url="
+
url
);
GeneratedPluginRegistrant
.
registerWith
(
registry
);
return
PageRouter
.
openPageByUrl
(
context
,
url
,
params
,
requestCode
);
}
}
@Override
@Override
public
int
whenEngineStart
(
)
{
public
void
openContainer
(
Context
context
,
String
url
,
Map
<
String
,
Object
>
urlParams
,
int
requestCode
,
Map
<
String
,
Object
>
exts
)
{
return
IMMEDIATELY
;
PageRouter
.
openPageByUrl
(
context
,
url
,
urlParams
,
requestCode
)
;
}
}
});
});
}
}
...
...
lib/flutter_boost.dart
View file @
786e5617
...
@@ -60,7 +60,8 @@ class FlutterBoost {
...
@@ -60,7 +60,8 @@ class FlutterBoost {
GlobalKey
<
ContainerManagerState
>();
GlobalKey
<
ContainerManagerState
>();
final
ObserversHolder
_observersHolder
=
ObserversHolder
();
final
ObserversHolder
_observersHolder
=
ObserversHolder
();
final
Router
_router
=
Router
();
final
Router
_router
=
Router
();
final
MethodChannel
_methodChannel
=
MethodChannel
(
'flutter_boost'
);
final
MethodChannel
_methodChannel
=
MethodChannel
(
'flutter_boost_method'
);
final
EventChannel
_eventChannel
=
EventChannel
(
'flutter_boost_event'
);
final
MessageDispatcher
_dispatcher
=
MessageDispatcher
();
final
MessageDispatcher
_dispatcher
=
MessageDispatcher
();
int
_callbackID
=
0
;
int
_callbackID
=
0
;
...
...
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