io.flutter.view.FlutterView Java Examples
The following examples show how to use
io.flutter.view.FlutterView.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XFlutterActivityDelegate.java From hybrid_stack_manager with MIT License | 5 votes |
/** * Show and then automatically animate out the launch view. * * If a launch screen is defined in the user application's AndroidManifest.xml as the * activity's {@code windowBackground}, display it on top of the {@link FlutterView} and * remove the activity's {@code windowBackground}. * * Fade it out and remove it when the {@link FlutterView} renders its first frame. */ private void addLaunchView() { if (launchView == null) { return; } activity.addContentView(launchView, matchParent); flutterView.addFirstFrameListener(new FlutterView.FirstFrameListener() { @Override public void onFirstFrame() { XFlutterActivityDelegate.this.launchView.animate() .alpha(0f) // Use Android's default animation duration. .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // Views added to an Activity's addContentView is always added to its // root FrameLayout. ((ViewGroup) XFlutterActivityDelegate.this.launchView.getParent()) .removeView(XFlutterActivityDelegate.this.launchView); XFlutterActivityDelegate.this.launchView = null; } }); XFlutterActivityDelegate.this.flutterView.removeFirstFrameListener(this); } }); // Resets the activity theme from the one containing the launch screen in the window // background to a blank one since the launch screen is now in a view in front of the // FlutterView. // // We can make this configurable if users want it. activity.setTheme(android.R.style.Theme_Black_NoTitleBar); }
Example #2
Source File: XFlutterActivityDelegate.java From hybrid_stack_manager with MIT License | 5 votes |
/** * Show and then automatically animate out the launch view. * * If a launch screen is defined in the user application's AndroidManifest.xml as the * activity's {@code windowBackground}, display it on top of the {@link FlutterView} and * remove the activity's {@code windowBackground}. * * Fade it out and remove it when the {@link FlutterView} renders its first frame. */ private void addLaunchView() { if (launchView == null) { return; } activity.addContentView(launchView, matchParent); flutterView.addFirstFrameListener(new FlutterView.FirstFrameListener() { @Override public void onFirstFrame() { XFlutterActivityDelegate.this.launchView.animate() .alpha(0f) // Use Android's default animation duration. .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // Views added to an Activity's addContentView is always added to its // root FrameLayout. ((ViewGroup) XFlutterActivityDelegate.this.launchView.getParent()) .removeView(XFlutterActivityDelegate.this.launchView); XFlutterActivityDelegate.this.launchView = null; } }); XFlutterActivityDelegate.this.flutterView.removeFirstFrameListener(this); } }); // Resets the activity theme from the one containing the launch screen in the window // background to a blank one since the launch screen is now in a view in front of the // FlutterView. // // We can make this configurable if users want it. activity.setTheme(android.R.style.Theme_Black_NoTitleBar); }
Example #3
Source File: Flutter.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
/** * Creates a {@link FlutterView} linked to the specified {@link Activity} and {@link Lifecycle}. * The optional initial route string will be made available to the Dart code (via * {@code window.defaultRouteName}) and may be used to determine which widget should be displayed * in the view. The default initialRoute is "/". * * @param activity an {@link Activity} * @param lifecycle a {@link Lifecycle} * @param initialRoute an initial route {@link String}, or null * @return a {@link FlutterView} */ @NonNull public static FlutterView createView(@NonNull final Activity activity, @NonNull final Lifecycle lifecycle, final String initialRoute) { FlutterMain.startInitialization(activity.getApplicationContext()); FlutterMain.ensureInitializationComplete(activity.getApplicationContext(), null); final FlutterNativeView nativeView = new FlutterNativeView(activity); final FlutterView flutterView = new FlutterView(activity, null, nativeView) { private final BasicMessageChannel<String> lifecycleMessages = new BasicMessageChannel<>(this, "flutter/lifecycle", StringCodec.INSTANCE); @Override public void onFirstFrame() { super.onFirstFrame(); setAlpha(1.0f); } @Override public void onPostResume() { // Overriding default behavior to avoid dictating system UI via PlatformPlugin. lifecycleMessages.send("AppLifecycleState.resumed"); } }; if (initialRoute != null) { flutterView.setInitialRoute(initialRoute); } lifecycle.addObserver(new LifecycleObserver() { @OnLifecycleEvent(Lifecycle.Event.ON_CREATE) public void onCreate() { final FlutterRunArguments arguments = new FlutterRunArguments(); arguments.bundlePath = FlutterMain.findAppBundlePath(activity.getApplicationContext()); arguments.entrypoint = "main"; flutterView.runFromBundle(arguments); GeneratedPluginRegistrant.registerWith(flutterView.getPluginRegistry()); } @OnLifecycleEvent(Lifecycle.Event.ON_START) public void onStart() { flutterView.onStart(); } @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) public void onResume() { flutterView.onPostResume(); } @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE) public void onPause() { flutterView.onPause(); } @OnLifecycleEvent(Lifecycle.Event.ON_STOP) public void onStop() { flutterView.onStop(); } @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void onDestroy() { flutterView.destroy(); } }); flutterView.setAlpha(0.0f); return flutterView; }
Example #4
Source File: XFlutterActivityDelegate.java From hybrid_stack_manager with MIT License | 4 votes |
@Override public FlutterView getFlutterView() { return flutterView; }
Example #5
Source File: XFlutterActivityDelegate.java From hybrid_stack_manager with MIT License | 4 votes |
@Override public FlutterView getFlutterView() { return flutterView; }
Example #6
Source File: FastQrReaderViewPlugin.java From fast_qr_reader_view with MIT License | 4 votes |
private FastQrReaderViewPlugin(Registrar registrar, FlutterView view, Activity activity) { this.registrar = registrar; this.view = view; this.activity = activity; registrar.addRequestPermissionsResultListener(new CameraRequestPermissionsListener()); this.activityLifecycleCallbacks = new Application.ActivityLifecycleCallbacks() { @Override public void onActivityCreated(Activity activity, Bundle savedInstanceState) { } @Override public void onActivityStarted(Activity activity) { } @Override public void onActivityResumed(Activity activity) { if (requestingPermission) { requestingPermission = false; return; } if (activity == FastQrReaderViewPlugin.this.activity) { if (camera != null) { camera.startCameraSource(); } } } @Override public void onActivityPaused(Activity activity) { if (activity == FastQrReaderViewPlugin.this.activity) { if (camera != null) { if (camera.preview != null) { camera.preview.stop(); } } } } @Override public void onActivityStopped(Activity activity) { if (activity == FastQrReaderViewPlugin.this.activity) { if (camera != null) { if (camera.preview != null) { camera.preview.stop(); } if (camera.cameraSource != null) { camera.cameraSource.release(); } } } } @Override public void onActivitySaveInstanceState(Activity activity, Bundle outState) { } @Override public void onActivityDestroyed(Activity activity) { } }; }
Example #7
Source File: Flutter.java From CrazyDaily with Apache License 2.0 | 4 votes |
/** * Creates a {@link FlutterView} linked to the specified {@link Activity} and {@link Lifecycle}. * The optional initial route string will be made available to the Dart code (via * {@code window.defaultRouteName}) and may be used to determine which widget should be displayed * in the view. The default initialRoute is "/". * * @param activity an {@link Activity} * @param lifecycle a {@link Lifecycle} * @param initialRoute an initial route {@link String}, or null * @return a {@link FlutterView} */ @NonNull public static FlutterView createView(@NonNull final Activity activity, @NonNull final Lifecycle lifecycle, final String initialRoute) { FlutterMain.startInitialization(activity.getApplicationContext()); FlutterMain.ensureInitializationComplete(activity.getApplicationContext(), null); final FlutterNativeView nativeView = new FlutterNativeView(activity); final FlutterView flutterView = new FlutterView(activity, null, nativeView) { private final BasicMessageChannel<String> lifecycleMessages = new BasicMessageChannel<>(this, "flutter/lifecycle", StringCodec.INSTANCE); @Override public void onFirstFrame() { super.onFirstFrame(); setAlpha(1.0f); } @Override public void onPostResume() { // Overriding default behavior to avoid dictating system UI via PlatformPlugin. lifecycleMessages.send("AppLifecycleState.resumed"); } }; if (initialRoute != null) { flutterView.setInitialRoute(initialRoute); } lifecycle.addObserver(new LifecycleObserver() { @OnLifecycleEvent(Lifecycle.Event.ON_CREATE) public void onCreate() { final FlutterRunArguments arguments = new FlutterRunArguments(); arguments.bundlePath = FlutterMain.findAppBundlePath(activity.getApplicationContext()); arguments.entrypoint = "main"; flutterView.runFromBundle(arguments); } @OnLifecycleEvent(Lifecycle.Event.ON_START) public void onStart() { flutterView.onStart(); } @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) public void onResume() { flutterView.onPostResume(); } @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE) public void onPause() { flutterView.onPause(); } @OnLifecycleEvent(Lifecycle.Event.ON_STOP) public void onStop() { flutterView.onStop(); } @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void onDestroy() { flutterView.destroy(); } }); flutterView.setAlpha(0.0f); return flutterView; }
Example #8
Source File: FlutterFragment.java From CrazyDaily with Apache License 2.0 | 4 votes |
@Override public FlutterView onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return Flutter.createView(getActivity(), getLifecycle(), mRoute); }
Example #9
Source File: FlutterFragment.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
@Override public FlutterView onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return Flutter.createView(getActivity(), getLifecycle(), mRoute); }
Example #10
Source File: AppFlutterActivity.java From Aurora with Apache License 2.0 | 4 votes |
public FlutterView getFlutterView() { return this.viewProvider.getFlutterView(); }
Example #11
Source File: AppFlutterActivity.java From Aurora with Apache License 2.0 | 4 votes |
public FlutterView createFlutterView(Context context) { return null; }
Example #12
Source File: XFlutterActivityDelegate.java From hybrid_stack_manager with MIT License | votes |
FlutterView createFlutterView(Context context);
Example #13
Source File: XFlutterActivityDelegate.java From hybrid_stack_manager with MIT License | votes |
FlutterView createFlutterView(Context context);