5package io.flutter.view;
9import androidx.annotation.NonNull;
10import androidx.annotation.UiThread;
12import io.flutter.app.FlutterPluginRegistry;
13import io.flutter.embedding.engine.FlutterEngine.EngineLifecycleListener;
14import io.flutter.embedding.engine.FlutterJNI;
15import io.flutter.embedding.engine.dart.DartExecutor;
16import io.flutter.embedding.engine.renderer.FlutterUiDisplayListener;
17import io.flutter.plugin.common.*;
18import java.nio.ByteBuffer;
26 private static final String TAG =
"FlutterNativeView";
32 private final Context mContext;
33 private boolean applicationIsRunning;
38 public void onFlutterUiDisplayed() {
39 if (mFlutterView ==
null) {
46 public void onFlutterUiNoLongerDisplayed() {
56 if (isBackgroundView) {
57 Log.
w(
TAG,
"'isBackgroundView' is no longer supported and will be ignored");
63 this.dartExecutor =
new DartExecutor(mFlutterJNI, context.getAssets());
80 applicationIsRunning =
false;
90 return mPluginRegistry;
94 mFlutterView = flutterView;
95 mPluginRegistry.
attach(flutterView, activity);
103 if (!
isAttached())
throw new AssertionError(
"Platform view is not attached");
107 if (
args.entrypoint ==
null) {
108 throw new AssertionError(
"An entrypoint must be specified");
111 if (applicationIsRunning)
112 throw new AssertionError(
"This Flutter engine instance is already running an application");
117 mContext.getResources().getAssets(),
120 applicationIsRunning =
true;
124 return applicationIsRunning;
152 Log.
d(
TAG,
"FlutterView.send called on a detached view, channel=" + channel);
186 private final class EngineLifecycleListenerImpl
implements EngineLifecycleListener {
188 @SuppressWarnings(
"unused")
189 public
void onPreEngineRestart() {
190 if (mFlutterView !=
null) {
193 if (mPluginRegistry ==
null) {
199 public void onEngineWillDestroy() {
static void d(@NonNull String tag, @NonNull String message)
static void w(@NonNull String tag, @NonNull String message)
void onPreEngineRestart()
void attach(FlutterView flutterView, Activity activity)
void addIsDisplayingFlutterUiListener(@NonNull FlutterUiDisplayListener listener)
void runBundleAndSnapshotFromLibrary( @NonNull String bundlePath, @Nullable String entrypointFunctionName, @Nullable String pathToEntrypointFunction, @NonNull AssetManager assetManager, @Nullable List< String > entrypointArgs)
void detachFromNativeAndReleaseResources()
void addEngineLifecycleListener(@NonNull EngineLifecycleListener engineLifecycleListener)
static String getVMServiceUri()
void removeIsDisplayingFlutterUiListener(@NonNull FlutterUiDisplayListener listener)
BinaryMessenger getBinaryMessenger()
void setMessageHandler(String channel, BinaryMessageHandler handler)
void disableBufferingIncomingMessages()
FlutterNativeView(@NonNull Context context, boolean isBackgroundView)
void send(String channel, ByteBuffer message, BinaryReply callback)
FlutterJNI getFlutterJNI()
void send(String channel, ByteBuffer message)
static String getObservatoryUri()
void detachFromFlutterView()
FlutterPluginRegistry getPluginRegistry()
static String getVMServiceUri()
boolean isApplicationRunning()
void enableBufferingIncomingMessages()
void attachViewAndActivity(FlutterView flutterView, Activity activity)
DartExecutor getDartExecutor()
FlutterNativeView(@NonNull Context context)
void setMessageHandler(String channel, BinaryMessageHandler handler, TaskQueue taskQueue)
TaskQueue makeBackgroundTaskQueue(TaskQueueOptions options)
void runFromBundle(FlutterRunArguments args)
void resetAccessibilityTree()
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
void setMessageHandler(@NonNull String channel, @Nullable BinaryMessageHandler handler)
default TaskQueue makeBackgroundTaskQueue()
void send(@NonNull String channel, @Nullable ByteBuffer message)