提交 13044ca1 编写于 作者: A amirh 提交者: Adam Barth

Add a getter for flutterView in FlutterActivity. This allows fullscreen...

Add a getter for flutterView in FlutterActivity. This allows fullscreen flutter apps to extend FlutterActivity and do custom stuff with the flutter view. (#3324)
上级 ed5a1d2d
...@@ -21,7 +21,7 @@ import org.chromium.base.TraceEvent; ...@@ -21,7 +21,7 @@ import org.chromium.base.TraceEvent;
* Base class for activities that use Flutter. * Base class for activities that use Flutter.
*/ */
public class FlutterActivity extends Activity { public class FlutterActivity extends Activity {
private FlutterView mView; private FlutterView flutterView;
private String[] getArgsFromIntent(Intent intent) { private String[] getArgsFromIntent(Intent intent) {
// Before adding more entries to this list, consider that arbitrary // Before adding more entries to this list, consider that arbitrary
...@@ -60,8 +60,8 @@ public class FlutterActivity extends Activity { ...@@ -60,8 +60,8 @@ public class FlutterActivity extends Activity {
String[] args = getArgsFromIntent(getIntent()); String[] args = getArgsFromIntent(getIntent());
FlutterMain.ensureInitializationComplete(getApplicationContext(), args); FlutterMain.ensureInitializationComplete(getApplicationContext(), args);
mView = new FlutterView(this); flutterView = new FlutterView(this);
setContentView(mView); setContentView(flutterView);
onFlutterReady(); onFlutterReady();
} }
...@@ -71,16 +71,16 @@ public class FlutterActivity extends Activity { ...@@ -71,16 +71,16 @@ public class FlutterActivity extends Activity {
*/ */
@Override @Override
protected void onDestroy() { protected void onDestroy() {
if (mView != null) { if (flutterView != null) {
mView.destroy(); flutterView.destroy();
} }
super.onDestroy(); super.onDestroy();
} }
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (mView != null) { if (flutterView != null) {
mView.popRoute(); flutterView.popRoute();
return; return;
} }
super.onBackPressed(); super.onBackPressed();
...@@ -89,16 +89,16 @@ public class FlutterActivity extends Activity { ...@@ -89,16 +89,16 @@ public class FlutterActivity extends Activity {
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
if (mView != null) { if (flutterView != null) {
mView.onPause(); flutterView.onPause();
} }
} }
@Override @Override
protected void onPostResume() { protected void onPostResume() {
super.onPostResume(); super.onPostResume();
if (mView != null) { if (flutterView != null) {
mView.onPostResume(); flutterView.onPostResume();
} }
} }
...@@ -113,7 +113,7 @@ public class FlutterActivity extends Activity { ...@@ -113,7 +113,7 @@ public class FlutterActivity extends Activity {
} }
String appBundlePath = FlutterMain.findAppBundlePath(getApplicationContext()); String appBundlePath = FlutterMain.findAppBundlePath(getApplicationContext());
if (appBundlePath != null) { if (appBundlePath != null) {
mView.runFromBundle(appBundlePath, null); flutterView.runFromBundle(appBundlePath, null);
return; return;
} }
} }
...@@ -133,13 +133,21 @@ public class FlutterActivity extends Activity { ...@@ -133,13 +133,21 @@ public class FlutterActivity extends Activity {
appBundlePath = appBundlePath =
FlutterMain.findAppBundlePath(getApplicationContext()); FlutterMain.findAppBundlePath(getApplicationContext());
} }
mView.runFromBundle(appBundlePath, flutterView.runFromBundle(appBundlePath,
intent.getStringExtra("snapshot")); intent.getStringExtra("snapshot"));
if (route != null) if (route != null)
mView.pushRoute(route); flutterView.pushRoute(route);
return true; return true;
} }
return false; return false;
} }
/**
* Returns the Flutter view used by this activity, may be null before
* onCreate was called.
*/
public FlutterView getFlutterView() {
return flutterView;
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册