devlog of ShinJe Kim

[TIL] 2019-11-21

|

Today I Learned

코드를 작성할 떄 변하는 부분과 변하지 않는 부분을 분리하자.

// 변경 전
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
    if (commentEditText.text.isBlank())
        commentTextHint.visibility = View.VISIBLE
    else
        commentTextHint.visibility = View.GONE
}
// 변경 후
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
    commentTextHint.visibility = if (commentEditText.text.isBlank())
        View.VISIBLE
    else
        View.GONE
}

Comments