wizard: Reduce nested closures
All checks were successful
/ build-debug (push) Successful in 4m41s

This commit is contained in:
Peter Cai 2025-03-08 16:42:48 -05:00
parent d3df70501a
commit db8063cd5f

View file

@ -42,18 +42,16 @@ class DownloadWizardMethodSelectFragment : DownloadWizardActivity.DownloadWizard
registerForActivityResult(ActivityResultContracts.GetContent()) { result ->
if (result == null) return@registerForActivityResult
lifecycleScope.launch(Dispatchers.IO) {
runCatching {
requireContext().contentResolver.openInputStream(result)?.use { input ->
BitmapFactory.decodeStream(input).use { bmp ->
decodeQrFromBitmap(bmp)?.let {
withContext(Dispatchers.Main) {
processLpaString(it)
}
}
lifecycleScope.launch {
val decoded = withContext(Dispatchers.IO) {
runCatching {
requireContext().contentResolver.openInputStream(result)?.use { input ->
BitmapFactory.decodeStream(input).use(::decodeQrFromBitmap)
}
}
}
decoded.getOrNull()?.let { processLpaString(it) }
}
}