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
91880134
Commit
91880134
authored
Jul 02, 2019
by
Yacumima
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dev
parent
3ef2bfe4
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
71 additions
and
76 deletions
+71
-76
android/src/main/java/com/idlefish/flutterboost/ContainerRecord.java
.../main/java/com/idlefish/flutterboost/ContainerRecord.java
+15
-3
android/src/main/java/com/idlefish/flutterboost/FlutterBoost.java
...src/main/java/com/idlefish/flutterboost/FlutterBoost.java
+3
-3
android/src/main/java/com/idlefish/flutterboost/FlutterViewContainerManager.java
...om/idlefish/flutterboost/FlutterViewContainerManager.java
+34
-13
android/src/main/java/com/idlefish/flutterboost/containers/BoostFlutterActivity.java
...dlefish/flutterboost/containers/BoostFlutterActivity.java
+5
-5
android/src/main/java/com/idlefish/flutterboost/interfaces/IContainerManager.java
...m/idlefish/flutterboost/interfaces/IContainerManager.java
+0
-12
android/src/main/java/com/idlefish/flutterboost/interfaces/IContainerRecord.java
...om/idlefish/flutterboost/interfaces/IContainerRecord.java
+3
-0
android/src/main/java/com/idlefish/flutterboost/interfaces/IOperateSyncer.java
.../com/idlefish/flutterboost/interfaces/IOperateSyncer.java
+1
-1
lib/container/boost_container.dart
lib/container/boost_container.dart
+8
-37
lib/flutter_boost.dart
lib/flutter_boost.dart
+2
-2
No files found.
android/src/main/java/com/idlefish/flutterboost/ContainerRecord.java
View file @
91880134
...
...
@@ -40,7 +40,13 @@ public class ContainerRecord implements IContainerRecord {
private
MethodChannelProxy
mProxy
=
new
MethodChannelProxy
();
ContainerRecord
(
FlutterViewContainerManager
manager
,
IFlutterViewContainer
container
)
{
mUniqueId
=
System
.
currentTimeMillis
()
+
"-"
+
hashCode
();
final
Map
params
=
container
.
getContainerUrlParams
();
if
(
params
!=
null
&&
params
.
containsKey
(
IContainerRecord
.
UNIQ_KEY
))
{
mUniqueId
=
String
.
valueOf
(
params
.
get
(
IContainerRecord
.
UNIQ_KEY
));
}
else
{
mUniqueId
=
genUniqueId
(
this
);
}
mManager
=
manager
;
mContainer
=
container
;
}
...
...
@@ -124,6 +130,8 @@ public class ContainerRecord implements IContainerRecord {
mManager
.
removeRecord
(
this
);
mManager
.
setContainerResult
(
this
,-
1
,-
1
,
null
);
if
(!
mManager
.
hasContainerAppear
())
{
mContainer
.
getBoostFlutterView
().
onPause
();
mContainer
.
getBoostFlutterView
().
onStop
();
...
...
@@ -164,8 +172,8 @@ public class ContainerRecord implements IContainerRecord {
}
@Override
public
void
onContainerResult
(
int
requestCode
,
Map
<
String
,
Object
>
result
)
{
mManager
.
setContainerResult
(
this
,
requestCode
,
result
);
public
void
onContainerResult
(
int
requestCode
,
int
resultCode
,
Map
<
String
,
Object
>
result
)
{
mManager
.
setContainerResult
(
this
,
requestCode
,
resultCode
,
result
);
}
@Override
...
...
@@ -252,4 +260,8 @@ public class ContainerRecord implements IContainerRecord {
FlutterBoost
.
singleton
().
channel
().
invokeMethodUnsafe
(
method
,
args
);
}
}
public
static
String
genUniqueId
(
Object
obj
)
{
return
System
.
currentTimeMillis
()
+
"-"
+
obj
.
hashCode
();
}
}
android/src/main/java/com/idlefish/flutterboost/FlutterBoost.java
View file @
91880134
...
...
@@ -67,7 +67,7 @@ public class FlutterBoost {
}
private
final
IPlatform
mPlatform
;
private
final
I
ContainerManager
mManager
;
private
final
FlutterView
ContainerManager
mManager
;
private
final
IFlutterEngineProvider
mEngineProvider
;
IStateListener
mStateListener
;
...
...
@@ -223,7 +223,7 @@ public class FlutterBoost {
Map
<
String
,
Object
>
exts
=
methodCall
.
argument
(
"exts"
);
String
url
=
methodCall
.
argument
(
"url"
);
mManager
.
openContainer
(
url
,
params
,
exts
,
new
I
ContainerManager
.
OnResult
()
{
mManager
.
openContainer
(
url
,
params
,
exts
,
new
FlutterView
ContainerManager
.
OnResult
()
{
@Override
public
void
onResult
(
Map
<
String
,
Object
>
rlt
)
{
if
(
result
!=
null
)
{
...
...
@@ -232,7 +232,7 @@ public class FlutterBoost {
}
});
}
catch
(
Throwable
t
){
result
.
error
(
"open page error"
,
t
.
getMessage
(),
t
);
}
}
break
;
...
...
android/src/main/java/com/idlefish/flutterboost/FlutterViewContainerManager.java
View file @
91880134
...
...
@@ -35,6 +35,7 @@ import com.idlefish.flutterboost.interfaces.IOperateSyncer;
import
java.lang.ref.WeakReference
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
...
...
@@ -48,8 +49,7 @@ public class FlutterViewContainerManager implements IContainerManager {
private
final
Set
<
ContainerRef
>
mRefs
=
new
HashSet
<>();
private
final
Stack
<
IContainerRecord
>
mRecordStack
=
new
Stack
<>();
private
final
AtomicInteger
mRequestCode
=
new
AtomicInteger
(
0
);
private
final
SparseArray
<
OnResult
>
mOnResults
=
new
SparseArray
<>();
private
final
Map
<
String
,
OnResult
>
mOnResults
=
new
HashMap
<>();
FlutterViewContainerManager
()
{}
...
...
@@ -86,37 +86,55 @@ public class FlutterViewContainerManager implements IContainerManager {
mRecordMap
.
remove
(
record
.
getContainer
());
}
void
setContainerResult
(
IContainerRecord
record
,
int
requestCode
,
Map
<
String
,
Object
>
result
)
{
void
setContainerResult
(
IContainerRecord
record
,
int
requestCode
,
int
resultCode
,
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
(
result
==
null
)
{
result
=
new
HashMap
<>();
}
result
.
put
(
"_requestCode__"
,
requestCode
);
result
.
put
(
"_resultCode__"
,
resultCode
);
final
OnResult
onResult
=
mOnResults
.
remove
(
record
.
uniqueId
());
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
)
{
public
IContainerRecord
recordOf
(
IFlutterViewContainer
container
)
{
return
mRecordMap
.
get
(
container
);
}
void
openContainer
(
String
url
,
Map
<
String
,
Object
>
urlParams
,
Map
<
String
,
Object
>
exts
,
OnResult
onResult
)
{
Context
context
=
FlutterBoost
.
singleton
().
currentActivity
();
if
(
context
==
null
)
{
context
=
FlutterBoost
.
singleton
().
platform
().
getApplication
();
}
int
requestCode
=
mRequestCode
.
addAndGet
(
3
);
if
(
urlParams
==
null
)
{
urlParams
=
new
HashMap
<>();
}
int
requestCode
=
0
;
if
(
urlParams
.
containsKey
(
"requestCode"
))
{
requestCode
=
Integer
.
valueOf
((
String
)
urlParams
.
remove
(
"requestCode"
));
}
final
String
uniqueId
=
ContainerRecord
.
genUniqueId
(
url
);
urlParams
.
put
(
IContainerRecord
.
UNIQ_KEY
,
uniqueId
);
if
(
onResult
!=
null
)
{
mOnResults
.
put
(
requestCode
,
onResult
);
mOnResults
.
put
(
uniqueId
,
onResult
);
}
FlutterBoost
.
singleton
().
platform
().
openContainer
(
context
,
url
,
urlParams
,
requestCode
,
exts
);
}
@Override
public
IContainerRecord
closeContainer
(
String
uniqueId
,
Map
<
String
,
Object
>
result
,
Map
<
String
,
Object
>
exts
)
{
IContainerRecord
closeContainer
(
String
uniqueId
,
Map
<
String
,
Object
>
result
,
Map
<
String
,
Object
>
exts
)
{
IContainerRecord
targetRecord
=
null
;
for
(
Map
.
Entry
<
IFlutterViewContainer
,
IContainerRecord
>
entry
:
mRecordMap
.
entrySet
())
{
if
(
TextUtils
.
equals
(
uniqueId
,
entry
.
getValue
().
uniqueId
()))
{
...
...
@@ -170,8 +188,7 @@ public class FlutterViewContainerManager implements IContainerManager {
return
target
;
}
@Override
public
void
onShownContainerChanged
(
String
old
,
String
now
)
{
void
onShownContainerChanged
(
String
old
,
String
now
)
{
Utils
.
assertCallOnMainThread
();
IFlutterViewContainer
oldContainer
=
null
;
...
...
@@ -220,4 +237,8 @@ public class FlutterViewContainerManager implements IContainerManager {
this
.
container
=
new
WeakReference
<>(
container
);
}
}
interface
OnResult
{
void
onResult
(
Map
<
String
,
Object
>
result
);
}
}
android/src/main/java/com/idlefish/flutterboost/containers/BoostFlutterActivity.java
View file @
91880134
...
...
@@ -191,7 +191,7 @@ public abstract class BoostFlutterActivity extends Activity implements IFlutterV
}
}
mSyncer
.
onContainerResult
(
requestCode
,
result
);
mSyncer
.
onContainerResult
(
requestCode
,
result
Code
,
result
);
}
@Override
...
...
@@ -230,11 +230,11 @@ public abstract class BoostFlutterActivity extends Activity implements IFlutterV
@Override
public
void
finishContainer
(
Map
<
String
,
Object
>
result
)
{
Intent
intent
=
new
Intent
();
if
(
result
!=
null
)
{
intent
.
putExtra
(
RESULT_KEY
,
new
HashMap
<>(
result
));
if
(
result
!=
null
)
{
FlutterBoost
.
setBoostResult
(
this
,
new
HashMap
<>(
result
));
}
else
{
finish
();
}
setResult
(
Activity
.
RESULT_OK
,
intent
);
}
@Override
...
...
android/src/main/java/com/idlefish/flutterboost/interfaces/IContainerManager.java
View file @
91880134
...
...
@@ -23,27 +23,15 @@
*/
package
com.idlefish.flutterboost.interfaces
;
import
java.util.Map
;
public
interface
IContainerManager
{
IOperateSyncer
generateSyncer
(
IFlutterViewContainer
container
);
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
getLastGenerateRecord
();
IFlutterViewContainer
findContainerById
(
String
uniqueId
);
void
onShownContainerChanged
(
String
oldUniqueId
,
String
nowUniqueId
);
boolean
hasContainerAppear
();
interface
OnResult
{
void
onResult
(
Map
<
String
,
Object
>
result
);
}
}
\ No newline at end of file
android/src/main/java/com/idlefish/flutterboost/interfaces/IContainerRecord.java
View file @
91880134
...
...
@@ -27,6 +27,9 @@ package com.idlefish.flutterboost.interfaces;
* a container record, which use map a flutter page
*/
public
interface
IContainerRecord
extends
IOperateSyncer
{
String
UNIQ_KEY
=
"__container_uniqueId_key__"
;
int
STATE_UNKNOW
=
0
;
int
STATE_CREATED
=
1
;
int
STATE_APPEAR
=
2
;
...
...
android/src/main/java/com/idlefish/flutterboost/interfaces/IOperateSyncer.java
View file @
91880134
...
...
@@ -22,7 +22,7 @@ public interface IOperateSyncer {
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
);
void
onContainerResult
(
int
requestCode
,
Map
<
String
,
Object
>
result
);
void
onContainerResult
(
int
requestCode
,
int
resultCode
,
Map
<
String
,
Object
>
result
);
void
onUserLeaveHint
();
...
...
lib/container/boost_container.dart
View file @
91880134
...
...
@@ -39,9 +39,6 @@ enum ContainerLifeCycle {
typedef
void
BoostContainerLifeCycleObserver
(
ContainerLifeCycle
state
,
BoostContainerSettings
settings
);
typedef
void
ResultObserver
(
int
requestCode
,
int
responseCode
,
Map
<
dynamic
,
dynamic
>
result
);
class
BoostContainer
extends
Navigator
{
final
BoostContainerSettings
settings
;
...
...
@@ -116,9 +113,7 @@ class BoostContainer extends Navigator {
}
class
BoostContainerState
extends
NavigatorState
{
final
Set
<
VoidCallback
>
_backPressedListeners
=
Set
<
VoidCallback
>();
final
Set
<
ResultObserver
>
_resultObservers
=
Set
<
ResultObserver
>();
VoidCallback
backPressedHandler
;
String
get
uniqueId
=>
widget
.
settings
.
uniqueId
;
...
...
@@ -148,6 +143,12 @@ class BoostContainerState extends NavigatorState {
return
null
;
}
@override
void
initState
()
{
super
.
initState
();
backPressedHandler
=
()=>
pop
();
}
@override
void
didUpdateWidget
(
Navigator
oldWidget
)
{
super
.
didUpdateWidget
(
oldWidget
);
...
...
@@ -165,25 +166,7 @@ class BoostContainerState extends NavigatorState {
void
performBackPressed
()
{
Logger
.
log
(
'performBackPressed'
);
if
(
_backPressedListeners
.
isEmpty
)
{
pop
();
}
else
{
for
(
VoidCallback
cb
in
_backPressedListeners
)
{
cb
();
}
}
}
void
performOnResult
(
Map
<
dynamic
,
dynamic
>
data
)
{
Logger
.
log
(
'performOnResult
${data.toString()}
'
);
final
int
requestCode
=
data
[
'requestCode'
];
final
int
responseCode
=
data
[
'responseCode'
];
final
Map
result
=
data
[
'result'
];
for
(
ResultObserver
observer
in
_resultObservers
)
{
observer
(
requestCode
,
responseCode
,
result
);
}
backPressedHandler
?.
call
();
}
@override
...
...
@@ -219,18 +202,6 @@ class BoostContainerState extends NavigatorState {
return
future
;
}
VoidCallback
addBackPressedListener
(
VoidCallback
listener
)
{
_backPressedListeners
.
add
(
listener
);
return
()
=>
_backPressedListeners
.
remove
(
listener
);
}
VoidCallback
addResultObserver
(
ResultObserver
observer
)
{
_resultObservers
.
add
(
observer
);
return
()
=>
_resultObservers
.
remove
(
observer
);
}
VoidCallback
addLifeCycleObserver
(
BoostContainerLifeCycleObserver
observer
)
{
return
FlutterBoost
.
singleton
.
addBoostContainerLifeCycleObserver
(
(
ContainerLifeCycle
state
,
BoostContainerSettings
settings
)
{
...
...
lib/flutter_boost.dart
View file @
91880134
...
...
@@ -37,10 +37,10 @@ export 'container/container_manager.dart';
typedef
Widget
PageBuilder
(
String
pageName
,
Map
params
,
String
uniqueId
);
typedef
Route
PrePushRoute
(
String
pageName
,
String
uniqueId
,
Map
params
,
Route
route
);
String
url
,
String
uniqueId
,
Map
params
,
Route
route
);
typedef
void
PostPushRoute
(
String
pageName
,
String
uniqueId
,
Map
params
,
Route
route
,
Future
result
);
String
url
,
String
uniqueId
,
Map
params
,
Route
route
,
Future
result
);
class
FlutterBoost
{
...
...
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