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
05a6dec5
Commit
05a6dec5
authored
Sep 17, 2019
by
justin
Committed by
GitHub
Sep 17, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #365 from Jaysonss/master
add platformview support to boost && add platform view example
parents
6afd80fb
feab757a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
22 deletions
+88
-22
android/src/main/java/com/idlefish/flutterboost/XFlutterView.java
...src/main/java/com/idlefish/flutterboost/XFlutterView.java
+7
-0
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
...om/taobao/idlefish/flutterboostexample/MyApplication.java
+12
-3
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/TextPlatformViewFactory.java
...idlefish/flutterboostexample/TextPlatformViewFactory.java
+41
-0
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/TextPlatformViewPlugin.java
.../idlefish/flutterboostexample/TextPlatformViewPlugin.java
+11
-0
example/lib/simple_page_widgets.dart
example/lib/simple_page_widgets.dart
+17
-19
No files found.
android/src/main/java/com/idlefish/flutterboost/XFlutterView.java
View file @
05a6dec5
...
@@ -445,6 +445,9 @@ public class XFlutterView extends FrameLayout {
...
@@ -445,6 +445,9 @@ public class XFlutterView extends FrameLayout {
this
.
flutterEngine
=
flutterEngine
;
this
.
flutterEngine
=
flutterEngine
;
// initialize PlatformViewsController
this
.
flutterEngine
.
getPluginRegistry
().
getPlatformViewsController
().
attach
(
getContext
(),
flutterEngine
.
getRenderer
(),
flutterEngine
.
getDartExecutor
());
// Instruct our FlutterRenderer that we are now its designated RenderSurface.
// Instruct our FlutterRenderer that we are now its designated RenderSurface.
this
.
flutterEngine
.
getRenderer
().
attachToRenderSurface
(
renderSurface
);
this
.
flutterEngine
.
getRenderer
().
attachToRenderSurface
(
renderSurface
);
...
@@ -524,6 +527,10 @@ public class XFlutterView extends FrameLayout {
...
@@ -524,6 +527,10 @@ public class XFlutterView extends FrameLayout {
}
}
Log
.
d
(
TAG
,
"Detaching from Flutter Engine"
);
Log
.
d
(
TAG
,
"Detaching from Flutter Engine"
);
// detach platformviews in page in case memory leak
flutterEngine
.
getPluginRegistry
().
getPlatformViewsController
().
detach
();
flutterEngine
.
getPluginRegistry
().
getPlatformViewsController
().
onFlutterViewDestroyed
();
// Inform the Android framework that it should retrieve a new InputConnection
// Inform the Android framework that it should retrieve a new InputConnection
// now that the engine is detached. The new InputConnection will be null, which
// now that the engine is detached. The new InputConnection will be null, which
// signifies that this View does not process input (until a new engine is attached).
// signifies that this View does not process input (until a new engine is attached).
...
...
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/MyApplication.java
View file @
05a6dec5
...
@@ -3,6 +3,7 @@ package com.taobao.idlefish.flutterboostexample;
...
@@ -3,6 +3,7 @@ package com.taobao.idlefish.flutterboostexample;
import
android.app.Application
;
import
android.app.Application
;
import
android.content.Context
;
import
android.content.Context
;
import
com.idlefish.flutterboost.BoostChannel
;
import
com.idlefish.flutterboost.BoostEngineProvider
;
import
com.idlefish.flutterboost.BoostEngineProvider
;
import
com.idlefish.flutterboost.BoostFlutterEngine
;
import
com.idlefish.flutterboost.BoostFlutterEngine
;
import
com.idlefish.flutterboost.FlutterBoost
;
import
com.idlefish.flutterboost.FlutterBoost
;
...
@@ -34,18 +35,18 @@ public class MyApplication extends FlutterApplication {
...
@@ -34,18 +35,18 @@ public class MyApplication extends FlutterApplication {
@Override
@Override
public
void
openContainer
(
Context
context
,
String
url
,
Map
<
String
,
Object
>
urlParams
,
int
requestCode
,
Map
<
String
,
Object
>
exts
)
{
public
void
openContainer
(
Context
context
,
String
url
,
Map
<
String
,
Object
>
urlParams
,
int
requestCode
,
Map
<
String
,
Object
>
exts
)
{
PageRouter
.
openPageByUrl
(
context
,
url
,
urlParams
,
requestCode
);
PageRouter
.
openPageByUrl
(
context
,
url
,
urlParams
,
requestCode
);
}
}
@Override
@Override
public
IFlutterEngineProvider
engineProvider
()
{
public
IFlutterEngineProvider
engineProvider
()
{
return
new
BoostEngineProvider
(){
return
new
BoostEngineProvider
()
{
@Override
@Override
public
BoostFlutterEngine
createEngine
(
Context
context
)
{
public
BoostFlutterEngine
createEngine
(
Context
context
)
{
return
new
BoostFlutterEngine
(
context
,
new
DartExecutor
.
DartEntrypoint
(
return
new
BoostFlutterEngine
(
context
,
new
DartExecutor
.
DartEntrypoint
(
context
.
getResources
().
getAssets
(),
context
.
getResources
().
getAssets
(),
FlutterMain
.
findAppBundlePath
(
context
),
FlutterMain
.
findAppBundlePath
(
context
),
"main"
),
"/"
);
"main"
),
"/"
);
}
}
};
};
}
}
...
@@ -55,5 +56,13 @@ public class MyApplication extends FlutterApplication {
...
@@ -55,5 +56,13 @@ public class MyApplication extends FlutterApplication {
return
ANY_ACTIVITY_CREATED
;
return
ANY_ACTIVITY_CREATED
;
}
}
});
});
BoostChannel
.
addActionAfterRegistered
(
new
BoostChannel
.
ActionAfterRegistered
()
{
@Override
public
void
onChannelRegistered
(
BoostChannel
channel
)
{
//platform view register should use FlutterPluginRegistry instread of BoostPluginRegistry
TextPlatformViewPlugin
.
register
(
FlutterBoost
.
singleton
().
engineProvider
().
tryGetEngine
().
getPluginRegistry
());
}
});
}
}
}
}
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/TextPlatformViewFactory.java
0 → 100644
View file @
05a6dec5
package
com.taobao.idlefish.flutterboostexample
;
import
android.content.Context
;
import
android.view.View
;
import
android.widget.TextView
;
import
io.flutter.plugin.common.MessageCodec
;
import
io.flutter.plugin.platform.PlatformView
;
import
io.flutter.plugin.platform.PlatformViewFactory
;
public
class
TextPlatformViewFactory
extends
PlatformViewFactory
{
public
TextPlatformViewFactory
(
MessageCodec
<
Object
>
createArgsCodec
)
{
super
(
createArgsCodec
);
}
@Override
public
PlatformView
create
(
Context
context
,
int
i
,
Object
o
)
{
return
new
TextPlatformView
(
context
);
}
private
static
class
TextPlatformView
implements
PlatformView
{
private
TextView
platformTv
;
public
TextPlatformView
(
Context
context
)
{
platformTv
=
new
TextView
(
context
);
platformTv
.
setText
(
"PlatformView Demo"
);
}
@Override
public
View
getView
()
{
return
platformTv
;
}
@Override
public
void
dispose
()
{
}
}
}
example/android/app/src/main/java/com/taobao/idlefish/flutterboostexample/TextPlatformViewPlugin.java
0 → 100644
View file @
05a6dec5
package
com.taobao.idlefish.flutterboostexample
;
import
io.flutter.app.FlutterPluginRegistry
;
import
io.flutter.plugin.common.StandardMessageCodec
;
public
class
TextPlatformViewPlugin
{
public
static
void
register
(
FlutterPluginRegistry
registry
)
{
registry
.
getPlatformViewsController
().
getRegistry
().
registerViewFactory
(
"plugins.test/view"
,
new
TextPlatformViewFactory
(
StandardMessageCodec
.
INSTANCE
));
}
}
example/lib/simple_page_widgets.dart
View file @
05a6dec5
...
@@ -12,13 +12,11 @@ class FirstRouteWidget extends StatelessWidget {
...
@@ -12,13 +12,11 @@ class FirstRouteWidget extends StatelessWidget {
child:
RaisedButton
(
child:
RaisedButton
(
child:
Text
(
'Open second route'
),
child:
Text
(
'Open second route'
),
onPressed:
()
{
onPressed:
()
{
print
(
"open second page!"
);
print
(
"open second page!"
);
FlutterBoost
.
singleton
.
open
(
"second"
).
then
((
Map
value
){
FlutterBoost
.
singleton
.
open
(
"second"
).
then
((
Map
value
)
{
print
(
"did recieve second route result"
);
print
(
"did recieve second route result"
);
print
(
"did recieve second route result
$value
"
);
print
(
"did recieve second route result
$value
"
);
});
});
},
},
),
),
),
),
...
@@ -37,9 +35,11 @@ class SecondRouteWidget extends StatelessWidget {
...
@@ -37,9 +35,11 @@ class SecondRouteWidget extends StatelessWidget {
child:
RaisedButton
(
child:
RaisedButton
(
onPressed:
()
{
onPressed:
()
{
// Navigate back to first route when tapped.
// Navigate back to first route when tapped.
BoostContainerSettings
settings
=
BoostContainer
.
of
(
context
).
settings
;
BoostContainerSettings
settings
=
FlutterBoost
.
singleton
.
close
(
settings
.
uniqueId
,
result:
{
"result"
:
"data from second"
});
BoostContainer
.
of
(
context
).
settings
;
FlutterBoost
.
singleton
.
close
(
settings
.
uniqueId
,
result:
{
"result"
:
"data from second"
});
},
},
child:
Text
(
'Go back with result!'
),
child:
Text
(
'Go back with result!'
),
),
),
...
@@ -103,7 +103,7 @@ class FlutterRouteWidget extends StatelessWidget {
...
@@ -103,7 +103,7 @@ class FlutterRouteWidget extends StatelessWidget {
///后面的参数会在native的IPlatform.startActivity方法回调中拼接到url的query部分。
///后面的参数会在native的IPlatform.startActivity方法回调中拼接到url的query部分。
///例如:sample://nativePage?aaa=bbb
///例如:sample://nativePage?aaa=bbb
onTap:
()
=>
onTap:
()
=>
FlutterBoost
.
singleton
.
open
(
"sample://nativePage"
,
urlParams:
{
FlutterBoost
.
singleton
.
open
(
"sample://nativePage"
,
urlParams:
{
"query"
:
{
"aaa"
:
"bbb"
}
"query"
:
{
"aaa"
:
"bbb"
}
}),
}),
),
),
...
@@ -120,7 +120,7 @@ class FlutterRouteWidget extends StatelessWidget {
...
@@ -120,7 +120,7 @@ class FlutterRouteWidget extends StatelessWidget {
///后面的参数会在native的IPlatform.startActivity方法回调中拼接到url的query部分。
///后面的参数会在native的IPlatform.startActivity方法回调中拼接到url的query部分。
///例如:sample://nativePage?aaa=bbb
///例如:sample://nativePage?aaa=bbb
onTap:
()
=>
onTap:
()
=>
FlutterBoost
.
singleton
.
open
(
"sample://flutterPage"
,
urlParams:
{
FlutterBoost
.
singleton
.
open
(
"sample://flutterPage"
,
urlParams:
{
"query"
:
{
"aaa"
:
"bbb"
}
"query"
:
{
"aaa"
:
"bbb"
}
}),
}),
),
),
...
@@ -141,15 +141,15 @@ class FlutterRouteWidget extends StatelessWidget {
...
@@ -141,15 +141,15 @@ class FlutterRouteWidget extends StatelessWidget {
InkWell
(
InkWell
(
child:
Container
(
child:
Container
(
padding:
const
EdgeInsets
.
all
(
8.0
),
padding:
const
EdgeInsets
.
all
(
8.0
),
margin:
const
EdgeInsets
.
fromLTRB
(
8.0
,
8.0
,
8.0
,
80
.0
),
margin:
const
EdgeInsets
.
all
(
8
.0
),
color:
Colors
.
yellow
,
color:
Colors
.
yellow
,
child:
Text
(
child:
Text
(
'open flutter fragment page'
,
'open flutter fragment page'
,
style:
TextStyle
(
fontSize:
22.0
,
color:
Colors
.
black
),
style:
TextStyle
(
fontSize:
22.0
,
color:
Colors
.
black
),
)),
)),
onTap:
()
=>
FlutterBoost
.
singleton
onTap:
()
=>
.
open
(
"sample://flutterFragmentPage"
),
FlutterBoost
.
singleton
.
open
(
"sample://flutterFragmentPage"
),
)
)
,
],
],
),
),
);
);
...
@@ -196,8 +196,7 @@ class FragmentRouteWidget extends StatelessWidget {
...
@@ -196,8 +196,7 @@ class FragmentRouteWidget extends StatelessWidget {
'open native page'
,
'open native page'
,
style:
TextStyle
(
fontSize:
22.0
,
color:
Colors
.
black
),
style:
TextStyle
(
fontSize:
22.0
,
color:
Colors
.
black
),
)),
)),
onTap:
()
=>
onTap:
()
=>
FlutterBoost
.
singleton
.
open
(
"sample://nativePage"
),
FlutterBoost
.
singleton
.
open
(
"sample://nativePage"
),
),
),
InkWell
(
InkWell
(
child:
Container
(
child:
Container
(
...
@@ -208,8 +207,7 @@ class FragmentRouteWidget extends StatelessWidget {
...
@@ -208,8 +207,7 @@ class FragmentRouteWidget extends StatelessWidget {
'open flutter page'
,
'open flutter page'
,
style:
TextStyle
(
fontSize:
22.0
,
color:
Colors
.
black
),
style:
TextStyle
(
fontSize:
22.0
,
color:
Colors
.
black
),
)),
)),
onTap:
()
=>
onTap:
()
=>
FlutterBoost
.
singleton
.
open
(
"sample://flutterPage"
),
FlutterBoost
.
singleton
.
open
(
"sample://flutterPage"
),
),
),
InkWell
(
InkWell
(
child:
Container
(
child:
Container
(
...
@@ -220,8 +218,8 @@ class FragmentRouteWidget extends StatelessWidget {
...
@@ -220,8 +218,8 @@ class FragmentRouteWidget extends StatelessWidget {
'open flutter fragment page'
,
'open flutter fragment page'
,
style:
TextStyle
(
fontSize:
22.0
,
color:
Colors
.
black
),
style:
TextStyle
(
fontSize:
22.0
,
color:
Colors
.
black
),
)),
)),
onTap:
()
=>
FlutterBoost
.
singleton
onTap:
()
=>
.
open
(
"sample://flutterFragmentPage"
),
FlutterBoost
.
singleton
.
open
(
"sample://flutterFragmentPage"
),
)
)
],
],
),
),
...
@@ -268,6 +266,6 @@ class _PushWidgetState extends State<PushWidget> {
...
@@ -268,6 +266,6 @@ class _PushWidgetState extends State<PushWidget> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
FlutterRouteWidget
(
message:
"Pushed Widget"
);
return
FlutterRouteWidget
(
message:
"Pushed Widget"
);
}
}
}
}
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