From 3d4fb6a2f6d7816f5ff7ecf57c94ce05328d9d56 Mon Sep 17 00:00:00 2001 From: Brandon McAnsh Date: Wed, 21 Feb 2024 16:24:48 -0500 Subject: [PATCH] chore(filepicker): trigger onResult when nothing selected on Android Allow callbacks to invoke when nothing is selected --- .../calf/picker/FilePickerLauncher.android.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/calf-file-picker/src/androidMain/kotlin/com/mohamedrejeb/calf/picker/FilePickerLauncher.android.kt b/calf-file-picker/src/androidMain/kotlin/com/mohamedrejeb/calf/picker/FilePickerLauncher.android.kt index 772841f..3bc6d1d 100644 --- a/calf-file-picker/src/androidMain/kotlin/com/mohamedrejeb/calf/picker/FilePickerLauncher.android.kt +++ b/calf-file-picker/src/androidMain/kotlin/com/mohamedrejeb/calf/picker/FilePickerLauncher.android.kt @@ -76,7 +76,7 @@ private fun pickSingleVisualMedia( contract = ActivityResultContracts.PickVisualMedia(), onResult = { uri -> val file = URIPathHelper.getPath(context, uri)?.let { File(it) } - file?.let { onResult(listOf(it)) } + file?.let { onResult(listOf(it)) } ?: onResult(emptyList()) } ) @@ -136,7 +136,7 @@ private fun pickSingleFile( contract = ActivityResultContracts.GetContent(), onResult = { uri -> val file = URIPathHelper.getPath(context, uri)?.let { File(it) } - file?.let { onResult(listOf(it)) } + file?.let { onResult(listOf(it)) } ?: onResult(emptyList()) } ) @@ -201,7 +201,7 @@ private fun pickFolder( Intent.FLAG_GRANT_READ_URI_PERMISSION ) val file = URIPathHelper.getPath(context, uri)?.let { File(it) } - file?.let { onResult(listOf(it)) } + file?.let { onResult(listOf(it)) } ?: onResult(emptyList()) } } ) @@ -242,4 +242,4 @@ actual class FilePickerLauncher actual constructor( actual fun launch() { onLaunch() } -} \ No newline at end of file +}