Improve readability with a traditional null check

Sure, this can be expressed more briefly, but not more comprehensibly.
This commit is contained in:
Markus Fisch
2021-12-23 17:49:46 +01:00
parent f65e942100
commit b4fefad54f
@@ -18,10 +18,12 @@ abstract class IntentAction : IAction {
abstract val errorMsg: Int
final override suspend fun execute(context: Context, data: ByteArray) {
val intent = createIntent(context, data) ?: return context.toast(
errorMsg
)
context.execShareIntent(intent)
val intent = createIntent(context, data)
if (intent == null) {
context.toast(errorMsg)
} else {
context.execShareIntent(intent)
}
}
abstract suspend fun createIntent(context: Context, data: ByteArray): Intent?