Exemplo n.º 1
0
        private void OpenCamera()
        {
            if (_cameraSurface == null)
            {
                _cameraSurface = new CameraSurface(this);
                _cameraFrameLayout.AddView(_cameraSurface);
            }

            if (_camera == null)
            {
                // Camera2 API has more capabilities but is more complex to use and not needed for current requirements of Umbella modules
#pragma warning disable 0618
                _camera = global::Android.Hardware.Camera.Open();
                _cameraSurface.OpenCamera(_camera);
            }
            else
            {
                _camera.StartPreview();
            }

            _ = StartSendingPhotoAsync();
        }
Exemplo n.º 2
0
        protected override async void OnPause()
        {
            base.OnPause();
            _working = false;
            if (_camera != null && _cameraSurface != null)
            {
                await _takePhotoLock.WaitAsync();

                _cameraFrameLayout?.RemoveView(_cameraSurface);
                _cameraSurface.ReleaseResources();
                _cameraSurface = null;

                ReleaseCamera();
                UnsubscribeFromEvents();

                _takePhotoLock.Release();
            }
            else
            {
                UnsubscribeFromTakenPhotoButtonsBarEvents();
            }

            ViewModel.PropertyChanged -= ViewModel_PropertyChanged;
        }