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,7 +72,9 @@ class CarbsDialog : DialogFragmentWithDate() {
private val textWatcher: TextWatcher = object : TextWatcher {
override fun afterTextChanged(s: Editable) {
validateInputs()
_binding?.let {
validateInputs()
}
}
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}

View file

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

View file

@ -65,9 +65,11 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
private val textWatcher: TextWatcher = object : TextWatcher {
override fun afterTextChanged(s: Editable) {
val isDuration = binding.duration.value > 0
val isLowerPercentage = binding.percentage.value < 100
binding.ttLayout.visibility = (isDuration && isLowerPercentage).toVisibility()
_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) {}

View file

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