Skip to content

[Slider] java.lang.IllegalStateException: valueFrom(2.0) must be smaller than valueTo(2.0) #2787

@amitlodha

Description

@amitlodha

Description:
When i set value to slider having same valueTo and ValueFrom it crash

Crash Logs:
java.lang.IllegalStateException: valueFrom(2.0) must be smaller than valueTo(2.0)
at com.google.android.material.slider.BaseSlider.validateValueFrom(BaseSlider.java:520)
at com.google.android.material.slider.BaseSlider.validateConfigurationIfDirty(BaseSlider.java:608)
at com.google.android.material.slider.BaseSlider.onDraw(BaseSlider.java:1662)
at android.view.View.draw(View.java:22644)
at android.view.View.updateDisplayListIfDirty(View.java:21519)

Suggestion:
We should not throw exception instead we should accept the same value

private void validateValueFrom() {
if (valueFrom >= valueTo) {
throw new IllegalStateException(
String.format(EXCEPTION_ILLEGAL_VALUE_FROM, valueFrom, valueTo));
}
}

private void validateValueTo() {
if (valueTo <= valueFrom) {
throw new IllegalStateException(
String.format(EXCEPTION_ILLEGAL_VALUE_TO, valueTo, valueFrom));
}
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions