-
Notifications
You must be signed in to change notification settings - Fork 13
Translated to Kotlin #6
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
base: master
Are you sure you want to change the base?
Translated to Kotlin #6
Conversation
name = getString(R.string.anon) | ||
|
||
savedInstanceState?.getString(NAME_KEY)?.let { | ||
name = 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.
Наверное не имеет смысла предварительно получать R.string.anon
можно записать это более лаконично, используя оператор Элвис:
name = savedInstanceState?.getString(NAME_KEY) ?: getString(R.string.anon)
data.getStringExtra((NewSecondActivity.NAME_KEY))?.let{ | ||
name = 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.
можно упростить условие и убрать из него data != null
вместо этого воспользуемся безопасным вызовом: ?.
data?.getStringExtra(NewSecondActivity.NAME_KEY)?.let{ name = it }
и лишние двойные скобки
|
||
|
||
companion object { | ||
const val NAME_KEY = "com.example.kotlinhomework.MainActivity.NAME_KEY" |
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.
потерялся private
} | ||
|
||
override fun afterTextChanged(s: Editable?) { | ||
s?.let { |
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.
или можно так:
if (s.isNullOrEmpty().not()) button.isEnabled = true
No description provided.