AnderWeb / AnderWeb/discreteSeekBar

Limiting the range of a discreteSeekBar based on another one

Đang mở
#50 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Java
Star
2.1k
Fork
417
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

![screenshot_2015-09-29-17-16-15](https://cloud.githubusercontent.com/assets/1422362/10168746/6745997a-66ce-11e5-9b66-b00592fdcbb3.png)

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
![screenshot_2015-09-29-17-16-33](https://cloud.githubusercontent.com/assets/1422362/10168795/b7290b5c-66ce-11e5-837c-235039810ecc.png)

Here I keep dragging the MaxPrice marker down. It does not move, but the value changes
![screenshot_2015-09-29-17-16-37](https://cloud.githubusercontent.com/assets/1422362/10168807/c4bf6306-66ce-11e5-952a-6c7493ac1a75.png)

Do you have any suggestion about how could I avoid this behavior?

Thank you

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.