How can I use rxBinding to call setOnSeekBarChangeListener?
My code :
view?.seekBarDisplay?.setOnSeekBarChangeListener(object :
SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar,
progress: Int, fromuser: Boolean) {
val backLightValue = (progress / 100f)
val layoutParams = activity?.window?.attributes
layoutParams?.screenBrightness = backLightValue
activity?.window?.attributes = layoutParams
}
override fun onStartTrackingTouch(seekBar: SeekBar) {}
override fun onStopTrackingTouch(seekBar: SeekBar) {}
})
As RxBinding 4.0 released, you have 4 options to implement the Seekbar using it:
the
SeekBar.changeEvents(): with subscribing to this observable, you'll get notified whenonProgressChanged,onStartTrackingTouch, andonStopTrackingTouchmethods get called.SeekBar.changes(): Notifies you only when any changes happen to the seekbar.SeekBar.userChanges(): Notifies you only when any changes happen to the seekbar by User itself.SeekBar.systemChanges(): Notifies you only when any changes happen to the seekbar by the system.you can subscribe to these function as other usual Observables.
Here is a sample of the first method: