Skip to content

Commit

Permalink
🐛 fix permission error when choosing multiple step images
Browse files Browse the repository at this point in the history
  • Loading branch information
kmkim2689 committed Oct 21, 2024
1 parent cb27216 commit 2db3c5e
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ class RecipeMakingFragment2 : Fragment() {
}
}

private val requestMultipleImagesRequestPermissionLauncher =
registerForActivityResult(
ActivityResultContracts.RequestPermission(),
) { isGranted: Boolean ->
if (isGranted) {
requestMultiplePhotoPermissionLauncher.launch("image/*")
} else {
showSnackBar(getString(R.string.camera_permission_needed))
}
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand Down Expand Up @@ -219,15 +230,7 @@ class RecipeMakingFragment2 : Fragment() {
if (imageUtils.isPermissionGranted(permissionArray)) {
requestMultiplePhotoPermissionLauncher.launch("image/*")
} else {
registerForActivityResult(
ActivityResultContracts.RequestPermission(),
) { isGranted: Boolean ->
if (isGranted) {
requestMultiplePhotoPermissionLauncher.launch("image/*")
} else {
showSnackBar(getString(R.string.camera_permission_needed))
}
}.launch(Manifest.permission.CAMERA)
requestMultipleImagesRequestPermissionLauncher.launch(Manifest.permission.CAMERA)
}
}

Expand Down

0 comments on commit 2db3c5e

Please sign in to comment.