Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
2360b459
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
2360b459
编写于
2月 27, 2019
作者:
M
Matt Carroll
提交者:
GitHub
2月 27, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Android Embedding PR 11: Add FlutterEngine to FlutterFragment. (#7972)
上级
df03ec74
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
58 addition
and
0 deletion
+58
-0
shell/platform/android/io/flutter/embedding/engine/android/FlutterFragment.java
.../io/flutter/embedding/engine/android/FlutterFragment.java
+58
-0
未找到文件。
shell/platform/android/io/flutter/embedding/engine/android/FlutterFragment.java
浏览文件 @
2360b459
...
...
@@ -4,12 +4,17 @@
package
io.flutter.embedding.engine.android
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
android.support.v4.app.Fragment
;
import
android.util.Log
;
import
io.flutter.embedding.engine.FlutterEngine
;
import
io.flutter.embedding.engine.FlutterShellArgs
;
import
io.flutter.view.FlutterMain
;
/**
* {@code Fragment} which displays a Flutter UI that takes up all available {@code Fragment} space.
...
...
@@ -144,9 +149,62 @@ public class FlutterFragment extends Fragment {
return
args
;
}
@Nullable
private
FlutterEngine
flutterEngine
;
public
FlutterFragment
()
{
// Ensure that we at least have an empty Bundle of arguments so that we don't
// need to continually check for null arguments before grabbing one.
setArguments
(
new
Bundle
());
}
@Override
public
void
onAttach
(
Context
context
)
{
super
.
onAttach
(
context
);
// When "retain instance" is true, the FlutterEngine will survive configuration
// changes. Therefore, we create a new one only if one does not already exist.
if
(
flutterEngine
==
null
)
{
createFlutterEngine
();
}
}
/**
* Creates a new FlutterEngine instance.
*
* Subclasses can instantiate their own {@link FlutterEngine} by overriding
* {@link #onCreateFlutterEngine(Context)}.
*
* Subclasses can alter the {@link FlutterEngine} after creation by overriding
* {@link #onFlutterEngineCreated(FlutterEngine)}.
*/
private
void
createFlutterEngine
()
{
// Create a FlutterEngine to back our FlutterView.
flutterEngine
=
onCreateFlutterEngine
(
getActivity
());
// Allow subclasses to customize FlutterEngine as desired.
onFlutterEngineCreated
(
flutterEngine
);
}
/**
* Hook for subclasses to customize the creation of the {@code FlutterEngine}.
*
* By default, this method returns a standard {@link FlutterEngine} without any modification.
*/
@NonNull
protected
FlutterEngine
onCreateFlutterEngine
(
@NonNull
Context
context
)
{
Log
.
d
(
TAG
,
"onCreateFlutterEngine()"
);
return
new
FlutterEngine
(
context
);
}
/**
* Hook for subclasses to customize the {@link FlutterEngine} owned by this {@link FlutterFragment}
* after the {@link FlutterEngine} has been instantiated.
*
* Consider using this method to connect desired Flutter plugins to this {@code Fragment}'s
* {@link FlutterEngine}.
*/
protected
void
onFlutterEngineCreated
(
@NonNull
FlutterEngine
flutterEngine
)
{
// no-op
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录