Skip to content

Commit

Permalink
Resolve bad merge of #223
Browse files Browse the repository at this point in the history
  • Loading branch information
pbowyer committed May 28, 2022
1 parent 8023f51 commit 030caa9
Showing 1 changed file with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,27 +370,18 @@ public void run() {
fragmentTransaction.add(containerView.getId(), fragment);
fragmentTransaction.commit();

call.resolve();
// NOTE: we don't return invoke call.resolve here because it must be invoked in onCameraStarted
// otherwise the plugin start method might resolve/return before the camera is actually set in CameraActivity
// onResume method (see this line mCamera = Camera.open(defaultCameraId);) and the next subsequent plugin
// method invocations (for example, getSupportedFlashModes) might fails with "Camera is not running" error
// because camera is not available yet and hasCamera method will return false
// Please also see https://developer.android.com/reference/android/hardware/Camera.html#open%28int%29
bridge.saveCall(call);
cameraStartCallbackId = call.getCallbackId();
} else {
call.reject("camera already started");
}
}

FragmentManager fragmentManager = getBridge().getActivity().getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.add(containerView.getId(), fragment);
fragmentTransaction.commit();

// NOTE: we don't return invoke call.resolve here because it must be invoked in onCameraStarted
// otherwise the plugin start method might resolve/return before the camera is actually set in CameraActivity
// onResume method (see this line mCamera = Camera.open(defaultCameraId);) and the next subsequent plugin
// method invocations (for example, getSupportedFlashModes) might fails with "Camera is not running" error
// because camera is not available yet and hasCamera method will return false
// Please also see https://developer.android.com/reference/android/hardware/Camera.html#open%28int%29
bridge.saveCall(call);
cameraStartCallbackId = call.getCallbackId();
} else {
call.reject("camera already started");
}
);
}
Expand Down

0 comments on commit 030caa9

Please sign in to comment.