mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2024-12-29 09:39:59 +01:00
make dialNumber callback nullable for easier reading
This commit is contained in:
parent
636c7cb8c5
commit
580fc7d35b
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user