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 {
|
fun handleShareIntent(context: Context, intent: Intent): Boolean {
|
||||||
val type = intent.resolveType(context) ?: return false
|
val type = intent.resolveType(context) ?: return false
|
||||||
if (type.startsWith("image")) {
|
when {
|
||||||
callback.onContentAttachmentsReady(
|
type.startsWith("image") -> {
|
||||||
MultiPicker.get(MultiPicker.IMAGE).getIncomingFiles(context, intent).map {
|
callback.onContentAttachmentsReady(
|
||||||
it.toContentAttachmentData()
|
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 {
|
type.startsWith("video") -> {
|
||||||
it.toContentAttachmentData()
|
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()
|
type.startsWith("audio") -> {
|
||||||
}
|
callback.onContentAttachmentsReady(
|
||||||
)
|
MultiPicker.get(MultiPicker.AUDIO).getIncomingFiles(context, intent).map {
|
||||||
} else if (type.startsWith("application") || type.startsWith("file") || type.startsWith("text") || type.startsWith("*")) {
|
it.toContentAttachmentData()
|
||||||
callback.onContentAttachmentsReady(
|
}
|
||||||
MultiPicker.get(MultiPicker.FILE).getIncomingFiles(context, intent).map {
|
)
|
||||||
it.toContentAttachmentData()
|
}
|
||||||
}
|
type.startsWith("application") || type.startsWith("file") || type.startsWith("text") || type.startsWith("*") -> {
|
||||||
)
|
callback.onContentAttachmentsReady(
|
||||||
} else {
|
MultiPicker.get(MultiPicker.FILE).getIncomingFiles(context, intent).map {
|
||||||
return false
|
it.toContentAttachmentData()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue