Skip to content

Commit

Permalink
additional removals in image_picker
Browse files Browse the repository at this point in the history
  • Loading branch information
Gray Mackall committed May 15, 2024
1 parent 1c4da2e commit c2e4c87
Showing 1 changed file with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugins.imagepicker.Messages.CacheRetrievalResult;
import io.flutter.plugins.imagepicker.Messages.FlutterError;
import io.flutter.plugins.imagepicker.Messages.GeneralOptions;
Expand Down Expand Up @@ -117,7 +116,6 @@ private class ActivityState {
final Activity activity,
final BinaryMessenger messenger,
final ImagePickerApi handler,
final PluginRegistry.Registrar registrar,
final ActivityPluginBinding activityBinding) {
this.application = application;
this.activity = activity;
Expand All @@ -127,18 +125,12 @@ private class ActivityState {
delegate = constructDelegate(activity);
ImagePickerApi.setUp(messenger, handler);
observer = new LifeCycleObserver(activity);
if (registrar != null) {
// V1 embedding setup for activity listeners.
application.registerActivityLifecycleCallbacks(observer);
registrar.addActivityResultListener(delegate);
registrar.addRequestPermissionsResultListener(delegate);
} else {
// V2 embedding setup for activity listeners.
activityBinding.addActivityResultListener(delegate);
activityBinding.addRequestPermissionsResultListener(delegate);
lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding);
lifecycle.addObserver(observer);
}

// V2 embedding setup for activity listeners.
activityBinding.addActivityResultListener(delegate);
activityBinding.addRequestPermissionsResultListener(delegate);
lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(activityBinding);
lifecycle.addObserver(observer);
}

// Only invoked by {@link #ImagePickerPlugin(ImagePickerDelegate, Activity)} for testing.
Expand Down Expand Up @@ -217,7 +209,6 @@ public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) {
pluginBinding.getBinaryMessenger(),
(Application) pluginBinding.getApplicationContext(),
binding.getActivity(),
null,
binding);
}

Expand All @@ -240,10 +231,9 @@ private void setup(
final BinaryMessenger messenger,
final Application application,
final Activity activity,
final PluginRegistry.Registrar registrar,
final ActivityPluginBinding activityBinding) {
activityState =
new ActivityState(application, activity, messenger, this, registrar, activityBinding);
new ActivityState(application, activity, messenger, this, activityBinding);
}

private void tearDown() {
Expand Down

0 comments on commit c2e4c87

Please sign in to comment.