This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| childFragmentManager.setFragmentResultListener(...) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| parentFragmentManager.setFragmentResultListener(...) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| parentFragmentManager.setFragmentResult( | |
| requestKey, // Same request key FragmentA used to register its listener | |
| bundleOf(key to value) // The data to be passed to FragmentA | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FragmentManager.setFragmentResultListener( | |
| requestKey, | |
| lifecycleOwner, | |
| FragmentResultListener { requestKey: String, result: Bundle -> | |
| // Handle result | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| imageAnalysis.setAnalyzer(executor) { image -> | |
| val rotationDegrees = image.imageInfo.rotationDegrees | |
| // Analyze image. Make sure to close it before returning from the method, otherwise the pipeline will be blocked. | |
| image.close() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Set desired name and type of captured image to be used by the contentResolver when writing captured image to MediaStore | |
| val contentValues = ContentValues().apply { | |
| put(MediaStore.MediaColumns.DISPLAY_NAME, "anImage") | |
| put(MediaStore.MediaColumns.MIME_TYPE, "image/jpg") | |
| } | |
| // Create the output file option to store the captured image in MediaStore | |
| val outputFileOptions = ImageCapture.OutputFileOptions | |
| .Builder(contentResolver, MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues) | |
| .build() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Create file to store the image in | |
| val imageFile = createTempFile("anImage", ".jpg") | |
| // Create the output file option from the above file | |
| val outputFileOptions = ImageCapture.OutputFileOptions.Builder(imageFile).build() | |
| // Initiate image capture | |
| imageCapture.takePicture(outputFileOptions, executor, object: ImageCapture.OnImageSavedCallback { | |
| override fun onImageSaved(outputFileResults: ImageCapture.OutputFileResults) { | |
| // Image was successfully saved to `imageFile` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| imageCapture.takePicture(executor, object: ImageCapture.OnImageCapturedCallback() { | |
| override fun onCaptureSuccess(image: ImageProxy) { | |
| // Use the image, then make sure to close it. | |
| image.close() | |
| } | |
| override fun onError(exception: ImageCaptureException) { | |
| val errorType = exception.getImageCaptureError() | |
| displayError(errorType) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Create a SurfaceProvider using PreviewView. The CameraInfo you pass in to this method can be: | |
| // - `null`, in which case you won't benifit from certain optimizations PreviewView can provide to display the preview. | |
| // - Obtained after binding the use cases. Calling `bindToLifecycle()` returns a Camera instance, use it to call `Camera.getCameraInfo()`. | |
| val surfaceProvider = previewView.createSurfaceProvider(cameraInfo) | |
| // Attach the SurfaceProvider to the preview to start displaying the camera preview. | |
| preview.setSurfaceProvider(surfaceProvider) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| view.setOnTouchListener() { view, event -> | |
| // Handle the touch event | |
| // Return true when the event has been handled, false otherwise | |
| } |