GoogleFragment: Move authevent check to flow collector
lint warns that when checks are exhastive otherwise Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -110,29 +110,25 @@ class GoogleFragment : BaseFragment<FragmentGoogleBinding>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
viewLifecycleOwner.lifecycleScope.launch {
|
viewLifecycleOwner.lifecycleScope.launch {
|
||||||
AuroraApp.events.authEvent.collect { onEventReceived(it) }
|
AuroraApp.events.authEvent.collect { event ->
|
||||||
|
if (event is AuthEvent.GoogleLogin) onEventReceived(event)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onEventReceived(event: AuthEvent) {
|
private fun onEventReceived(event: AuthEvent.GoogleLogin) {
|
||||||
when (event) {
|
if (event.success) {
|
||||||
is AuthEvent.GoogleLogin -> {
|
viewModel.buildGoogleAuthData(event.email, event.token, AuthHelper.Token.AAS)
|
||||||
if (event.success) {
|
} else {
|
||||||
viewModel.buildGoogleAuthData(event.email, event.token, AuthHelper.Token.AAS)
|
Toast.makeText(
|
||||||
} else {
|
requireContext(),
|
||||||
Toast.makeText(
|
getString(R.string.toast_aas_token_failed),
|
||||||
requireContext(),
|
Toast.LENGTH_LONG
|
||||||
getString(R.string.toast_aas_token_failed),
|
).show()
|
||||||
Toast.LENGTH_LONG
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
findNavController().navigate(
|
|
||||||
GoogleFragmentDirections.actionGoogleFragmentToSplashFragment()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
findNavController().navigate(
|
||||||
|
GoogleFragmentDirections.actionGoogleFragmentToSplashFragment()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user