-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: round slider value to fix illegalStateException
- Loading branch information
1 parent
3c81fec
commit 2229b1e
Showing
2 changed files
with
15 additions
and
5 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
core/common/src/main/java/dev/anilbeesetti/nextplayer/core/common/extensions/Float.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package dev.anilbeesetti.nextplayer.core.common.extensions | ||
|
||
import kotlin.math.pow | ||
import kotlin.math.roundToInt | ||
|
||
fun Float.round(decimalPlaces: Int): Float { | ||
return (this * 10.0.pow(decimalPlaces.toDouble())) | ||
.roundToInt() / 10.0.pow(decimalPlaces.toDouble()).toFloat() | ||
} |
This file contains 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