Refactor shared code into separate function to simplify further work. (flutter/engine#7410)

This should be a no-op change that behaves identical to as before.
This commit is contained in:
Stanislav Baranov
2019-01-08 12:44:07 -08:00
committed by GitHub
parent 9ff2d2b937
commit 089ea4bf10

View File

@@ -167,19 +167,9 @@ public final class FlutterActivityDelegate
return;
}
if (!flutterView.getFlutterNativeView().isApplicationRunning()) {
String appBundlePath = FlutterMain.findAppBundlePath(activity.getApplicationContext());
if (appBundlePath != null) {
FlutterRunArguments arguments = new FlutterRunArguments();
ArrayList<String> bundlePaths = new ArrayList<>();
if (FlutterMain.getUpdateInstallationPath() != null) {
bundlePaths.add(FlutterMain.getUpdateInstallationPath());
}
bundlePaths.add(appBundlePath);
arguments.bundlePaths = bundlePaths.toArray(new String[0]);
arguments.entrypoint = "main";
flutterView.runFromBundle(arguments);
}
String appBundlePath = FlutterMain.findAppBundlePath(activity.getApplicationContext());
if (appBundlePath != null) {
runBundle(appBundlePath);
}
}
@@ -335,30 +325,34 @@ public final class FlutterActivityDelegate
String route = intent.getStringExtra("route");
String appBundlePath = intent.getDataString();
if (appBundlePath == null) {
// Fall back to the installation path if no bundle path
// was specified.
// Fall back to the installation path if no bundle path was specified.
appBundlePath = FlutterMain.findAppBundlePath(activity.getApplicationContext());
}
if (route != null) {
flutterView.setInitialRoute(route);
}
if (!flutterView.getFlutterNativeView().isApplicationRunning()) {
FlutterRunArguments args = new FlutterRunArguments();
ArrayList<String> bundlePaths = new ArrayList<>();
if (FlutterMain.getUpdateInstallationPath() != null) {
bundlePaths.add(FlutterMain.getUpdateInstallationPath());
}
bundlePaths.add(appBundlePath);
args.bundlePaths = bundlePaths.toArray(new String[0]);
args.entrypoint = "main";
flutterView.runFromBundle(args);
}
runBundle(appBundlePath);
return true;
}
return false;
}
private void runBundle(String appBundlePath) {
if (!flutterView.getFlutterNativeView().isApplicationRunning()) {
FlutterRunArguments args = new FlutterRunArguments();
ArrayList<String> bundlePaths = new ArrayList<>();
if (FlutterMain.getUpdateInstallationPath() != null) {
bundlePaths.add(FlutterMain.getUpdateInstallationPath());
}
bundlePaths.add(appBundlePath);
args.bundlePaths = bundlePaths.toArray(new String[0]);
args.entrypoint = "main";
flutterView.runFromBundle(args);
}
}
/**
* Creates a {@link View} containing the same {@link Drawable} as the one set as the
* {@code windowBackground} of the parent activity for use as a launch splash view.