AnderWeb / AnderWeb/discreteSeekBar
Limiting the range of a discreteSeekBar based on another one
- Lenguaje dominante
- Java
- Estrellas
- 2.1k
- Forks
- 417
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Hello everybody,
I'd rather not to use a single range bar for my min-max range, so I chose to use two seekbars. When I drag the value on the MinPrice bar, when I get to the same value I have on the MaxPrice the dragging should stop.

I handled this using the setOnProgressChangeListener in this way
```
maxPriceBar.setOnProgressChangeListener(new DiscreteSeekBar.OnProgressChangeListener() {
@Override
public void onProgressChanged(DiscreteSeekBar seekBar, int value, boolean fromUser) {
if(value <= minPriceBar.getProgress()) {
maxPriceBar.setProgress(minPriceBar.getProgress());
return;
}
}
@Override
public void onStartTrackingTouch(DiscreteSeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(DiscreteSeekBar seekBar) {
if (maxPriceBar.getProgress() <= minPriceBar.getProgress()) {
maxPriceBar.setProgress(minPriceBar.getProgress());
}
}
});
```
The same applies to the other seekBar, with opposite checks.
I expect the two seekBars to prevent the user from dragging the marker higher than the value of the MaxPrice bar and lower than the value of the MinPrice bar. And it does! The only issue is that, if I keep dragging in the direction I'm prevented to, the marker does not move but the text in the bubble changes.
Two pictures are worth a thousand words:
Here I stop at the same value

Here I keep dragging the MaxPrice marker down. It does not move, but the value changes

Do you have any suggestion about how could I avoid this behavior?
Thank you
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.