Skip to content

Commit

Permalink
Use TextView.doOnTextChanged() extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
Isira-Seneviratne committed Oct 17, 2020
1 parent 293e2ff commit 1336992
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.core.content.getSystemService
import androidx.core.os.bundleOf
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.core.widget.doOnTextChanged
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
Expand Down Expand Up @@ -194,16 +195,11 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
}

group_name_input_container.error = null
group_name_input.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable?) {}
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}

override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
if (group_name_input_container.isErrorEnabled && !s.isNullOrBlank()) {
group_name_input_container.error = null
}
group_name_input.doOnTextChanged { text, _, _, _ ->
if (group_name_input_container.isErrorEnabled && !text.isNullOrBlank()) {
group_name_input_container.error = null
}
})
}

confirm_button.setOnClickListener { handlePositiveButton() }

Expand Down

0 comments on commit 1336992

Please sign in to comment.