10import io.flutter.embedding.engine.FlutterEngine;
11import io.flutter.plugin.common.BinaryMessenger;
12import io.flutter.plugin.common.PluginRegistry;
13import io.flutter.plugin.platform.PlatformViewRegistry;
14import io.flutter.plugin.platform.PlatformViewsController;
15import io.flutter.view.FlutterMain;
16import io.flutter.view.FlutterNativeView;
17import io.flutter.view.FlutterView;
18import io.flutter.view.TextureRegistry;
19import java.util.ArrayList;
20import java.util.LinkedHashMap;
34 private static final String TAG =
"FlutterPluginRegistry";
36 private Activity mActivity;
37 private Context mAppContext;
42 private final Map<String, Object> mPluginMap =
new LinkedHashMap<>(0);
52 mNativeView = nativeView;
53 mAppContext = context;
59 mAppContext = context;
65 return mPluginMap.containsKey(
key);
69 @SuppressWarnings(
"unchecked")
71 return (
T) mPluginMap.get(pluginKey);
76 if (mPluginMap.containsKey(pluginKey)) {
77 throw new IllegalStateException(
"Plugin key " + pluginKey +
" is already in use");
79 mPluginMap.put(pluginKey,
null);
80 return new FlutterRegistrar(pluginKey);
84 mFlutterView = flutterView;
90 mPlatformViewsController.
detach();
101 return mPlatformViewsController;
104 private class FlutterRegistrar
implements Registrar {
105 private final String pluginKey;
107 FlutterRegistrar(String pluginKey) {
108 this.pluginKey = pluginKey;
112 public Activity activity() {
117 public Context context() {
122 public Context activeContext() {
123 return (mActivity !=
null) ? mActivity : mAppContext;
127 public BinaryMessenger messenger() {
132 public TextureRegistry textures() {
137 public PlatformViewRegistry platformViewRegistry() {
153 return FlutterMain.getLookupKeyForAsset(asset, packageName);
158 mPluginMap.put(pluginKey,
value);
164 RequestPermissionsResultListener listener) {
165 mRequestPermissionsResultListeners.add(listener);
171 mActivityResultListeners.add(listener);
177 mNewIntentListeners.add(listener);
183 mUserLeaveHintListeners.add(listener);
189 mWindowFocusChangedListeners.add(listener);
195 mViewDestroyListeners.add(listener);
202 int requestCode, String[] permissions,
int[] grantResults) {
204 if (listener.onRequestPermissionsResult(requestCode, permissions, grantResults)) {
214 if (listener.onActivityResult(requestCode, resultCode,
data)) {
224 if (listener.onNewIntent(intent)) {
234 listener.onUserLeaveHint();
241 listener.onWindowFocusChanged(hasFocus);
247 boolean handled =
false;
249 if (listener.onViewDestroy(view)) {
boolean onActivityResult(int requestCode, int resultCode, Intent data)
FlutterPluginRegistry(FlutterNativeView nativeView, Context context)
boolean hasPlugin(String key)
PlatformViewsController getPlatformViewsController()
void onPreEngineRestart()
public< T > T valuePublishedByPlugin(String pluginKey)
FlutterPluginRegistry(FlutterEngine engine, Context context)
boolean onNewIntent(Intent intent)
void onWindowFocusChanged(boolean hasFocus)
void attach(FlutterView flutterView, Activity activity)
Registrar registrarFor(String pluginKey)
boolean onViewDestroy(FlutterNativeView view)
boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
String getLookupKeyForAsset(String asset)
DartExecutor getDartExecutor()
Registrar addActivityResultListener(@NonNull ActivityResultListener listener)
Registrar publish(@Nullable Object value)
Registrar addNewIntentListener(@NonNull NewIntentListener listener)
String lookupKeyForAsset(@NonNull String asset)
Registrar addViewDestroyListener(@NonNull ViewDestroyListener listener)
Registrar addRequestPermissionsResultListener( @NonNull RequestPermissionsResultListener listener)
Registrar addUserLeaveHintListener(@NonNull UserLeaveHintListener listener)
Registrar addWindowFocusChangedListener(@NonNull WindowFocusChangedListener listener)
std::shared_ptr< const fml::Mapping > data