rsktash
02/26/2021, 7:33 PMAdam Powell
02/26/2021, 7:44 PMjim
02/26/2021, 7:50 PMrsktash
02/26/2021, 7:50 PMonValueChangeFinished
Then, should we store two values first is main value second is awaiting user interaction?jim
02/26/2021, 7:54 PMrsktash
02/26/2021, 7:55 PMjim
02/26/2021, 7:56 PMonValueChangeFinished
doesn't have a value parameter, ewwrsktash
02/26/2021, 7:59 PMRick Regan
02/26/2021, 10:41 PMThomas
02/27/2021, 10:01 AMRick Regan
02/27/2021, 1:44 PMThomas
02/27/2021, 8:40 PMposition
changes without touching the slider. That is what the linked issue is about as well.Rick Regan
02/27/2021, 9:30 PMposition
and userPosition
declared)?rsktash
02/27/2021, 10:41 PMonValueChange
fires on any value change by user or by state. But onValueChangeFinished
fires only at the end of user interaction. So if I want to bind the value with player and at the same time accept user interaction I must ignore player position updates from listener while user is interacting with the slider and start accepting player position when user stops playing the slider barThomas
02/27/2021, 11:37 PMI think onValueChange fires on any value change by user or by state.
At the moment it is called by user and by state changes, but the latter is a bug which was confirmed in the linked issue.
Rick Regan
02/27/2021, 11:50 PM@Composable
fun SliderTest() {
println("SliderTest: Composed")
var position by remember { mutableStateOf(0f) }
var userPosition by remember { mutableStateOf(0f) }
Slider(
value = position,
onValueChange = {
userPosition = it
println("SliderTest: Position changed: userPosition = $userPosition (position = $position)")
},
onValueChangeFinished = {
position = userPosition
println("SliderTest: User selected position: (position = $position)")
}
)
}
rsktash
02/28/2021, 4:37 PMRick Regan
02/28/2021, 5:16 PM...I/System.out: SliderTest: Composed
...I/System.out: SliderTest: Position changed: userPosition = 0.0 (position = 0.0)
Clicking to the right (the thumb jumps as expected) gives:
...I/System.out: SliderTest: Position changed: userPosition = 0.8638611 (position = 0.0)
...I/System.out: SliderTest: User selected position: (position = 0.8638611)
...I/System.out: SliderTest: Composed
But then clicking to the left (the thumb doesn't move) gives:
...I/System.out: SliderTest: Position changed: userPosition = 0.087005615 (position = 0.8638611)
...I/System.out: SliderTest: Position changed: userPosition = 0.8638611 (position = 0.8638611)
...I/System.out: SliderTest: User selected position: (position = 0.8638611)
Thomas, that second callback is likely bug 75943373 as well, as you suspected. It overrides the position with the old position. I don't know why it only happens in that direction though. This has not been a problem in my app (except at initialization), maybe because I don't use onValueChangeFinished.
rsktash
02/28/2021, 5:30 PMRick Regan
02/28/2021, 6:39 PMSlider
issues will be addressed.