From ccf893da5a703f29b87ab90c8bd57bca175275e4 Mon Sep 17 00:00:00 2001 From: Alexey Nesterov Date: Fri, 26 Apr 2024 17:02:38 +0700 Subject: [PATCH] #34 Fix detekt --- .../moko/media/picker/FilePickerDelegate.kt | 22 +++++++++---------- .../media/picker/MediaPickerControllerImpl.kt | 2 ++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/media/src/androidMain/kotlin/dev/icerock/moko/media/picker/FilePickerDelegate.kt b/media/src/androidMain/kotlin/dev/icerock/moko/media/picker/FilePickerDelegate.kt index 08842df..5a404e0 100644 --- a/media/src/androidMain/kotlin/dev/icerock/moko/media/picker/FilePickerDelegate.kt +++ b/media/src/androidMain/kotlin/dev/icerock/moko/media/picker/FilePickerDelegate.kt @@ -36,7 +36,8 @@ internal class FilePickerDelegate { return@register } - if (uri.path == null) { + val path = uri.path + if (path == null) { callback.invoke(Result.failure(java.lang.IllegalStateException("File is null"))) return@register } @@ -50,18 +51,15 @@ internal class FilePickerDelegate { } } else null - uri.path?.let { path -> - val file = File(path) - val name = file.name - callback( - Result.success( - FileMedia( - fileNameWithExtension ?: name, - uri.toString(), - ) - ) + val file = File(path) + val name = file.name + val result = Result.success( + FileMedia( + fileNameWithExtension ?: name, + uri.toString(), ) - } + ) + callback.invoke(result) } } diff --git a/media/src/androidMain/kotlin/dev/icerock/moko/media/picker/MediaPickerControllerImpl.kt b/media/src/androidMain/kotlin/dev/icerock/moko/media/picker/MediaPickerControllerImpl.kt index 79b5db8..f94ae7c 100755 --- a/media/src/androidMain/kotlin/dev/icerock/moko/media/picker/MediaPickerControllerImpl.kt +++ b/media/src/androidMain/kotlin/dev/icerock/moko/media/picker/MediaPickerControllerImpl.kt @@ -66,6 +66,8 @@ internal class MediaPickerControllerImpl( * (Look here: https://youtrack.jetbrains.com/issue/KT-37331) */ override suspend fun pickImage(source: MediaSource, maxWidth: Int, maxHeight: Int): Bitmap { + + @Suppress("NewApi") source.requiredPermissions().forEach { permission -> permissionsController.providePermission(permission) }