prevent NPE in afterTextChanged

This commit is contained in:
Milos Kozak 2022-12-16 11:31:25 +01:00
parent 8b41abb388
commit bf3d15f9be
5 changed files with 15 additions and 7 deletions

View file

@ -385,7 +385,7 @@ class AutotuneFragment : DaggerFragment() {
private val textWatcher = object : TextWatcher {
override fun afterTextChanged(s: Editable) {
updateGui()
_binding?.let { updateGui() }
}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}

View file

@ -72,8 +72,10 @@ class CarbsDialog : DialogFragmentWithDate() {
private val textWatcher: TextWatcher = object : TextWatcher {
override fun afterTextChanged(s: Editable) {
_binding?.let {
validateInputs()
}
}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}

View file

@ -80,8 +80,10 @@ class InsulinDialog : DialogFragmentWithDate() {
private val textWatcher: TextWatcher = object : TextWatcher {
override fun afterTextChanged(s: Editable) {
_binding?.let {
validateInputs()
}
}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}

View file

@ -65,10 +65,12 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
private val textWatcher: TextWatcher = object : TextWatcher {
override fun afterTextChanged(s: Editable) {
_binding?.let { binding ->
val isDuration = binding.duration.value > 0
val isLowerPercentage = binding.percentage.value < 100
binding.ttLayout.visibility = (isDuration && isLowerPercentage).toVisibility()
}
}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}

View file

@ -103,8 +103,10 @@ class WizardDialog : DaggerDialogFragment() {
private val timeTextWatcher = object : TextWatcher {
override fun afterTextChanged(s: Editable) {
_binding?.let { binding ->
binding.alarm.isChecked = binding.carbTimeInput.value > 0
}
}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {