Skip to content

Commit

Permalink
Reset actualXPosition if min/max/default/limit values are changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Edgar Žigis committed Mar 31, 2021
1 parent 5126ebd commit b3ee4fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Make sure you have jitpack.io included in your gradle repositories.
maven { url "https://jitpack.io" }
```
```
implementation 'com.github.edgar-zigis:LabeledSeekSlider:1.0.4'
implementation 'com.github.edgar-zigis:LabeledSeekSlider:1.0.5'
```
### Usage
``` xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ open class LabeledSeekSlider : View {

var minValue: Int = 0
set(value) {
if (field != value) {
actualXPosition = null
}
field = value
if (actualFractionalValue < value) {
actualFractionalValue = value
Expand All @@ -35,6 +38,9 @@ open class LabeledSeekSlider : View {
}
var maxValue: Int = 100
set(value) {
if (field != value) {
actualXPosition = null
}
field = value
if (actualFractionalValue > value) {
actualFractionalValue = value
Expand All @@ -43,13 +49,19 @@ open class LabeledSeekSlider : View {
}
var defaultValue: Int = 50
set(value) {
if (field != value) {
actualXPosition = null
}
val newValue = min(maxValue, max(minValue, value))
field = newValue
actualFractionalValue = newValue
invalidate()
}
var limitValue: Int? = null
set(value) {
if (field != value) {
actualXPosition = null
}
field = value
if (value != null && actualFractionalValue > value) {
actualFractionalValue = value
Expand Down

0 comments on commit b3ee4fd

Please sign in to comment.