Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public actual object Picker {
initialDirectory: String?,
): Out? = withContext(Dispatchers.IO) {
// Throw exception if registry is not initialized
val registry = registry ?: throw IllegalStateException("Picker not initialized")
val registry = registry ?: throw PickerNotInitializedException()

// It doesn't really matter what the key is, just that it is unique
val key = UUID.randomUUID().toString()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package io.github.vinceglb.picker.core

public class PickerNotInitializedException :
IllegalStateException("Picker not initialized on Android. Please call Picker.init(activity) first.")
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public actual sealed class PickerSelectionMode<Out> {
) : PickerSelectionMode<PlatformFile>() {
actual override fun result(selection: SelectionResult): PlatformFile? {
val context = Picker.context.get()
?: throw IllegalStateException("Picker context is not set")
?: throw PickerNotInitializedException()

return selection.files
?.firstOrNull()
Expand All @@ -27,7 +27,7 @@ public actual sealed class PickerSelectionMode<Out> {
) : PickerSelectionMode<PlatformFiles>() {
override fun result(selection: SelectionResult): PlatformFiles? {
val context = Picker.context.get()
?: throw IllegalStateException("Picker context is not set")
?: throw PickerNotInitializedException()

return selection.files
?.takeIf { it.isNotEmpty() }
Expand Down
1 change: 1 addition & 0 deletions samples/sample-core/composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ android {

defaultConfig {
minSdk = 24
targetSdk = 34
}

compileOptions {
Expand Down