Conversation
Add binding adapter that sets slider range before value to prevent IllegalStateException when camera reports zoom ratio below the slider's default minimum. The adapter intercepts all three slider attributes (value, valueFrom, valueTo) and sets them in the correct order, avoiding the race condition where data binding could set value before the range was updated. Fixes crash: "Slider value(0.6) must be greater or equal to valueFrom(1.0)" --- The Issue (High Level) The Slider widget crashes when its value is outside the [valueFrom, valueTo] range at draw time. The race condition: - Camera with ultra-wide lens is selected (zoom range: 0.6x - 8.0x) - The camera reports current zoom = 0.6x - Data binding updates fire, but in the wrong order: - zoomRatio → 0.6 (but slider still has default range 1.0-8.0) - zoomRatioRange → [0.6, 8.0] (too late!) - Slider tries to draw with value=0.6, min=1.0 → CRASH
9db9a89 to
d981913
Compare
dimadesu
commented
Feb 7, 2026
| * Handles both Float and Integer (Number) values. | ||
| */ | ||
| @BindingAdapter("android:value", "android:valueFrom", "android:valueTo", requireAll = true) | ||
| fun setSliderValueWithRange(slider: Slider, value: Number?, valueFrom: Number?, valueTo: Number?) { |
Owner
Author
There was a problem hiding this comment.
@copilot how is this used? Will it have any performance impact?
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #271
Fix slider crash on cameras with ultra-wide zoom (< 1.0x)
Add binding adapter that sets slider range before value to prevent
IllegalStateException when camera reports zoom ratio below the
slider's default minimum.
The adapter intercepts all three slider attributes (value, valueFrom,
valueTo) and sets them in the correct order, avoiding the race
condition where data binding could set value before the range was
updated.
Fixes crash: "Slider value(0.6) must be greater or equal to valueFrom(1.0)"
The Issue (High Level)
The Slider widget crashes when its value is outside the [valueFrom, valueTo] range at draw time.
The race condition: