make dialNumber callback nullable for easier reading

This commit is contained in:
Tibor Kaputa 2021-10-18 18:36:00 +02:00 committed by GitHub
parent 636c7cb8c5
commit 580fc7d35b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,10 +34,10 @@ import com.simplemobiletools.smsmessenger.interfaces.MessagesDao
import com.simplemobiletools.smsmessenger.models.*
import com.simplemobiletools.smsmessenger.receivers.DirectReplyReceiver
import com.simplemobiletools.smsmessenger.receivers.MarkAsReadReceiver
import me.leolin.shortcutbadger.ShortcutBadger
import java.io.FileNotFoundException
import java.util.*
import kotlin.collections.ArrayList
import me.leolin.shortcutbadger.ShortcutBadger
val Context.config: Config get() = Config.newInstance(applicationContext)
@ -894,13 +894,13 @@ fun Context.getFileSizeFromUri(uri: Uri): Long {
}
}
fun Context.dialNumber(phoneNumber: String, callback: () -> Unit = fun() {}) {
fun Context.dialNumber(phoneNumber: String, callback: (() -> Unit)? = null) {
Intent(Intent.ACTION_DIAL).apply {
data = Uri.fromParts("tel", phoneNumber, null)
try {
startActivity(this)
callback()
callback?.invoke()
} catch (e: ActivityNotFoundException) {
toast(R.string.no_app_found)
} catch (e: Exception) {