oli107 / material-range-bar

Android widget for selecting a range of values.
Apache License 2.0
1.68k stars 370 forks source link

The range bar allows you to swipe past the end #156

Open zsweigart opened 5 years ago

zsweigart commented 5 years ago

If you swipe on an angle (e.g. down and to the left) past the end of the range bar you can set the value to outside the range bar entirely. Once you are in that state backgrounding and foregrounding the app causes an exception to be thrown in setRangePinsByIndices because the left value is less than the minimum value. I have been able to get around it using

` mRangeBar.setOnRangeBarChangeListener( (rangeBar, i, i1, left, right) -> { Logger.d(TAG, "onRangeChangeListener");

    if (Integer.parseInt(rangeBar.getLeftPinValue()) < minValue) {
      left = String.valueOf(minValue);
      mRangeBar.setRangePinsByValue(Integer.parseInt(left), Integer.parseInt(right));
    }

    if (Integer.parseInt(rangeBar.getRightPinValue()) > maxValue) {
      right = String.valueOf(maxValue);
      mRangeBar.setRangePinsByValue(Integer.parseInt(left), Integer.parseInt(right));
    }

}); `

but that is just a hacky workaround and this should be built into the library

ByeonWoojeong commented 5 years ago

I tried it but it does not apply...

If I move my finger thousands of times, the same problem continue to happen...