We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
There is such a binding:
fun MutableLiveData<Boolean>.bindTwoWayToCheckBoxChecked( lifecycleOwner: LifecycleOwner, checkBox: CheckBox ): Closeable { val readCloseable = bindNotNull(lifecycleOwner) { value -> if (checkBox.isChecked == value) return@bindNotNull checkBox.isChecked = value } val checkListener = CompoundButton.OnCheckedChangeListener { _, isChecked -> if (value == isChecked) return@OnCheckedChangeListener value = isChecked } checkBox.setOnCheckedChangeListener(checkListener) val writeCloseable = Closeable { checkBox.setOnCheckedChangeListener(null) } return readCloseable + writeCloseable }
Need:
fun MutableLiveData<Boolean>.bindTwoWayToCheckable( lifecycleOwner: LifecycleOwner, switch: CompoundButton ): Closeable { val readCloseable = bindNotNull(lifecycleOwner) { value -> if (switch.isChecked == value) return@bindNotNull switch.isChecked = value } val checkListener = CompoundButton.OnCheckedChangeListener { _, isChecked -> if (value == isChecked) return@OnCheckedChangeListener value = isChecked } switch.setOnCheckedChangeListener(checkListener) val writeCloseable = Closeable { switch.setOnCheckedChangeListener(null) } return readCloseable + writeCloseable }
The text was updated successfully, but these errors were encountered:
available in 0.13.0
Sorry, something went wrong.
Alex009
No branches or pull requests
There is such a binding:
Need:
The text was updated successfully, but these errors were encountered: