Fix crash related to slider
This commit is contained in:
@@ -15,8 +15,8 @@ android {
|
|||||||
applicationId 'org.koitharu.kotatsu'
|
applicationId 'org.koitharu.kotatsu'
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 33
|
targetSdkVersion 33
|
||||||
versionCode 501
|
versionCode 502
|
||||||
versionName '4.0.1'
|
versionName '4.0.2'
|
||||||
generatedDensities = []
|
generatedDensities = []
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,11 @@ fun <T> RecyclerView.ViewHolder.getItem(clazz: Class<T>): T? {
|
|||||||
|
|
||||||
fun Slider.setValueRounded(newValue: Float) {
|
fun Slider.setValueRounded(newValue: Float) {
|
||||||
val step = stepSize
|
val step = stepSize
|
||||||
val roundedValue = (newValue / step).roundToInt() * step
|
val roundedValue = if (step <= 0f) {
|
||||||
|
newValue
|
||||||
|
} else {
|
||||||
|
(newValue / step).roundToInt() * step
|
||||||
|
}
|
||||||
value = roundedValue.coerceIn(valueFrom, valueTo)
|
value = roundedValue.coerceIn(valueFrom, valueTo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user