forked from upstream-mirrors/quik
fix(compose): Handle different intents in provideSharedAttachments
Manage single and multiple URIs without throwing a class cast exception.
This commit is contained in:
@@ -86,9 +86,14 @@ class ComposeActivityModule {
|
||||
@Named("attachments")
|
||||
fun provideSharedAttachments(activity: ComposeActivity): List<Attachment> {
|
||||
val uris = mutableListOf<Uri>()
|
||||
activity.intent.getParcelableExtra<Uri>(Intent.EXTRA_STREAM)?.run(uris::add)
|
||||
activity.intent.getParcelableArrayListExtra<Uri>(Intent.EXTRA_STREAM)?.run(uris::addAll)
|
||||
|
||||
when (activity.intent.action) {
|
||||
Intent.ACTION_SEND -> {
|
||||
activity.intent.getParcelableExtra<Uri>(Intent.EXTRA_STREAM)?.run(uris::add)
|
||||
}
|
||||
Intent.ACTION_SEND_MULTIPLE -> {
|
||||
activity.intent.getParcelableArrayListExtra<Uri>(Intent.EXTRA_STREAM)?.run(uris::addAll)
|
||||
}
|
||||
}
|
||||
return uris.map { Attachment(activity, it) }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user