viewModel.getStatus().observe(this, Observer { handleStatus(it) }) | |
private fun handleStatus(status: Status?) { | |
when (status) { | |
Status.EMPTY_FIRST_NAME -> Toast.makeText(activity, "Please enter your first name!", Toast.LENGTH_SHORT).show() | |
Status.EMPTY_LAST_NAME -> Toast.makeText(activity, "Please enter your last name", Toast.LENGTH_SHORT).show() | |
Status.EMPTY_CITY -> Toast.makeText(activity, "Please choose your home city", Toast.LENGTH_SHORT).show() | |
Status.INVALID_URI -> Toast.makeText(activity, "Unable to load the photo", Toast.LENGTH_SHORT).show() | |
Status.SUCCESS -> { | |
startActivity(HomeFragment.newIntent(activity)) | |
activity.finish() | |
} | |
else -> Toast.makeText(activity, "Something went wrong, please try again!", Toast.LENGTH_SHORT).show() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment