-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert java to kotlin #142
base: master
Are you sure you want to change the base?
Conversation
if (!populated(editTextPassword)) { | ||
passwordErrorText.visibility = View.VISIBLE | ||
passwordErrorText.text = getString(R.string.empty_input_error) | ||
isValid = false | ||
} | ||
if (!populated(editTextConfirmPassword)) { | ||
confirmPasswordErrorText.visibility = View.VISIBLE | ||
confirmPasswordErrorText.text = getString(R.string.empty_input_error) | ||
isValid = false | ||
} | ||
if (!populated(editTextEmail)) { | ||
emailErrorText.visibility = View.VISIBLE | ||
emailErrorText.text = getString(R.string.empty_input_error) | ||
isValid = false | ||
} | ||
if (!populated(editTextUserName)) { | ||
usernameErrorText.visibility = View.VISIBLE | ||
usernameErrorText.text = getString(R.string.empty_input_error) | ||
isValid = false | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate code can be reduced by extraction
private fun populated(editText: EditText): Boolean { | ||
return editText.text.toString().trim().isNotEmpty() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be used as extension
private fun showProgressDialog() { | ||
progressDialog = MaterialDialog.Builder(this) | ||
.title(R.string.loading) | ||
.content(R.string.please_wait) | ||
.widgetColorRes(R.color.primary) | ||
.progress(true, 0) | ||
.cancelable(false) | ||
.show() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to UIUtils
intent?.extras?.let { | ||
intent.putExtras(it) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unneccessary
private fun showSuccessLayout() { | ||
registerLayout.visibility = View.GONE | ||
success_description.setText(R.string.activation_email_sent_message) | ||
success_complete.visibility = View.VISIBLE | ||
} | ||
|
||
private fun setUserNameError(registrationErrorDetails: RegistrationErrorDetails) { | ||
usernameErrorText.visibility = View.VISIBLE | ||
usernameErrorText.text = registrationErrorDetails.username[0] | ||
editTextUserName.requestFocus() | ||
} | ||
|
||
private fun setEmailError(registrationErrorDetails: RegistrationErrorDetails) { | ||
emailErrorText.visibility = View.VISIBLE | ||
emailErrorText.text = registrationErrorDetails.email[0] | ||
editTextEmail.requestFocus() | ||
} | ||
|
||
private fun setPasswordError(registrationErrorDetails: RegistrationErrorDetails) { | ||
passwordErrorText.visibility = View.VISIBLE | ||
passwordErrorText.text = registrationErrorDetails.password[0] | ||
editTextPassword.requestFocus() | ||
} | ||
|
||
private fun setPhoneNumberError(registrationErrorDetails: RegistrationErrorDetails) { | ||
phoneErrorText.visibility = View.VISIBLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code duplications can be removed by extraction method
c686873
to
f9b09e8
Compare
Changes done
Reason for the changes
Fixes # . Remove this line if there aren't any corresponding issues created
Stats
Guidelines