mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 10:58:34 +00:00
CameraX cleanup.
This commit is contained in:
parent
b57fab8c75
commit
631005e565
@ -101,7 +101,7 @@ public class CameraXFragment extends Fragment implements CameraFragment {
|
|||||||
this.camera = view.findViewById(R.id.camerax_camera);
|
this.camera = view.findViewById(R.id.camerax_camera);
|
||||||
this.controlsContainer = view.findViewById(R.id.camerax_controls_container);
|
this.controlsContainer = view.findViewById(R.id.camerax_controls_container);
|
||||||
|
|
||||||
camera.bindToLifecycle(this);
|
camera.bindToLifecycle(getViewLifecycleOwner());
|
||||||
camera.setCameraLensFacing(CameraXUtil.toLensFacing(TextSecurePreferences.getDirectCaptureCameraId(requireContext())));
|
camera.setCameraLensFacing(CameraXUtil.toLensFacing(TextSecurePreferences.getDirectCaptureCameraId(requireContext())));
|
||||||
|
|
||||||
onOrientationChanged(getResources().getConfiguration().orientation);
|
onOrientationChanged(getResources().getConfiguration().orientation);
|
||||||
@ -122,8 +122,6 @@ public class CameraXFragment extends Fragment implements CameraFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
CameraX.unbindAll();
|
|
||||||
|
|
||||||
closeVideoFileDescriptor();
|
closeVideoFileDescriptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +351,7 @@ public class CameraXFragment extends Fragment implements CameraFragment {
|
|||||||
public void onCaptureSuccess(ImageProxy image, int rotationDegrees) {
|
public void onCaptureSuccess(ImageProxy image, int rotationDegrees) {
|
||||||
flashHelper.endFlash();
|
flashHelper.endFlash();
|
||||||
|
|
||||||
SimpleTask.run(CameraXFragment.this.getLifecycle(), () -> {
|
SimpleTask.run(CameraXFragment.this.getViewLifecycleOwner().getLifecycle(), () -> {
|
||||||
stopwatch.split("captured");
|
stopwatch.split("captured");
|
||||||
try {
|
try {
|
||||||
return CameraXUtil.toJpeg(image, rotationDegrees, camera.getCameraLensFacing() == CameraX.LensFacing.FRONT);
|
return CameraXUtil.toJpeg(image, rotationDegrees, camera.getCameraLensFacing() == CameraX.LensFacing.FRONT);
|
||||||
@ -388,6 +386,7 @@ public class CameraXFragment extends Fragment implements CameraFragment {
|
|||||||
if (videoFileDescriptor != null) {
|
if (videoFileDescriptor != null) {
|
||||||
try {
|
try {
|
||||||
videoFileDescriptor.close();
|
videoFileDescriptor.close();
|
||||||
|
videoFileDescriptor = null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.w(TAG, "Failed to close video file descriptor", e);
|
Log.w(TAG, "Failed to close video file descriptor", e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user