Last active
March 18, 2021 11:49
-
-
Save CDRussell/0d9327996c90bb7fa8709c02e385731a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
viewModel.command.observe(this, Observer { | |
when (it) { | |
is BrowserViewModel.Command.Refresh -> webView.reload() | |
is BrowserViewModel.Command.Navigate -> webView.loadUrl(it.url) | |
is BrowserViewModel.Command.DialNumber -> { | |
val intent = Intent(Intent.ACTION_DIAL) | |
intent.data = Uri.parse("tel:${it.telephoneNumber}") | |
launchExternalActivity(intent) | |
} | |
is BrowserViewModel.Command.SendEmail -> { | |
val intent = Intent(Intent.ACTION_SENDTO) | |
intent.data = Uri.parse(it.emailAddress) | |
launchExternalActivity(intent) | |
} | |
is BrowserViewModel.Command.SendSms -> { | |
val intent = Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:${it.telephoneNumber}")) | |
startActivity(intent) | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment