mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-25 19:05:56 +03:00
converting if/else to when
This commit is contained in:
parent
abf35d730d
commit
8811f752e5
1 changed files with 32 additions and 26 deletions
|
@ -196,32 +196,38 @@ class AttachmentsHelper(val context: Context, val callback: Callback) : Restorab
|
|||
*/
|
||||
fun handleShareIntent(context: Context, intent: Intent): Boolean {
|
||||
val type = intent.resolveType(context) ?: return false
|
||||
if (type.startsWith("image")) {
|
||||
callback.onContentAttachmentsReady(
|
||||
MultiPicker.get(MultiPicker.IMAGE).getIncomingFiles(context, intent).map {
|
||||
it.toContentAttachmentData()
|
||||
}
|
||||
)
|
||||
} else if (type.startsWith("video")) {
|
||||
callback.onContentAttachmentsReady(
|
||||
MultiPicker.get(MultiPicker.VIDEO).getIncomingFiles(context, intent).map {
|
||||
it.toContentAttachmentData()
|
||||
}
|
||||
)
|
||||
} else if (type.startsWith("audio")) {
|
||||
callback.onContentAttachmentsReady(
|
||||
MultiPicker.get(MultiPicker.AUDIO).getIncomingFiles(context, intent).map {
|
||||
it.toContentAttachmentData()
|
||||
}
|
||||
)
|
||||
} else if (type.startsWith("application") || type.startsWith("file") || type.startsWith("text") || type.startsWith("*")) {
|
||||
callback.onContentAttachmentsReady(
|
||||
MultiPicker.get(MultiPicker.FILE).getIncomingFiles(context, intent).map {
|
||||
it.toContentAttachmentData()
|
||||
}
|
||||
)
|
||||
} else {
|
||||
return false
|
||||
when {
|
||||
type.startsWith("image") -> {
|
||||
callback.onContentAttachmentsReady(
|
||||
MultiPicker.get(MultiPicker.IMAGE).getIncomingFiles(context, intent).map {
|
||||
it.toContentAttachmentData()
|
||||
}
|
||||
)
|
||||
}
|
||||
type.startsWith("video") -> {
|
||||
callback.onContentAttachmentsReady(
|
||||
MultiPicker.get(MultiPicker.VIDEO).getIncomingFiles(context, intent).map {
|
||||
it.toContentAttachmentData()
|
||||
}
|
||||
)
|
||||
}
|
||||
type.startsWith("audio") -> {
|
||||
callback.onContentAttachmentsReady(
|
||||
MultiPicker.get(MultiPicker.AUDIO).getIncomingFiles(context, intent).map {
|
||||
it.toContentAttachmentData()
|
||||
}
|
||||
)
|
||||
}
|
||||
type.startsWith("application") || type.startsWith("file") || type.startsWith("text") || type.startsWith("*") -> {
|
||||
callback.onContentAttachmentsReady(
|
||||
MultiPicker.get(MultiPicker.FILE).getIncomingFiles(context, intent).map {
|
||||
it.toContentAttachmentData()
|
||||
}
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue