MultiSlider icon indicating copy to clipboard operation
MultiSlider copied to clipboard

Multlislider does not set min value more than 100

Open ravikanasagra1 opened this issue 7 years ago • 5 comments

I have used below code to set min and max value for slider.

`MultiSlider multiSlider5 = (MultiSlider)findViewById(R.id.range_slider5);

    multiSlider5.setMin(3000,true, true);
    multiSlider5.setMax(5115,true, true);` 

Min value is set at 100, instead of 3000. It should set 3000.

ravikanasagra1 avatar May 25 '17 10:05 ravikanasagra1

It's library internal check logic. You can't set min value greater than internal max and vice versa. That's why you get min value = 100.

bmx666 avatar May 26 '17 12:05 bmx666

Library requires add func setMinMax for set Min and Max values at the same time.

bmx666 avatar May 26 '17 12:05 bmx666

I found one solution as per current logic. We need to set setMax first then set min will solve the issue.

ravikanasagra1 avatar May 26 '17 12:05 ravikanasagra1

Fix for both situations

if (new_min > ms.getMax()) {
   ms.setMax(new_max, true, true);
   ms.setMin(new_min, true, true);
} else {
   ms.setMin(new_min, true, true);
   ms.setMax(new_max, true, true);
}

bmx666 avatar May 26 '17 12:05 bmx666

Convenience method to set both would be good, and maybe throw exceptions when setting wrong bounds, so the dev will know what is wrong right away...

joaoBeno avatar Jul 20 '17 19:07 joaoBeno