Fix crash related to slider

pull/251/head v4.0.2
Koitharu 4 years ago
parent ff58539e2e
commit cec19c3db3
No known key found for this signature in database
GPG Key ID: 8E861F8CE6E7CE27

@ -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)
} }

Loading…
Cancel
Save