I have following code:
private fun initSlider() {
binding.sSlider.addOnChangeListener { _, value: Float, _ ->
if (!value.isNaN()) {
viewModel.setValueFromSlider(value.roundToInt())
}
}
viewModel.sliderProgress.observe(viewLifecycleOwner) {
binding.sSlider.value = it?.toFloat() ?: 0f
}
}
It's just a simple slider, that is used to set some value to the application. The slider looks like this:
<com.google.android.material.slider.Slider
android:id="@+id/s_slider"
...
android:valueFrom="0"
android:valueTo="100"
/>
It works well, it is tested on thousands of installations. However, for a some time, there was this strange issue on Transsion Tecno devices:
Fatal Exception: java.lang.IllegalStateException: Slider value(107.0) must be greater or equal to valueFrom(0.0), and lower or equal to valueTo(100.0) at com.google.android.material.slider.BaseSlider.validateValues(BaseSlider.java:621)...
I put these valueFrom and valueTo attributes to Slider as you can see, but the issue still appears. It seems that it is hard crash, the app stops working for these devices. Can somebody advise, how to solve this issue? I do not own such phone. Thank you.