mirror of
https://github.com/SimpleMobileTools/Simple-Keyboard.git
synced 2025-06-05 21:49:26 +02:00
simplifying a function
This commit is contained in:
@ -79,13 +79,11 @@ class MyKeyboard {
|
|||||||
|
|
||||||
fun getDimensionOrFraction(a: TypedArray, index: Int, base: Int, defValue: Int): Int {
|
fun getDimensionOrFraction(a: TypedArray, index: Int, base: Int, defValue: Int): Int {
|
||||||
val value = a.peekValue(index) ?: return defValue
|
val value = a.peekValue(index) ?: return defValue
|
||||||
if (value.type == TypedValue.TYPE_DIMENSION) {
|
return when (value.type) {
|
||||||
return a.getDimensionPixelOffset(index, defValue)
|
TypedValue.TYPE_DIMENSION -> a.getDimensionPixelOffset(index, defValue)
|
||||||
} else if (value.type == TypedValue.TYPE_FRACTION) {
|
TypedValue.TYPE_FRACTION -> Math.round(a.getFraction(index, base, base, defValue.toFloat()))
|
||||||
// Round it to avoid values like 47.9999 from getting truncated
|
else -> defValue
|
||||||
return Math.round(a.getFraction(index, base, base, defValue.toFloat()))
|
|
||||||
}
|
}
|
||||||
return defValue
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user